<!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>[201967] trunk</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/201967">201967</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-06-11 04:09:54 -0700 (Sat, 11 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Vary:Cookie validation doesn't work in private browsing
https://bugs.webkit.org/show_bug.cgi?id=158616
Source/WebCore:

rdar://problem/26755067

Reviewed by Darin Adler.

This wasn't implemented because there was no way to get NetworkStorageSession from
a SessionID on WebCore side.

The patch adds a simple WebCore level weak map that allows getting NetworkStorageSessions
from SessionID. This seemed like the cleanest way to do this without a big refactoring
around the currently WebKit2 level SessionTracker.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/network/CacheValidation.cpp:
(WebCore::headerValueForVary):

    Get NetworkStorageSession from SessionID for cookies

(WebCore::verifyVaryingRequestHeaders):
* platform/network/NetworkStorageSession.cpp: Added.

    Add platform independent .cpp for NetworkStorageSession.
    Implement a weak map for SessionID -&gt; NetworkStorageSession.

(WebCore::sessionsMap):
(WebCore::NetworkStorageSession::NetworkStorageSession):
(WebCore::NetworkStorageSession::~NetworkStorageSession):
(WebCore::NetworkStorageSession::forSessionID):

    Get NetworkStorageSession for sessionID.

* platform/network/NetworkStorageSession.h:
(WebCore::NetworkStorageSession::sessionID):
(WebCore::NetworkStorageSession::credentialStorage):
* platform/network/cf/NetworkStorageSessionCFNet.cpp:
(WebCore::NetworkStorageSession::NetworkStorageSession):

    Call to common constructor.

(WebCore::defaultNetworkStorageSession):
* platform/network/soup/NetworkStorageSessionSoup.cpp:
(WebCore::NetworkStorageSession::NetworkStorageSession):

    Call to common constructor.

(WebCore::defaultSession):
(WebCore::NetworkStorageSession::~NetworkStorageSession): Deleted.

LayoutTests:


Reviewed by Darin Adler.

* http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt:
* http/tests/cache/disk-cache/disk-cache-vary-cookie.html:

Exapand the existing test to cover memory cache and private browsing.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachediskcachevarycookieexpectedtxt">trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachediskcachevarycookiehtml">trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkCacheValidationcpp">trunk/Source/WebCore/platform/network/CacheValidation.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkNetworkStorageSessionh">trunk/Source/WebCore/platform/network/NetworkStorageSession.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcfNetworkStorageSessionCFNetcpp">trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworksoupNetworkStorageSessionSoupcpp">trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformnetworkNetworkStorageSessioncpp">trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (201966 => 201967)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-11 06:01:48 UTC (rev 201966)
+++ trunk/LayoutTests/ChangeLog        2016-06-11 11:09:54 UTC (rev 201967)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-06-10  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Vary:Cookie validation doesn't work in private browsing
+        https://bugs.webkit.org/show_bug.cgi?id=158616
+
+        Reviewed by Darin Adler.
+
+        * http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt:
+        * http/tests/cache/disk-cache/disk-cache-vary-cookie.html:
+
+        Exapand the existing test to cover memory cache and private browsing.
+
</ins><span class="cx"> 2016-06-10  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add support for passive event listeners on touch events
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachediskcachevarycookieexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt (201966 => 201967)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt        2016-06-11 06:01:48 UTC (rev 201966)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie-expected.txt        2016-06-11 11:09:54 UTC (rev 201967)
</span><span class="lines">@@ -1,8 +1,9 @@
</span><del>-Test that Vary: Cookie in response is handled by the disk cache.
</del><ins>+Test that Vary: Cookie in response is handled by caches.
</ins><span class="cx"> 
</span><span class="cx"> On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+Testing disk cache
</ins><span class="cx"> Setting cookie and loading
</span><span class="cx"> response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
</span><span class="cx"> response source: Network
</span><span class="lines">@@ -31,6 +32,64 @@
</span><span class="cx"> response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
</span><span class="cx"> response source: Disk cache
</span><span class="cx"> 
</span><ins>+Testing memory cache
+Setting cookie and loading
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+Loading again
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+Changing cookie and loading
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+Loading again
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+Testing memory cache in private browsing
+Setting cookie and loading
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+Loading again
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+Changing cookie and loading
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Network
+
+Loading again
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
+response headers: {&quot;Vary&quot;:&quot;Cookie&quot;,&quot;Cache-control&quot;:&quot;max-age=100&quot;}
+response source: Memory cache
+
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachediskcachevarycookiehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html (201966 => 201967)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html        2016-06-11 06:01:48 UTC (rev 201966)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-vary-cookie.html        2016-06-11 11:09:54 UTC (rev 201967)
</span><span class="lines">@@ -3,32 +3,48 @@
</span><span class="cx"> &lt;body&gt;
</span><span class="cx"> &lt;script&gt;
</span><span class="cx"> 
</span><del>-var tests =
-[
-  { responseHeaders: {'Cache-control': 'max-age=100'} },
-  { responseHeaders: {'Vary': 'Cookie', 'Cache-control': 'max-age=100'} },
-];
</del><span class="cx"> 
</span><del>-description(&quot;Test that Vary: Cookie in response is handled by the disk cache.&quot;);
</del><ins>+description(&quot;Test that Vary: Cookie in response is handled by caches.&quot;);
</ins><span class="cx"> 
</span><del>-debug(&quot;Setting cookie and loading&quot;);
-document.cookie = &quot;cookie=value&quot;;
-loadResources(tests, function () {
-    printResults(tests);
-    debug(&quot;Loading again&quot;);
-    loadResources(tests, function () {
</del><ins>+function testCookies(testDiskCache, completionHandler)
+{
+    var tests = [
+      { responseHeaders: {'Cache-control': 'max-age=100'} },
+      { responseHeaders: {'Vary': 'Cookie', 'Cache-control': 'max-age=100'} },
+    ];
+
+    var options = { &quot;ClearMemoryCache&quot; : testDiskCache };
+    debug(&quot;Setting cookie and loading&quot;);
+    document.cookie = &quot;cookie=&quot; + Math.floor((Math.random() * 1000000000000));
+    loadResourcesWithOptions(tests, options, function () {
</ins><span class="cx">         printResults(tests);
</span><del>-        debug(&quot;Changing cookie and loading&quot;);
-        document.cookie = &quot;cookie=othervalue&quot;;
-        loadResources(tests, function () {
</del><ins>+        debug(&quot;Loading again&quot;);
+        loadResourcesWithOptions(tests, options, function () {
</ins><span class="cx">             printResults(tests);
</span><del>-            debug(&quot;Loading again&quot;);
-            loadResources(tests, function () {
-               printResults(tests);
-               finishJSTest();
</del><ins>+            debug(&quot;Changing cookie and loading&quot;);
+            document.cookie = &quot;cookie&quot; + Math.floor((Math.random() * 1000000000000));
+            loadResourcesWithOptions(tests, options, function () {
+                printResults(tests);
+                debug(&quot;Loading again&quot;);
+                loadResourcesWithOptions(tests, options, function () {
+                   printResults(tests);
+                   completionHandler();
+                });
</ins><span class="cx">             });
</span><span class="cx">         });
</span><span class="cx">     });
</span><ins>+}
+
+debug(&quot;Testing disk cache&quot;);
+testCookies(true, function () {
+    debug(&quot;Testing memory cache&quot;);
+    testCookies(false, function () {
+        debug(&quot;Testing memory cache in private browsing&quot;);
+        testRunner.setPrivateBrowsingEnabled(true);
+        testCookies(false, function () {
+            finishJSTest();
+        });
+    });
</ins><span class="cx"> });
</span><span class="cx"> 
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (201966 => 201967)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-06-11 06:01:48 UTC (rev 201966)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-06-11 11:09:54 UTC (rev 201967)
</span><span class="lines">@@ -2338,6 +2338,7 @@
</span><span class="cx">     platform/network/HTTPParsers.cpp
</span><span class="cx">     platform/network/MIMEHeader.cpp
</span><span class="cx">     platform/network/NetworkStateNotifier.cpp
</span><ins>+    platform/network/NetworkStorageSession.cpp
</ins><span class="cx">     platform/network/ParsedContentRange.cpp
</span><span class="cx">     platform/network/ParsedContentType.cpp
</span><span class="cx">     platform/network/ProtectionSpaceBase.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (201966 => 201967)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-11 06:01:48 UTC (rev 201966)
+++ trunk/Source/WebCore/ChangeLog        2016-06-11 11:09:54 UTC (rev 201967)
</span><span class="lines">@@ -1,3 +1,55 @@
</span><ins>+2016-06-10  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Vary:Cookie validation doesn't work in private browsing
+        https://bugs.webkit.org/show_bug.cgi?id=158616
+        rdar://problem/26755067
+
+        Reviewed by Darin Adler.
+
+        This wasn't implemented because there was no way to get NetworkStorageSession from
+        a SessionID on WebCore side.
+
+        The patch adds a simple WebCore level weak map that allows getting NetworkStorageSessions
+        from SessionID. This seemed like the cleanest way to do this without a big refactoring
+        around the currently WebKit2 level SessionTracker.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/network/CacheValidation.cpp:
+        (WebCore::headerValueForVary):
+
+            Get NetworkStorageSession from SessionID for cookies
+
+        (WebCore::verifyVaryingRequestHeaders):
+        * platform/network/NetworkStorageSession.cpp: Added.
+
+            Add platform independent .cpp for NetworkStorageSession.
+            Implement a weak map for SessionID -&gt; NetworkStorageSession.
+
+        (WebCore::sessionsMap):
+        (WebCore::NetworkStorageSession::NetworkStorageSession):
+        (WebCore::NetworkStorageSession::~NetworkStorageSession):
+        (WebCore::NetworkStorageSession::forSessionID):
+
+            Get NetworkStorageSession for sessionID.
+
+        * platform/network/NetworkStorageSession.h:
+        (WebCore::NetworkStorageSession::sessionID):
+        (WebCore::NetworkStorageSession::credentialStorage):
+        * platform/network/cf/NetworkStorageSessionCFNet.cpp:
+        (WebCore::NetworkStorageSession::NetworkStorageSession):
+
+            Call to common constructor.
+
+        (WebCore::defaultNetworkStorageSession):
+        * platform/network/soup/NetworkStorageSessionSoup.cpp:
+        (WebCore::NetworkStorageSession::NetworkStorageSession):
+
+            Call to common constructor.
+
+        (WebCore::defaultSession):
+        (WebCore::NetworkStorageSession::~NetworkStorageSession): Deleted.
+
</ins><span class="cx"> 2016-06-10  Ada Chan  &lt;adachan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Use the video element's video box when getting the inline video rect in WebVideoFullscreenManager
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (201966 => 201967)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-11 06:01:48 UTC (rev 201966)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-11 11:09:54 UTC (rev 201967)
</span><span class="lines">@@ -6733,6 +6733,7 @@
</span><span class="cx">                 E4E9B11D1814569C003ACCDF /* SimpleLineLayoutFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */; };
</span><span class="cx">                 E4F9EEF2156D9FFA00D23E7E /* StyleSheetContents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */; };
</span><span class="cx">                 E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                E4FD02041D0AF2C100D8E57E /* NetworkStorageSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4FD02031D0AF2C100D8E57E /* NetworkStorageSession.cpp */; };
</ins><span class="cx">                 E51A81DF17298D7700BFCA61 /* JSPerformance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E51A81DE17298D7700BFCA61 /* JSPerformance.cpp */; };
</span><span class="cx">                 E526AF3F1727F8F200E41781 /* Performance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E526AF3E1727F8F200E41781 /* Performance.cpp */; };
</span><span class="cx">                 E55F497A151B888000BB67DB /* LengthFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E55F4979151B888000BB67DB /* LengthFunctions.cpp */; };
</span><span class="lines">@@ -14818,6 +14819,7 @@
</span><span class="cx">                 E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutFunctions.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleSheetContents.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleSheetContents.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                E4FD02031D0AF2C100D8E57E /* NetworkStorageSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkStorageSession.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 E51A81DE17298D7700BFCA61 /* JSPerformance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPerformance.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E526AF3E1727F8F200E41781 /* Performance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Performance.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E55F4979151B888000BB67DB /* LengthFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LengthFunctions.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -17806,6 +17808,7 @@
</span><span class="cx">                                 628D214B12131ED10055DCFC /* NetworkingContext.h */,
</span><span class="cx">                                 1A7FA61A0DDA3BBE0028F8A5 /* NetworkStateNotifier.cpp */,
</span><span class="cx">                                 1A7FA6180DDA3B3A0028F8A5 /* NetworkStateNotifier.h */,
</span><ins>+                                E4FD02031D0AF2C100D8E57E /* NetworkStorageSession.cpp */,
</ins><span class="cx">                                 E13EF3421684ECF40034C83F /* NetworkStorageSession.h */,
</span><span class="cx">                                 CDCD41E51C3DDB0900965D99 /* ParsedContentRange.cpp */,
</span><span class="cx">                                 CDCD41E61C3DDB0900965D99 /* ParsedContentRange.h */,
</span><span class="lines">@@ -32190,6 +32193,7 @@
</span><span class="cx">                                 A55639D21C6F09E700806D8E /* WorkerConsoleClient.cpp in Sources */,
</span><span class="cx">                                 A3E2643014748991005A8588 /* WorkerEventQueue.cpp in Sources */,
</span><span class="cx">                                 2E4346480F546A8200B0F1BA /* WorkerGlobalScope.cpp in Sources */,
</span><ins>+                                E4FD02041D0AF2C100D8E57E /* NetworkStorageSession.cpp in Sources */,
</ins><span class="cx">                                 418C395A1C8DD6990051C8A3 /* WorkerGlobalScopeFetch.cpp in Sources */,
</span><span class="cx">                                 5185FCB31BB4C4E80012898F /* WorkerGlobalScopeIndexedDatabase.cpp in Sources */,
</span><span class="cx">                                 97F8E665151D4A4B00D2D181 /* WorkerGlobalScopeNotifications.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkCacheValidationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/CacheValidation.cpp (201966 => 201967)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/CacheValidation.cpp        2016-06-11 06:01:48 UTC (rev 201966)
+++ trunk/Source/WebCore/platform/network/CacheValidation.cpp        2016-06-11 11:09:54 UTC (rev 201967)
</span><span class="lines">@@ -338,11 +338,7 @@
</span><span class="cx">     // We could fetch the cookie when making the request but that seems overkill as the case is very rare and it
</span><span class="cx">     // is a blocking operation. This should be sufficient to cover reasonable cases.
</span><span class="cx">     if (headerName == httpHeaderNameString(HTTPHeaderName::Cookie)) {
</span><del>-        if (sessionID != SessionID::defaultSessionID()) {
-            // FIXME: Don't know how to get the cookie. There should be a global way to get NetworkStorageSession from sessionID.
-            return &quot;&quot;;
-        }
-        auto&amp; session = NetworkStorageSession::defaultStorageSession();
</del><ins>+        auto&amp; session = NetworkStorageSession::forSessionID(sessionID);
</ins><span class="cx">         auto* cookieStrategy = platformStrategies() ? platformStrategies()-&gt;cookiesStrategy() : nullptr;
</span><span class="cx">         if (!cookieStrategy)
</span><span class="cx">             return cookieRequestHeaderFieldValue(session, request.firstPartyForCookies(), request.url());
</span><span class="lines">@@ -374,10 +370,6 @@
</span><span class="cx">         // FIXME: Vary: * in response would ideally trigger a cache delete instead of a store.
</span><span class="cx">         if (varyingRequestHeader.first == &quot;*&quot;)
</span><span class="cx">             return false;
</span><del>-        if (sessionID != SessionID::defaultSessionID() &amp;&amp; varyingRequestHeader.first == httpHeaderNameString(HTTPHeaderName::Cookie)) {
-            // FIXME: See the comment in headerValueForVary.
-            return false;
-        }
</del><span class="cx">         String headerValue = headerValueForVary(request, varyingRequestHeader.first, sessionID);
</span><span class="cx">         if (headerValue != varyingRequestHeader.second)
</span><span class="cx">             return false;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkNetworkStorageSessioncpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp (0 => 201967)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp        2016-06-11 11:09:54 UTC (rev 201967)
</span><span class="lines">@@ -0,0 +1,90 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;NetworkStorageSession.h&quot;
+
+#include &lt;wtf/HashMap.h&gt;
+#include &lt;wtf/MainThread.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
+
+#if USE(SOUP)
+#include &quot;SoupNetworkSession.h&quot;
+#endif
+
+namespace WebCore {
+
+static std::unique_ptr&lt;NetworkStorageSession&gt;&amp; defaultSession()
+{
+    ASSERT(isMainThread());
+    static NeverDestroyed&lt;std::unique_ptr&lt;NetworkStorageSession&gt;&gt; session;
+    return session;
+}
+
+static HashMap&lt;SessionID, NetworkStorageSession*&gt;&amp; sessionsMap()
+{
+    static NeverDestroyed&lt;HashMap&lt;SessionID, NetworkStorageSession*&gt;&gt; map;
+    return map;
+}
+
+NetworkStorageSession::NetworkStorageSession(SessionID sessionID)
+    : m_sessionID(sessionID)
+{
+    if (sessionID == SessionID::defaultSessionID())
+        return;
+    ASSERT(!sessionsMap().contains(sessionID));
+    sessionsMap().add(sessionID, this);
+}
+
+NetworkStorageSession&amp; NetworkStorageSession::defaultStorageSession()
+{
+    if (!defaultSession())
+        defaultSession() = std::make_unique&lt;NetworkStorageSession&gt;(SessionID::defaultSessionID(), nullptr);
+    return *defaultSession();
+}
+
+NetworkStorageSession::~NetworkStorageSession()
+{
+    if (m_sessionID == SessionID::defaultSessionID())
+        return;
+    ASSERT(sessionsMap().contains(m_sessionID));
+    sessionsMap().remove(m_sessionID);
+}
+
+NetworkStorageSession&amp; NetworkStorageSession::forSessionID(SessionID sessionID)
+{
+    if (sessionID == SessionID::defaultSessionID())
+        return defaultStorageSession();
+
+    ASSERT(sessionsMap().contains(sessionID));
+    return *sessionsMap().get(sessionID);
+}
+
+void NetworkStorageSession::replaceDefaultSession(std::unique_ptr&lt;NetworkStorageSession&gt; newDefaultSession)
+{
+    defaultSession() = WTFMove(newDefaultSession);
+}
+
+};
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkNetworkStorageSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (201966 => 201967)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h        2016-06-11 06:01:48 UTC (rev 201966)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h        2016-06-11 11:09:54 UTC (rev 201967)
</span><span class="lines">@@ -37,7 +37,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class NetworkingContext;
</del><span class="cx"> class ResourceRequest;
</span><span class="cx"> class SoupNetworkSession;
</span><span class="cx"> 
</span><span class="lines">@@ -49,37 +48,37 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT static void switchToNewTestingSession();
</span><span class="cx"> 
</span><ins>+    static NetworkStorageSession&amp; forSessionID(SessionID);
+
+    WEBCORE_EXPORT ~NetworkStorageSession();
+
</ins><span class="cx">     SessionID sessionID() const { return m_sessionID; }
</span><span class="cx">     CredentialStorage&amp; credentialStorage() { return m_credentialStorage; }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA) || USE(CFNETWORK)
</span><del>-    NetworkStorageSession(SessionID, RetainPtr&lt;CFURLStorageSessionRef&gt;);
</del><ins>+    NetworkStorageSession(SessionID, RetainPtr&lt;CFURLStorageSessionRef&gt;&amp;&amp;);
</ins><span class="cx"> 
</span><span class="cx">     // May be null, in which case a Foundation default should be used.
</span><span class="cx">     CFURLStorageSessionRef platformSession() { return m_platformSession.get(); }
</span><span class="cx">     WEBCORE_EXPORT RetainPtr&lt;CFHTTPCookieStorageRef&gt; cookieStorage() const;
</span><span class="cx"> #elif USE(SOUP)
</span><span class="cx">     NetworkStorageSession(SessionID, std::unique_ptr&lt;SoupNetworkSession&gt;);
</span><del>-    ~NetworkStorageSession();
</del><span class="cx"> 
</span><span class="cx">     SoupNetworkSession&amp; soupNetworkSession() const;
</span><span class="cx">     void setSoupNetworkSession(std::unique_ptr&lt;SoupNetworkSession&gt;);
</span><del>-#else
-    NetworkStorageSession(SessionID, NetworkingContext*);
-    ~NetworkStorageSession();
-
-    NetworkingContext* context() const;
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    explicit NetworkStorageSession(SessionID);
+
+    static void replaceDefaultSession(std::unique_ptr&lt;NetworkStorageSession&gt;);
+
</ins><span class="cx">     SessionID m_sessionID;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA) || USE(CFNETWORK)
</span><span class="cx">     RetainPtr&lt;CFURLStorageSessionRef&gt; m_platformSession;
</span><span class="cx"> #elif USE(SOUP)
</span><span class="cx">     std::unique_ptr&lt;SoupNetworkSession&gt; m_session;
</span><del>-#else
-    RefPtr&lt;NetworkingContext&gt; m_context;
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     CredentialStorage m_credentialStorage;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcfNetworkStorageSessionCFNetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp (201966 => 201967)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp        2016-06-11 06:01:48 UTC (rev 201966)
+++ trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp        2016-06-11 11:09:54 UTC (rev 201967)
</span><span class="lines">@@ -41,37 +41,23 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-NetworkStorageSession::NetworkStorageSession(SessionID sessionID, RetainPtr&lt;CFURLStorageSessionRef&gt; platformSession)
-    : m_sessionID(sessionID)
-    , m_platformSession(platformSession)
</del><ins>+NetworkStorageSession::NetworkStorageSession(SessionID sessionID, RetainPtr&lt;CFURLStorageSessionRef&gt;&amp;&amp; platformSession)
+    : NetworkStorageSession(sessionID)
</ins><span class="cx"> {
</span><ins>+    m_platformSession = WTFMove(platformSession);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static std::unique_ptr&lt;NetworkStorageSession&gt;&amp; defaultNetworkStorageSession()
-{
-    ASSERT(isMainThread());
-    static NeverDestroyed&lt;std::unique_ptr&lt;NetworkStorageSession&gt;&gt; session;
-    return session;
-}
-
</del><span class="cx"> void NetworkStorageSession::switchToNewTestingSession()
</span><span class="cx"> {
</span><span class="cx">     // Session name should be short enough for shared memory region name to be under the limit, otehrwise sandbox rules won't work (see &lt;rdar://problem/13642852&gt;).
</span><span class="cx">     String sessionName = String::format(&quot;WebKit Test-%u&quot;, static_cast&lt;uint32_t&gt;(getCurrentProcessID()));
</span><span class="cx"> #if PLATFORM(COCOA)
</span><del>-    defaultNetworkStorageSession() = std::make_unique&lt;NetworkStorageSession&gt;(SessionID::defaultSessionID(), adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get())));
</del><ins>+    replaceDefaultSession(std::make_unique&lt;NetworkStorageSession&gt;(SessionID::defaultSessionID(), adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get()))));
</ins><span class="cx"> #else
</span><del>-    defaultNetworkStorageSession() = std::make_unique&lt;NetworkStorageSession&gt;(SessionID::defaultSessionID(), adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get(), defaultNetworkStorageSession()-&gt;platformSession())));
</del><ins>+    replaceDefaultSession(std::make_unique&lt;NetworkStorageSession&gt;(SessionID::defaultSessionID(), adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get(), defaultNetworkStorageSession()-&gt;platformSession()))));
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-NetworkStorageSession&amp; NetworkStorageSession::defaultStorageSession()
-{
-    if (!defaultNetworkStorageSession())
-        defaultNetworkStorageSession() = std::make_unique&lt;NetworkStorageSession&gt;(SessionID::defaultSessionID(), nullptr);
-    return *defaultNetworkStorageSession();
-}
-
</del><span class="cx"> std::unique_ptr&lt;NetworkStorageSession&gt; NetworkStorageSession::createPrivateBrowsingSession(SessionID sessionID, const String&amp; identifierBase)
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;CFStringRef&gt; cfIdentifier = String(identifierBase + &quot;.PrivateBrowsing&quot;).createCFString();
</span><span class="lines">@@ -79,7 +65,7 @@
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     auto session = std::make_unique&lt;NetworkStorageSession&gt;(sessionID, adoptCF(wkCreatePrivateStorageSession(cfIdentifier.get())));
</span><span class="cx"> #else
</span><del>-    auto session = std::make_unique&lt;NetworkStorageSession&gt;(sessionID, adoptCF(wkCreatePrivateStorageSession(cfIdentifier.get(), defaultNetworkStorageSession()-&gt;platformSession())));
</del><ins>+    auto session = std::make_unique&lt;NetworkStorageSession&gt;(sessionID, adoptCF(wkCreatePrivateStorageSession(cfIdentifier.get(), defaultStorageSession().platformSession())));
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     return session;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworksoupNetworkStorageSessionSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp (201966 => 201967)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp        2016-06-11 06:01:48 UTC (rev 201966)
+++ trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp        2016-06-11 11:09:54 UTC (rev 201967)
</span><span class="lines">@@ -37,29 +37,11 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> NetworkStorageSession::NetworkStorageSession(SessionID sessionID, std::unique_ptr&lt;SoupNetworkSession&gt; session)
</span><del>-    : m_sessionID(sessionID)
-    , m_session(WTFMove(session))
</del><ins>+    : NetworkStorageSession(sessionID)
</ins><span class="cx"> {
</span><ins>+    m_session = WTFMove(session);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-NetworkStorageSession::~NetworkStorageSession()
-{
-}
-
-static std::unique_ptr&lt;NetworkStorageSession&gt;&amp; defaultSession()
-{
-    ASSERT(isMainThread());
-    static NeverDestroyed&lt;std::unique_ptr&lt;NetworkStorageSession&gt;&gt; session;
-    return session;
-}
-
-NetworkStorageSession&amp; NetworkStorageSession::defaultStorageSession()
-{
-    if (!defaultSession())
-        defaultSession() = std::make_unique&lt;NetworkStorageSession&gt;(SessionID::defaultSessionID(), nullptr);
-    return *defaultSession();
-}
-
</del><span class="cx"> std::unique_ptr&lt;NetworkStorageSession&gt; NetworkStorageSession::createPrivateBrowsingSession(SessionID sessionID, const String&amp;)
</span><span class="cx"> {
</span><span class="cx">     auto session = std::make_unique&lt;NetworkStorageSession&gt;(sessionID, SoupNetworkSession::createPrivateBrowsingSession());
</span><span class="lines">@@ -68,7 +50,7 @@
</span><span class="cx"> 
</span><span class="cx"> void NetworkStorageSession::switchToNewTestingSession()
</span><span class="cx"> {
</span><del>-    defaultSession() = std::make_unique&lt;NetworkStorageSession&gt;(SessionID::defaultSessionID(), SoupNetworkSession::createTestingSession());
</del><ins>+    replaceDefaultSession(std::make_unique&lt;NetworkStorageSession&gt;(SessionID::defaultSessionID(), SoupNetworkSession::createTestingSession()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> SoupNetworkSession&amp; NetworkStorageSession::soupNetworkSession() const
</span></span></pre>
</div>
</div>

</body>
</html>