Move Soup specific code out of WebCoreArgumentCoders.cpp
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Aug 2014 12:38:30 +0000 (12:38 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Aug 2014 12:38:30 +0000 (12:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135665

Reviewed by Anders Carlsson.

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ResourceRequest>::encode):
(IPC::ArgumentCoder<ResourceRequest>::decode):
(IPC::ArgumentCoder<ResourceError>::encode):
(IPC::ArgumentCoder<ResourceError>::decode):
* Shared/WebCoreArgumentCoders.h:

    Soup is the only client for this code. Move it to *Soup.cpp

* Shared/soup/WebCoreArgumentCodersSoup.cpp:
(IPC::ArgumentCoder<ResourceRequest>::encodePlatformData):
(IPC::ArgumentCoder<ResourceRequest>::decodePlatformData):
(IPC::ArgumentCoder<ResourceError>::encodePlatformData):
(IPC::ArgumentCoder<ResourceError>::decodePlatformData):

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/Shared/WebCoreArgumentCoders.h
Source/WebKit2/Shared/soup/WebCoreArgumentCodersSoup.cpp

index 9b4aa02..21521de 100644 (file)
@@ -1,3 +1,25 @@
+2014-08-06  Antti Koivisto  <antti@apple.com>
+
+        Move Soup specific code out of WebCoreArgumentCoders.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=135665
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<ResourceRequest>::encode):
+        (IPC::ArgumentCoder<ResourceRequest>::decode):
+        (IPC::ArgumentCoder<ResourceError>::encode):
+        (IPC::ArgumentCoder<ResourceError>::decode):
+        * Shared/WebCoreArgumentCoders.h:
+        
+            Soup is the only client for this code. Move it to *Soup.cpp
+
+        * Shared/soup/WebCoreArgumentCodersSoup.cpp:
+        (IPC::ArgumentCoder<ResourceRequest>::encodePlatformData):
+        (IPC::ArgumentCoder<ResourceRequest>::decodePlatformData):
+        (IPC::ArgumentCoder<ResourceError>::encodePlatformData):
+        (IPC::ArgumentCoder<ResourceError>::decodePlatformData):
+
 2014-08-06  Tim Horton  <timothy_horton@apple.com>
 
         Services overlay flashes a lot; should have some hysteresis before showing overlay
index d8c0059..35992e5 100644 (file)
@@ -632,22 +632,6 @@ bool ArgumentCoder<Cursor>::decode(ArgumentDecoder& decoder, Cursor& cursor)
 
 void ArgumentCoder<ResourceRequest>::encode(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest)
 {
-    if (kShouldSerializeWebCoreData) {
-        encoder << resourceRequest.url().string();
-        encoder << resourceRequest.httpMethod();
-        encoder << resourceRequest.httpHeaderFields();
-
-        // FIXME: Do not encode HTTP message body.
-        // 1. It can be large and thus costly to send across.
-        // 2. It is misleading to provide a body with some requests, while others use body streams, which cannot be serialized at all.
-        FormData* httpBody = resourceRequest.httpBody();
-        encoder << static_cast<bool>(httpBody);
-        if (httpBody)
-            encoder << httpBody->flattenToString();
-
-        encoder << resourceRequest.firstPartyForCookies().string();
-    }
-
 #if ENABLE(CACHE_PARTITIONING)
     encoder << resourceRequest.cachePartition();
 #endif
@@ -667,42 +651,6 @@ void ArgumentCoder<ResourceRequest>::encode(ArgumentEncoder& encoder, const Reso
 
 bool ArgumentCoder<ResourceRequest>::decode(ArgumentDecoder& decoder, ResourceRequest& resourceRequest)
 {
-    if (kShouldSerializeWebCoreData) {
-        ResourceRequest request;
-
-        String url;
-        if (!decoder.decode(url))
-            return false;
-        request.setURL(URL(URL(), url));
-
-        String httpMethod;
-        if (!decoder.decode(httpMethod))
-            return false;
-        request.setHTTPMethod(httpMethod);
-
-        HTTPHeaderMap headers;
-        if (!decoder.decode(headers))
-            return false;
-        request.setHTTPHeaderFields(WTF::move(headers));
-
-        bool hasHTTPBody;
-        if (!decoder.decode(hasHTTPBody))
-            return false;
-        if (hasHTTPBody) {
-            String httpBody;
-            if (!decoder.decode(httpBody))
-                return false;
-            request.setHTTPBody(FormData::create(httpBody.utf8()));
-        }
-
-        String firstPartyForCookies;
-        if (!decoder.decode(firstPartyForCookies))
-            return false;
-        request.setFirstPartyForCookies(URL(URL(), firstPartyForCookies));
-
-        resourceRequest = request;
-    }
-
 #if ENABLE(CACHE_PARTITIONING)
     String cachePartition;
     if (!decoder.decode(cachePartition))
@@ -851,63 +799,11 @@ bool ArgumentCoder<ResourceResponse>::decode(ArgumentDecoder& decoder, ResourceR
 
 void ArgumentCoder<ResourceError>::encode(ArgumentEncoder& encoder, const ResourceError& resourceError)
 {
-    if (kShouldSerializeWebCoreData) {
-        bool errorIsNull = resourceError.isNull();
-        encoder << errorIsNull;
-        if (errorIsNull)
-            return;
-
-        encoder << resourceError.domain();
-        encoder << resourceError.errorCode();
-        encoder << resourceError.failingURL();
-        encoder << resourceError.localizedDescription();
-        encoder << resourceError.isCancellation();
-        encoder << resourceError.isTimeout();
-    }
-
     encodePlatformData(encoder, resourceError);
 }
 
 bool ArgumentCoder<ResourceError>::decode(ArgumentDecoder& decoder, ResourceError& resourceError)
 {
-    if (kShouldSerializeWebCoreData) {
-        bool errorIsNull;
-        if (!decoder.decode(errorIsNull))
-            return false;
-        if (errorIsNull) {
-            resourceError = ResourceError();
-            return true;
-        }
-
-        String domain;
-        if (!decoder.decode(domain))
-            return false;
-
-        int errorCode;
-        if (!decoder.decode(errorCode))
-            return false;
-
-        String failingURL;
-        if (!decoder.decode(failingURL))
-            return false;
-
-        String localizedDescription;
-        if (!decoder.decode(localizedDescription))
-            return false;
-
-        bool isCancellation;
-        if (!decoder.decode(isCancellation))
-            return false;
-
-        bool isTimeout;
-        if (!decoder.decode(isTimeout))
-            return false;
-
-        resourceError = ResourceError(domain, errorCode, failingURL, localizedDescription);
-        resourceError.setIsCancellation(isCancellation);
-        resourceError.setIsTimeout(isTimeout);
-    }
-
     return decodePlatformData(decoder, resourceError);
 }
 
index ae5b5c7..1bea0d1 100644 (file)
@@ -245,12 +245,6 @@ template<> struct ArgumentCoder<WebCore::Cursor> {
 };
 
 template<> struct ArgumentCoder<WebCore::ResourceRequest> {
-#if PLATFORM(COCOA)
-    static const bool kShouldSerializeWebCoreData = false;
-#else
-    static const bool kShouldSerializeWebCoreData = true;
-#endif
-
     static void encode(ArgumentEncoder&, const WebCore::ResourceRequest&);
     static bool decode(ArgumentDecoder&, WebCore::ResourceRequest&);
     static void encodePlatformData(ArgumentEncoder&, const WebCore::ResourceRequest&);
@@ -265,12 +259,6 @@ template<> struct ArgumentCoder<WebCore::ResourceResponse> {
 };
 
 template<> struct ArgumentCoder<WebCore::ResourceError> {
-#if PLATFORM(COCOA)
-    static const bool kShouldSerializeWebCoreData = false;
-#else
-    static const bool kShouldSerializeWebCoreData = true;
-#endif
-
     static void encode(ArgumentEncoder&, const WebCore::ResourceError&);
     static bool decode(ArgumentDecoder&, WebCore::ResourceError&);
     static void encodePlatformData(ArgumentEncoder&, const WebCore::ResourceError&);
index 1d8098e..5ae8032 100644 (file)
@@ -41,12 +41,56 @@ namespace IPC {
 
 void ArgumentCoder<ResourceRequest>::encodePlatformData(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest)
 {
+    encoder << resourceRequest.url().string();
+    encoder << resourceRequest.httpMethod();
+    encoder << resourceRequest.httpHeaderFields();
+
+    // FIXME: Do not encode HTTP message body.
+    // 1. It can be large and thus costly to send across.
+    // 2. It is misleading to provide a body with some requests, while others use body streams, which cannot be serialized at all.
+    FormData* httpBody = resourceRequest.httpBody();
+    encoder << static_cast<bool>(httpBody);
+    if (httpBody)
+        encoder << httpBody->flattenToString();
+
+    encoder << resourceRequest.firstPartyForCookies().string();
+
     encoder << static_cast<uint32_t>(resourceRequest.soupMessageFlags());
     encoder << resourceRequest.initiatingPageID();
 }
 
 bool ArgumentCoder<ResourceRequest>::decodePlatformData(ArgumentDecoder& decoder, ResourceRequest& resourceRequest)
 {
+    String url;
+    if (!decoder.decode(url))
+        return false;
+    resourceRequest.setURL(URL(URL(), url));
+
+    String httpMethod;
+    if (!decoder.decode(httpMethod))
+        return false;
+    resourceRequest.setHTTPMethod(httpMethod);
+
+    HTTPHeaderMap headers;
+    if (!decoder.decode(headers))
+        return false;
+    resourceRequest.setHTTPHeaderFields(WTF::move(headers));
+
+    bool hasHTTPBody;
+    if (!decoder.decode(hasHTTPBody))
+        return false;
+    if (hasHTTPBody) {
+        String httpBody;
+        if (!decoder.decode(httpBody))
+            return false;
+        resourceRequest.setHTTPBody(FormData::create(httpBody.utf8()));
+    }
+
+    String firstPartyForCookies;
+    if (!decoder.decode(firstPartyForCookies))
+        return false;
+    resourceRequest.setFirstPartyForCookies(URL(URL(), firstPartyForCookies));
+
     uint32_t soupMessageFlags;
     if (!decoder.decode(soupMessageFlags))
         return false;
@@ -60,7 +104,6 @@ bool ArgumentCoder<ResourceRequest>::decodePlatformData(ArgumentDecoder& decoder
     return true;
 }
 
-
 void ArgumentCoder<ResourceResponse>::encodePlatformData(ArgumentEncoder& encoder, const ResourceResponse& resourceResponse)
 {
     encoder << static_cast<uint32_t>(resourceResponse.soupMessageFlags());
@@ -127,11 +170,59 @@ bool ArgumentCoder<CertificateInfo>::decode(ArgumentDecoder& decoder, Certificat
 
 void ArgumentCoder<ResourceError>::encodePlatformData(ArgumentEncoder& encoder, const ResourceError& resourceError)
 {
+    bool errorIsNull = resourceError.isNull();
+    encoder << errorIsNull;
+    if (errorIsNull)
+        return;
+
+    encoder << resourceError.domain();
+    encoder << resourceError.errorCode();
+    encoder << resourceError.failingURL();
+    encoder << resourceError.localizedDescription();
+    encoder << resourceError.isCancellation();
+    encoder << resourceError.isTimeout();
+
     encoder << CertificateInfo(resourceError);
 }
 
 bool ArgumentCoder<ResourceError>::decodePlatformData(ArgumentDecoder& decoder, ResourceError& resourceError)
 {
+    bool errorIsNull;
+    if (!decoder.decode(errorIsNull))
+        return false;
+    if (errorIsNull) {
+        resourceError = ResourceError();
+        return true;
+    }
+
+    String domain;
+    if (!decoder.decode(domain))
+        return false;
+
+    int errorCode;
+    if (!decoder.decode(errorCode))
+        return false;
+
+    String failingURL;
+    if (!decoder.decode(failingURL))
+        return false;
+
+    String localizedDescription;
+    if (!decoder.decode(localizedDescription))
+        return false;
+
+    bool isCancellation;
+    if (!decoder.decode(isCancellation))
+        return false;
+
+    bool isTimeout;
+    if (!decoder.decode(isTimeout))
+        return false;
+
+    resourceError = ResourceError(domain, errorCode, failingURL, localizedDescription);
+    resourceError.setIsCancellation(isCancellation);
+    resourceError.setIsTimeout(isTimeout);
+
     CertificateInfo certificateInfo;
     if (!decoder.decode(certificateInfo))
         return false;