- Revision
- 200909
- Author
- [email protected]
- Date
- 2016-05-13 19:26:23 -0700 (Fri, 13 May 2016)
Log Message
[NetworkCache] Avoid having to re-parse URLs after deserializing them
https://bugs.webkit.org/show_bug.cgi?id=157660
Reviewed by Darin Adler.
Source/WebCore:
Avoid having to re-parse URLs after deserializing them in the WebKit2
network cache storage implementation.
We previously serialized URLs as Strings, which meant that we had the
re-parse them upon deserialization. We now serialize all of the URL
data members to avoid having to parse the String again.
* platform/URL.h:
(WebCore::URL::encode):
(WebCore::URL::decode):
* platform/network/ResourceRequestBase.h:
(WebCore::ResourceRequestBase::encodeWithoutPlatformData):
(WebCore::ResourceRequestBase::decodeWithoutPlatformData):
* platform/network/ResourceResponseBase.h:
(WebCore::ResourceResponseBase::encode):
(WebCore::ResourceResponseBase::decode):
Source/WebKit2:
* NetworkProcess/cache/NetworkCacheCoders.cpp:
(WebKit::NetworkCache::Coder<WebCore::CertificateInfo>::encode): Deleted.
(WebKit::NetworkCache::Coder<WebCore::CertificateInfo>::decode): Deleted.
* NetworkProcess/cache/NetworkCacheCoders.h:
Drop template specializations used by our network cache for encoding
/ decoding URLs as Strings. This causes us to now rely on
URL::encode() / URL::decode() instead.
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<BlobPart>::decode):
Fix bug in BlobPart encoding / decoding. It was encoding the url member
as a URL but decoding it as a String.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (200908 => 200909)
--- trunk/Source/WebCore/ChangeLog 2016-05-14 02:17:31 UTC (rev 200908)
+++ trunk/Source/WebCore/ChangeLog 2016-05-14 02:26:23 UTC (rev 200909)
@@ -1,3 +1,27 @@
+2016-05-13 Chris Dumez <[email protected]>
+
+ [NetworkCache] Avoid having to re-parse URLs after deserializing them
+ https://bugs.webkit.org/show_bug.cgi?id=157660
+
+ Reviewed by Darin Adler.
+
+ Avoid having to re-parse URLs after deserializing them in the WebKit2
+ network cache storage implementation.
+
+ We previously serialized URLs as Strings, which meant that we had the
+ re-parse them upon deserialization. We now serialize all of the URL
+ data members to avoid having to parse the String again.
+
+ * platform/URL.h:
+ (WebCore::URL::encode):
+ (WebCore::URL::decode):
+ * platform/network/ResourceRequestBase.h:
+ (WebCore::ResourceRequestBase::encodeWithoutPlatformData):
+ (WebCore::ResourceRequestBase::decodeWithoutPlatformData):
+ * platform/network/ResourceResponseBase.h:
+ (WebCore::ResourceResponseBase::encode):
+ (WebCore::ResourceResponseBase::decode):
+
2016-05-13 Sam Weinig <[email protected]>
ScriptController::processingUserGesture should propagate across postMessage boundaries
Modified: trunk/Source/WebCore/platform/URL.h (200908 => 200909)
--- trunk/Source/WebCore/platform/URL.h 2016-05-14 02:17:31 UTC (rev 200908)
+++ trunk/Source/WebCore/platform/URL.h 2016-05-14 02:26:23 UTC (rev 200909)
@@ -195,6 +195,9 @@
bool isSafeToSendToAnotherThread() const;
+ template <class Encoder> void encode(Encoder&) const;
+ template <class Decoder> static bool decode(Decoder&, URL&);
+
private:
WEBCORE_EXPORT void invalidate();
static bool protocolIs(const String&, const char*);
@@ -225,6 +228,64 @@
int m_fragmentEnd;
};
+template <class Encoder>
+void URL::encode(Encoder& encoder) const
+{
+ encoder << m_string;
+ encoder << static_cast<bool>(m_isValid);
+ if (!m_isValid)
+ return;
+ encoder << static_cast<bool>(m_protocolIsInHTTPFamily);
+ encoder << m_schemeEnd;
+ encoder << m_userStart;
+ encoder << m_userEnd;
+ encoder << m_passwordEnd;
+ encoder << m_hostEnd;
+ encoder << m_portEnd;
+ encoder << m_pathAfterLastSlash;
+ encoder << m_pathEnd;
+ encoder << m_queryEnd;
+ encoder << m_fragmentEnd;
+}
+
+template <class Decoder>
+bool URL::decode(Decoder& decoder, URL& url)
+{
+ if (!decoder.decode(url.m_string))
+ return false;
+ bool isValid;
+ if (!decoder.decode(isValid))
+ return false;
+ url.m_isValid = isValid;
+ if (!isValid)
+ return true;
+ bool protocolIsInHTTPFamily;
+ if (!decoder.decode(protocolIsInHTTPFamily))
+ return false;
+ url.m_protocolIsInHTTPFamily = protocolIsInHTTPFamily;
+ if (!decoder.decode(url.m_schemeEnd))
+ return false;
+ if (!decoder.decode(url.m_userStart))
+ return false;
+ if (!decoder.decode(url.m_userEnd))
+ return false;
+ if (!decoder.decode(url.m_passwordEnd))
+ return false;
+ if (!decoder.decode(url.m_hostEnd))
+ return false;
+ if (!decoder.decode(url.m_portEnd))
+ return false;
+ if (!decoder.decode(url.m_pathAfterLastSlash))
+ return false;
+ if (!decoder.decode(url.m_pathEnd))
+ return false;
+ if (!decoder.decode(url.m_queryEnd))
+ return false;
+ if (!decoder.decode(url.m_fragmentEnd))
+ return false;
+ return true;
+}
+
bool operator==(const URL&, const URL&);
bool operator==(const URL&, const String&);
bool operator==(const String&, const URL&);
Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (200908 => 200909)
--- trunk/Source/WebCore/platform/network/ResourceRequestBase.h 2016-05-14 02:17:31 UTC (rev 200908)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.h 2016-05-14 02:26:23 UTC (rev 200909)
@@ -257,7 +257,7 @@
{
ASSERT(!m_httpBody);
ASSERT(!m_platformRequestUpdated);
- encoder << m_url.string();
+ encoder << m_url;
encoder << m_timeoutInterval;
encoder << m_firstPartyForCookies.string();
encoder << m_httpMethod;
@@ -272,10 +272,8 @@
template<class Decoder>
bool ResourceRequestBase::decodeWithoutPlatformData(Decoder& decoder)
{
- String url;
- if (!decoder.decode(url))
+ if (!decoder.decode(m_url))
return false;
- m_url = URL(ParsedURLString, url);
if (!decoder.decode(m_timeoutInterval))
return false;
Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.h (200908 => 200909)
--- trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2016-05-14 02:17:31 UTC (rev 200908)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2016-05-14 02:26:23 UTC (rev 200909)
@@ -202,7 +202,7 @@
return;
lazyInit(AllFields);
- encoder << m_url.string();
+ encoder << m_url;
encoder << m_mimeType;
encoder << static_cast<int64_t>(m_expectedContentLength);
encoder << m_textEncodingName;
@@ -227,10 +227,8 @@
if (responseIsNull)
return true;
- String url;
- if (!decoder.decode(url))
+ if (!decoder.decode(response.m_url))
return false;
- response.m_url = URL(URL(), url);
if (!decoder.decode(response.m_mimeType))
return false;
int64_t expectedContentLength;
Modified: trunk/Source/WebKit2/ChangeLog (200908 => 200909)
--- trunk/Source/WebKit2/ChangeLog 2016-05-14 02:17:31 UTC (rev 200908)
+++ trunk/Source/WebKit2/ChangeLog 2016-05-14 02:26:23 UTC (rev 200909)
@@ -1,3 +1,23 @@
+2016-05-13 Chris Dumez <[email protected]>
+
+ [NetworkCache] Avoid having to re-parse URLs after deserializing them
+ https://bugs.webkit.org/show_bug.cgi?id=157660
+
+ Reviewed by Darin Adler.
+
+ * NetworkProcess/cache/NetworkCacheCoders.cpp:
+ (WebKit::NetworkCache::Coder<WebCore::CertificateInfo>::encode): Deleted.
+ (WebKit::NetworkCache::Coder<WebCore::CertificateInfo>::decode): Deleted.
+ * NetworkProcess/cache/NetworkCacheCoders.h:
+ Drop template specializations used by our network cache for encoding
+ / decoding URLs as Strings. This causes us to now rely on
+ URL::encode() / URL::decode() instead.
+
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<BlobPart>::decode):
+ Fix bug in BlobPart encoding / decoding. It was encoding the url member
+ as a URL but decoding it as a String.
+
2016-05-13 Dan Bernstein <[email protected]>
Try to fix some non-iOS builds.
Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.cpp (200908 => 200909)
--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.cpp 2016-05-14 02:17:31 UTC (rev 200908)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.cpp 2016-05-14 02:26:23 UTC (rev 200909)
@@ -145,20 +145,6 @@
return decodeStringText<UChar>(decoder, length, result);
}
-void Coder<WebCore::URL>::encode(Encoder& encoder, const WebCore::URL& url)
-{
- encoder << url.string();
-}
-
-bool Coder<WebCore::URL>::decode(Decoder& decoder, WebCore::URL& url)
-{
- String urlAsString;
- if (!decoder.decode(urlAsString))
- return false;
- url = "" urlAsString);
- return true;
-}
-
void Coder<WebCore::CertificateInfo>::encode(Encoder& encoder, const WebCore::CertificateInfo& certificateInfo)
{
// FIXME: Cocoa CertificateInfo is a CF object tree. Generalize CF type coding so we don't need to use ArgumentCoder here.
Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.h (200908 => 200909)
--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.h 2016-05-14 02:17:31 UTC (rev 200908)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.h 2016-05-14 02:26:23 UTC (rev 200909)
@@ -32,7 +32,6 @@
#include "NetworkCacheEncoder.h"
#include <WebCore/CertificateInfo.h>
#include <WebCore/HTTPHeaderMap.h>
-#include <WebCore/URL.h>
#include <utility>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
@@ -250,11 +249,6 @@
static bool decode(Decoder&, String&);
};
-template<> struct Coder<WebCore::URL> {
- static void encode(Encoder&, const WebCore::URL&);
- static bool decode(Decoder&, WebCore::URL&);
-};
-
template<> struct Coder<WebCore::CertificateInfo> {
static void encode(Encoder&, const WebCore::CertificateInfo&);
static bool decode(Decoder&, WebCore::CertificateInfo&);
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp (200908 => 200909)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2016-05-14 02:17:31 UTC (rev 200908)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2016-05-14 02:26:23 UTC (rev 200909)
@@ -1868,10 +1868,10 @@
break;
}
case BlobPart::Blob: {
- String url;
+ URL url;
if (!decoder.decode(url))
return false;
- blobPart = BlobPart(URL(URL(), url));
+ blobPart = BlobPart(url);
break;
}
default: