Add IPC decoding support to BackForwardListState
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Jun 2014 16:58:27 +0000 (16:58 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Jun 2014 16:58:27 +0000 (16:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134171

Reviewed by Dan Bernstein.

* Shared/SessionState.cpp:
(WebKit::isValidEnum):
(WebKit::HTTPBody::Element::decode):
(WebKit::HTTPBody::decode):
(WebKit::FrameState::decode):
(WebKit::PageState::decode):
(WebKit::BackForwardListState::decode):
* Shared/SessionState.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170264 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/SessionState.cpp
Source/WebKit2/Shared/SessionState.h

index 5ced1a0..a4566f1 100644 (file)
@@ -1,5 +1,21 @@
 2014-06-22  Anders Carlsson  <andersca@apple.com>
 
+        Add IPC decoding support to BackForwardListState
+        https://bugs.webkit.org/show_bug.cgi?id=134171
+
+        Reviewed by Dan Bernstein.
+
+        * Shared/SessionState.cpp:
+        (WebKit::isValidEnum):
+        (WebKit::HTTPBody::Element::decode):
+        (WebKit::HTTPBody::decode):
+        (WebKit::FrameState::decode):
+        (WebKit::PageState::decode):
+        (WebKit::BackForwardListState::decode):
+        * Shared/SessionState.h:
+
+2014-06-22  Anders Carlsson  <andersca@apple.com>
+
         Address a review comment.
 
         * UIProcess/mac/LegacySessionStateCoding.cpp:
index 5af7600..2ce89be 100644 (file)
@@ -41,12 +41,54 @@ void HTTPBody::Element::encode(IPC::ArgumentEncoder& encoder) const
     encoder << blobURLString;
 }
 
+static bool isValidEnum(HTTPBody::Element::Type type)
+{
+    switch (type) {
+    case HTTPBody::Element::Type::Data:
+    case HTTPBody::Element::Type::File:
+    case HTTPBody::Element::Type::Blob:
+        return true;
+    }
+
+    return false;
+}
+
+bool HTTPBody::Element::decode(IPC::ArgumentDecoder& decoder, Element& result)
+{
+    if (!decoder.decodeEnum(result.type) || !isValidEnum(result.type))
+        return false;
+    if (!decoder.decode(result.data))
+        return false;
+    if (!decoder.decode(result.filePath))
+        return false;
+    if (!decoder.decode(result.fileStart))
+        return false;
+    if (!decoder.decode(result.fileLength))
+        return false;
+    if (!decoder.decode(result.expectedFileModificationTime))
+        return false;
+    if (!decoder.decode(result.blobURLString))
+        return false;
+
+    return true;
+}
+
 void HTTPBody::encode(IPC::ArgumentEncoder& encoder) const
 {
     encoder << contentType;
     encoder << elements;
 }
 
+bool HTTPBody::decode(IPC::ArgumentDecoder& decoder, HTTPBody& result)
+{
+    if (!decoder.decode(result.contentType))
+        return false;
+    if (!decoder.decode(result.elements))
+        return false;
+
+    return true;
+}
+
 void FrameState::encode(IPC::ArgumentEncoder& encoder) const
 {
     encoder << urlString;
@@ -68,15 +110,68 @@ void FrameState::encode(IPC::ArgumentEncoder& encoder) const
     encoder << children;
 }
 
+bool FrameState::decode(IPC::ArgumentDecoder& decoder, FrameState& result)
+{
+    if (!decoder.decode(result.urlString))
+        return false;
+    if (!decoder.decode(result.originalURLString))
+        return false;
+    if (!decoder.decode(result.referrer))
+        return false;
+    if (!decoder.decode(result.target))
+        return false;
+
+    if (!decoder.decode(result.documentState))
+        return false;
+    if (!decoder.decode(result.stateObjectData))
+        return false;
+
+    if (!decoder.decode(result.documentSequenceNumber))
+        return false;
+    if (!decoder.decode(result.itemSequenceNumber))
+        return false;
+
+    if (!decoder.decode(result.scrollPoint))
+        return false;
+    if (!decoder.decode(result.pageScaleFactor))
+        return false;
+
+    if (!decoder.decode(result.httpBody))
+        return false;
+
+    if (!decoder.decode(result.children))
+        return false;
+
+    return true;
+}
+
 void PageState::encode(IPC::ArgumentEncoder& encoder) const
 {
     encoder << mainFrameState;
 }
 
+bool PageState::decode(IPC::ArgumentDecoder& decoder, PageState& result)
+{
+    if (!decoder.decode(result.mainFrameState))
+        return false;
+
+    return true;
+}
+
 void BackForwardListState::encode(IPC::ArgumentEncoder& encoder) const
 {
     encoder << items;
     encoder << currentIndex;
 }
 
+bool BackForwardListState::decode(IPC::ArgumentDecoder& decoder, BackForwardListState& result)
+{
+    if (!decoder.decode(result.items))
+        return false;
+    if (!decoder.decode(result.currentIndex))
+        return false;
+
+    return true;
+}
+
 } // namespace WebKit
index a6e316c..591d194 100644 (file)
@@ -42,6 +42,7 @@ namespace WebKit {
 struct HTTPBody {
     struct Element {
         void encode(IPC::ArgumentEncoder&) const;
+        static bool decode(IPC::ArgumentDecoder&, Element&);
 
         enum class Type {
             Data,
@@ -65,6 +66,7 @@ struct HTTPBody {
     };
 
     void encode(IPC::ArgumentEncoder&) const;
+    static bool decode(IPC::ArgumentDecoder&, HTTPBody&);
 
     String contentType;
     Vector<Element> elements;
@@ -72,6 +74,7 @@ struct HTTPBody {
 
 struct FrameState {
     void encode(IPC::ArgumentEncoder&) const;
+    static bool decode(IPC::ArgumentDecoder&, FrameState&);
 
     String urlString;
     String originalURLString;
@@ -94,6 +97,7 @@ struct FrameState {
 
 struct PageState {
     void encode(IPC::ArgumentEncoder&) const;
+    static bool decode(IPC::ArgumentDecoder&, PageState&);
 
     String title;
     FrameState mainFrameState;
@@ -101,6 +105,7 @@ struct PageState {
 
 struct BackForwardListState {
     void encode(IPC::ArgumentEncoder&) const;
+    static bool decode(IPC::ArgumentDecoder&, BackForwardListState&);
 
     Vector<PageState> items;
     uint32_t currentIndex;