Title: [170226] trunk/Source/WebKit2
Revision
170226
Author
[email protected]
Date
2014-06-20 17:11:57 -0700 (Fri, 20 Jun 2014)

Log Message

Implement more of LegacySessionStateDecoder
https://bugs.webkit.org/show_bug.cgi?id=134145

Reviewed by Sam Weinig.

* Shared/SessionState.h:
* UIProcess/mac/LegacySessionStateCoding.cpp:
(WebKit::LegacySessionStateDecoder::decodeSessionHistoryEntry):
(WebKit::HistoryEntryDataDecoder::HistoryEntryDataDecoder):
(WebKit::HistoryEntryDataDecoder::finishDecoding):
(WebKit::LegacySessionStateDecoder::decodeSessionHistoryEntryData):
* UIProcess/mac/LegacySessionStateCoding.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (170225 => 170226)


--- trunk/Source/WebKit2/ChangeLog	2014-06-20 23:48:37 UTC (rev 170225)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-21 00:11:57 UTC (rev 170226)
@@ -1,6 +1,21 @@
 2014-06-20  Anders Carlsson  <[email protected]>
 
         Implement more of LegacySessionStateDecoder
+        https://bugs.webkit.org/show_bug.cgi?id=134145
+
+        Reviewed by Sam Weinig.
+
+        * Shared/SessionState.h:
+        * UIProcess/mac/LegacySessionStateCoding.cpp:
+        (WebKit::LegacySessionStateDecoder::decodeSessionHistoryEntry):
+        (WebKit::HistoryEntryDataDecoder::HistoryEntryDataDecoder):
+        (WebKit::HistoryEntryDataDecoder::finishDecoding):
+        (WebKit::LegacySessionStateDecoder::decodeSessionHistoryEntryData):
+        * UIProcess/mac/LegacySessionStateCoding.h:
+
+2014-06-20  Anders Carlsson  <[email protected]>
+
+        Implement more of LegacySessionStateDecoder
         https://bugs.webkit.org/show_bug.cgi?id=134144
 
         Reviewed by Sam Weinig.

Modified: trunk/Source/WebKit2/Shared/SessionState.h (170225 => 170226)


--- trunk/Source/WebKit2/Shared/SessionState.h	2014-06-20 23:48:37 UTC (rev 170225)
+++ trunk/Source/WebKit2/Shared/SessionState.h	2014-06-21 00:11:57 UTC (rev 170226)
@@ -95,6 +95,7 @@
 struct PageState {
     void encode(IPC::ArgumentEncoder&) const;
 
+    String title;
     FrameState mainFrameState;
 };
 

Modified: trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp (170225 => 170226)


--- trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp	2014-06-20 23:48:37 UTC (rev 170225)
+++ trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp	2014-06-21 00:11:57 UTC (rev 170226)
@@ -43,6 +43,13 @@
 static const CFStringRef sessionHistoryCurrentIndexKey = CFSTR("SessionHistoryCurrentIndex");
 static const CFStringRef sessionHistoryEntriesKey = CFSTR("SessionHistoryEntries");
 
+// Session history entry keys.
+static const CFStringRef sessionHistoryEntryURLKey = CFSTR("SessionHistoryEntryURL");
+static CFStringRef sessionHistoryEntryTitleKey = CFSTR("SessionHistoryEntryTitle");
+static CFStringRef sessionHistoryEntryOriginalURLKey = CFSTR("SessionHistoryEntryOriginalURL");
+static CFStringRef sessionHistoryEntrySnapshotUUIDKey = CFSTR("SessionHistoryEntrySnapshotUUID");
+static CFStringRef sessionHistoryEntryDataKey = CFSTR("SessionHistoryEntryData");
+
 LegacySessionStateDecoder::LegacySessionStateDecoder(API::Data* data)
     : m_data(data)
 {
@@ -162,8 +169,54 @@
 
 bool LegacySessionStateDecoder::decodeSessionHistoryEntry(CFDictionaryRef entryDictionary, PageState& pageState) const
 {
+    auto title = dynamic_cf_cast<CFStringRef>(CFDictionaryGetValue(entryDictionary, sessionHistoryEntryTitleKey));
+    if (!title)
+        return false;
+
+    auto urlString = dynamic_cf_cast<CFStringRef>(CFDictionaryGetValue(entryDictionary, sessionHistoryEntryURLKey));
+    if (!urlString)
+        return false;
+
+    auto originalURLString = dynamic_cf_cast<CFStringRef>(CFDictionaryGetValue(entryDictionary, sessionHistoryEntryOriginalURLKey));
+    if (!originalURLString)
+        return false;
+
+    auto historyEntryData = dynamic_cf_cast<CFDataRef>(CFDictionaryGetValue(entryDictionary, sessionHistoryEntryDataKey));
+    if (!historyEntryData)
+        return false;
+
+    if (!decodeSessionHistoryEntryData(historyEntryData, pageState.mainFrameState))
+        return false;
+
+    pageState.title = title;
+    pageState.mainFrameState.urlString = urlString;
+    pageState.mainFrameState.originalURLString = originalURLString;
+
+    return true;
+}
+
+class HistoryEntryDataDecoder {
+public:
+    HistoryEntryDataDecoder(const uint8_t* buffer, size_t bufferSize)
+        : m_buffer(buffer)
+        , m_bufferEnd(buffer + bufferSize)
+    {
+    }
+
+    bool finishDecoding() { return m_buffer == m_bufferEnd; }
+
+private:
+    const uint8_t* m_buffer;
+    const uint8_t* m_bufferEnd;
+};
+
+bool LegacySessionStateDecoder::decodeSessionHistoryEntryData(CFDataRef historyEntryData, FrameState& mainFrameState) const
+{
+    HistoryEntryDataDecoder decoder { CFDataGetBytePtr(historyEntryData), static_cast<size_t>(CFDataGetLength(historyEntryData)) };
+
     // FIXME: Implement this.
-    return false;
+
+    return decoder.finishDecoding();
 }
 
 

Modified: trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.h (170225 => 170226)


--- trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.h	2014-06-20 23:48:37 UTC (rev 170225)
+++ trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.h	2014-06-21 00:11:57 UTC (rev 170226)
@@ -35,8 +35,9 @@
 namespace WebKit {
 
 struct BackForwardListState;
+struct FrameState;
+struct PageState;
 struct SessionState;
-struct PageState;
 
 class LegacySessionStateDecoder {
 public:
@@ -52,6 +53,7 @@
 
     bool decodeSessionHistoryEntries(CFArrayRef, Vector<PageState>&) const;
     bool decodeSessionHistoryEntry(CFDictionaryRef, PageState&) const;
+    bool decodeSessionHistoryEntryData(CFDataRef, FrameState&) const;
 
     API::Data* m_data;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to