<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[200909] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/200909">200909</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-05-13 19:26:23 -0700 (Fri, 13 May 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[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.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformURLh">trunk/Source/WebCore/platform/URL.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkResourceRequestBaseh">trunk/Source/WebCore/platform/network/ResourceRequestBase.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkResourceResponseBaseh">trunk/Source/WebCore/platform/network/ResourceResponseBase.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheCoderscpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheCodersh">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.h</a></li>
<li><a href="#trunkSourceWebKit2SharedWebCoreArgumentCoderscpp">trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200908 => 200909)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-05-13 Chris Dumez <cdumez@apple.com>
+
+ [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):
+
</ins><span class="cx"> 2016-05-13 Sam Weinig <sam@webkit.org>
</span><span class="cx">
</span><span class="cx"> ScriptController::processingUserGesture should propagate across postMessage boundaries
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URL.h (200908 => 200909)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -195,6 +195,9 @@
</span><span class="cx">
</span><span class="cx"> bool isSafeToSendToAnotherThread() const;
</span><span class="cx">
</span><ins>+ template <class Encoder> void encode(Encoder&) const;
+ template <class Decoder> static bool decode(Decoder&, URL&);
+
</ins><span class="cx"> private:
</span><span class="cx"> WEBCORE_EXPORT void invalidate();
</span><span class="cx"> static bool protocolIs(const String&, const char*);
</span><span class="lines">@@ -225,6 +228,64 @@
</span><span class="cx"> int m_fragmentEnd;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+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;
+}
+
</ins><span class="cx"> bool operator==(const URL&, const URL&);
</span><span class="cx"> bool operator==(const URL&, const String&);
</span><span class="cx"> bool operator==(const String&, const URL&);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkResourceRequestBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (200908 => 200909)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -257,7 +257,7 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!m_httpBody);
</span><span class="cx"> ASSERT(!m_platformRequestUpdated);
</span><del>- encoder << m_url.string();
</del><ins>+ encoder << m_url;
</ins><span class="cx"> encoder << m_timeoutInterval;
</span><span class="cx"> encoder << m_firstPartyForCookies.string();
</span><span class="cx"> encoder << m_httpMethod;
</span><span class="lines">@@ -272,10 +272,8 @@
</span><span class="cx"> template<class Decoder>
</span><span class="cx"> bool ResourceRequestBase::decodeWithoutPlatformData(Decoder& decoder)
</span><span class="cx"> {
</span><del>- String url;
- if (!decoder.decode(url))
</del><ins>+ if (!decoder.decode(m_url))
</ins><span class="cx"> return false;
</span><del>- m_url = URL(ParsedURLString, url);
</del><span class="cx">
</span><span class="cx"> if (!decoder.decode(m_timeoutInterval))
</span><span class="cx"> return false;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkResourceResponseBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.h (200908 => 200909)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -202,7 +202,7 @@
</span><span class="cx"> return;
</span><span class="cx"> lazyInit(AllFields);
</span><span class="cx">
</span><del>- encoder << m_url.string();
</del><ins>+ encoder << m_url;
</ins><span class="cx"> encoder << m_mimeType;
</span><span class="cx"> encoder << static_cast<int64_t>(m_expectedContentLength);
</span><span class="cx"> encoder << m_textEncodingName;
</span><span class="lines">@@ -227,10 +227,8 @@
</span><span class="cx"> if (responseIsNull)
</span><span class="cx"> return true;
</span><span class="cx">
</span><del>- String url;
- if (!decoder.decode(url))
</del><ins>+ if (!decoder.decode(response.m_url))
</ins><span class="cx"> return false;
</span><del>- response.m_url = URL(URL(), url);
</del><span class="cx"> if (!decoder.decode(response.m_mimeType))
</span><span class="cx"> return false;
</span><span class="cx"> int64_t expectedContentLength;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (200908 => 200909)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-05-13 Chris Dumez <cdumez@apple.com>
+
+ [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.
+
</ins><span class="cx"> 2016-05-13 Dan Bernstein <mitz@apple.com>
</span><span class="cx">
</span><span class="cx"> Try to fix some non-iOS builds.
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheCoderscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.cpp (200908 => 200909)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -145,20 +145,6 @@
</span><span class="cx"> return decodeStringText<UChar>(decoder, length, result);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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 = WebCore::URL(WebCore::ParsedURLString, urlAsString);
- return true;
-}
-
</del><span class="cx"> void Coder<WebCore::CertificateInfo>::encode(Encoder& encoder, const WebCore::CertificateInfo& certificateInfo)
</span><span class="cx"> {
</span><span class="cx"> // FIXME: Cocoa CertificateInfo is a CF object tree. Generalize CF type coding so we don't need to use ArgumentCoder here.
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheCodersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.h (200908 => 200909)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -32,7 +32,6 @@
</span><span class="cx"> #include "NetworkCacheEncoder.h"
</span><span class="cx"> #include <WebCore/CertificateInfo.h>
</span><span class="cx"> #include <WebCore/HTTPHeaderMap.h>
</span><del>-#include <WebCore/URL.h>
</del><span class="cx"> #include <utility>
</span><span class="cx"> #include <wtf/Forward.h>
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="lines">@@ -250,11 +249,6 @@
</span><span class="cx"> static bool decode(Decoder&, String&);
</span><span class="cx"> };
</span><span class="cx">
</span><del>-template<> struct Coder<WebCore::URL> {
- static void encode(Encoder&, const WebCore::URL&);
- static bool decode(Decoder&, WebCore::URL&);
-};
-
</del><span class="cx"> template<> struct Coder<WebCore::CertificateInfo> {
</span><span class="cx"> static void encode(Encoder&, const WebCore::CertificateInfo&);
</span><span class="cx"> static bool decode(Decoder&, WebCore::CertificateInfo&);
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebCoreArgumentCoderscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp (200908 => 200909)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1868,10 +1868,10 @@
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case BlobPart::Blob: {
</span><del>- String url;
</del><ins>+ URL url;
</ins><span class="cx"> if (!decoder.decode(url))
</span><span class="cx"> return false;
</span><del>- blobPart = BlobPart(URL(URL(), url));
</del><ins>+ blobPart = BlobPart(url);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> default:
</span></span></pre>
</div>
</div>
</body>
</html>