<!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>[214127] 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/214127">214127</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2017-03-17 16:23:39 -0700 (Fri, 17 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make HTTPCookieStorage operate in the UIProcess in absence of a WebProcessPool.
&lt;rdar://problem/31102330&gt; and https://bugs.webkit.org/show_bug.cgi?id=169797

Reviewed by Alex Christensen.

Source/WebCore:

No new tests (No behavior change).

* platform/network/NetworkStorageSession.h:
* platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::NetworkStorageSession::flushCookieStore):

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

Source/WebKit2:

* UIProcess/API/APIHTTPCookieStore.cpp:
(API::HTTPCookieStore::~HTTPCookieStore):
(API::HTTPCookieStore::cookies):
(API::HTTPCookieStore::setCookie):
(API::HTTPCookieStore::deleteCookie):
(API::HTTPCookieStore::registerObserver):
(API::HTTPCookieStore::unregisterObserver):
(API::HTTPCookieStore::cookieManagerDestroyed):
(API::HTTPCookieStore::registerForNewProcessPoolNotifications):
* UIProcess/API/APIHTTPCookieStore.h:

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::create):
(WebKit::WebProcessPool::notifyThisWebProcessPoolWasCreated):
(WebKit::m_hiddenPageThrottlingTimer):
* UIProcess/WebProcessPool.h:

* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::processPoolForCookieStorageOperations):
(WebKit::WebsiteDataStore::processPoolForCookieStorageNotifications): Deleted.
* UIProcess/WebsiteData/WebsiteDataStore.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkNetworkStorageSessionh">trunk/Source/WebCore/platform/network/NetworkStorageSession.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcocoaNetworkStorageSessionCocoamm">trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworksoupNetworkStorageSessionSoupcpp">trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIHTTPCookieStorecpp">trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStore.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIHTTPCookieStoreh">trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStore.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessPoolcpp">trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessPoolh">trunk/Source/WebKit2/UIProcess/WebProcessPool.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp">trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh">trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (214126 => 214127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-17 21:59:33 UTC (rev 214126)
+++ trunk/Source/WebCore/ChangeLog        2017-03-17 23:23:39 UTC (rev 214127)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2017-03-17  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Make HTTPCookieStorage operate in the UIProcess in absence of a WebProcessPool.
+        &lt;rdar://problem/31102330&gt; and https://bugs.webkit.org/show_bug.cgi?id=169797
+
+        Reviewed by Alex Christensen.
+
+        No new tests (No behavior change).
+
+        * platform/network/NetworkStorageSession.h:
+        * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
+        (WebCore::NetworkStorageSession::flushCookieStore):
+
+        * platform/network/soup/NetworkStorageSessionSoup.cpp:
+        (WebCore::NetworkStorageSession::flushCookieStore):
+
</ins><span class="cx"> 2017-03-17  Dave Hyatt  &lt;hyatt@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Disable per-region boxes for multicolumn
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkNetworkStorageSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (214126 => 214127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h        2017-03-17 21:59:33 UTC (rev 214126)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h        2017-03-17 23:23:39 UTC (rev 214127)
</span><span class="lines">@@ -105,6 +105,7 @@
</span><span class="cx">     WEBCORE_EXPORT void deleteCookie(const Cookie&amp;);
</span><span class="cx">     WEBCORE_EXPORT Vector&lt;Cookie&gt; getAllCookies();
</span><span class="cx">     WEBCORE_EXPORT Vector&lt;Cookie&gt; getCookies(const URL&amp;);
</span><ins>+    WEBCORE_EXPORT void flushCookieStore();
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     static HashMap&lt;SessionID, std::unique_ptr&lt;NetworkStorageSession&gt;&gt;&amp; globalSessionMap();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcocoaNetworkStorageSessionCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm (214126 => 214127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm        2017-03-17 21:59:33 UTC (rev 214126)
+++ trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm        2017-03-17 23:23:39 UTC (rev 214127)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> #import &quot;NetworkStorageSession.h&quot;
</span><span class="cx"> 
</span><ins>+#import &quot;CFNetworkSPI.h&quot;
</ins><span class="cx"> #import &quot;Cookie.h&quot;
</span><span class="cx"> #import &quot;URL.h&quot;
</span><span class="cx"> #import &lt;wtf/BlockObjCExceptions.h&gt;
</span><span class="lines">@@ -75,6 +76,11 @@
</span><span class="cx">     return nsCookiesToCookieVector([nsCookieStorage() cookiesForURL:(NSURL *)url]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkStorageSession::flushCookieStore()
+{
+    [nsCookieStorage() _saveCookies];
+}
+
</ins><span class="cx"> NSHTTPCookieStorage *NetworkStorageSession::nsCookieStorage() const
</span><span class="cx"> {
</span><span class="cx">     auto cfCookieStorage = cookieStorage();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworksoupNetworkStorageSessionSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp (214126 => 214127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp        2017-03-17 21:59:33 UTC (rev 214126)
+++ trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp        2017-03-17 23:23:39 UTC (rev 214127)
</span><span class="lines">@@ -326,6 +326,11 @@
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkStorageSession::flushCookieStore()
+{
+    // FIXME: Implement for WK2 to use.
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // USE(SOUP)
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (214126 => 214127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-03-17 21:59:33 UTC (rev 214126)
+++ trunk/Source/WebKit2/ChangeLog        2017-03-17 23:23:39 UTC (rev 214127)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2017-03-17  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Make HTTPCookieStorage operate in the UIProcess in absence of a WebProcessPool.
+        &lt;rdar://problem/31102330&gt; and https://bugs.webkit.org/show_bug.cgi?id=169797
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/API/APIHTTPCookieStore.cpp:
+        (API::HTTPCookieStore::~HTTPCookieStore):
+        (API::HTTPCookieStore::cookies):
+        (API::HTTPCookieStore::setCookie):
+        (API::HTTPCookieStore::deleteCookie):
+        (API::HTTPCookieStore::registerObserver):
+        (API::HTTPCookieStore::unregisterObserver):
+        (API::HTTPCookieStore::cookieManagerDestroyed):
+        (API::HTTPCookieStore::registerForNewProcessPoolNotifications):
+        * UIProcess/API/APIHTTPCookieStore.h:
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::create):
+        (WebKit::WebProcessPool::notifyThisWebProcessPoolWasCreated):
+        (WebKit::m_hiddenPageThrottlingTimer):
+        * UIProcess/WebProcessPool.h:
+
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::processPoolForCookieStorageOperations):
+        (WebKit::WebsiteDataStore::processPoolForCookieStorageNotifications): Deleted.
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+
</ins><span class="cx"> 2017-03-17  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WK2] Disable background tab responsiveness detection on iOS
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIHTTPCookieStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStore.cpp (214126 => 214127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStore.cpp        2017-03-17 21:59:33 UTC (rev 214126)
+++ trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStore.cpp        2017-03-17 23:23:39 UTC (rev 214127)
</span><span class="lines">@@ -30,6 +30,8 @@
</span><span class="cx"> #include &quot;WebCookieManagerProxy.h&quot;
</span><span class="cx"> #include &quot;WebProcessPool.h&quot;
</span><span class="cx"> #include &lt;WebCore/Cookie.h&gt;
</span><ins>+#include &lt;WebCore/CookieStorage.h&gt;
+#include &lt;WebCore/NetworkStorageSession.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> using namespace WebKit;
</span><span class="cx"> 
</span><span class="lines">@@ -45,6 +47,7 @@
</span><span class="cx">     ASSERT(m_observers.isEmpty());
</span><span class="cx">     ASSERT(!m_observedCookieManagerProxy);
</span><span class="cx">     ASSERT(!m_cookieManagerProxyObserver);
</span><ins>+    ASSERT(!m_observingUIProcessCookies);
</ins><span class="cx"> 
</span><span class="cx">     unregisterForNewProcessPoolNotifications();
</span><span class="cx"> }
</span><span class="lines">@@ -52,9 +55,19 @@
</span><span class="cx"> void HTTPCookieStore::cookies(Function&lt;void (const Vector&lt;WebCore::Cookie&gt;&amp;)&gt;&amp;&amp; completionHandler)
</span><span class="cx"> {
</span><span class="cx">     auto&amp; dataStore = m_owningDataStore.websiteDataStore();
</span><del>-    auto pool = dataStore.processPoolForCookieStorageOperations();
</del><ins>+    auto* pool = dataStore.processPoolForCookieStorageOperations();
+    if (!pool) {
+        // FIXME: This is not necessarily the right storage session, but it's currently
+        // the best we can do in the absence of a process pool.
+        auto allCookies = WebCore::NetworkStorageSession::defaultStorageSession().getAllCookies();
+        callOnMainThread([completionHandler = WTFMove(completionHandler), allCookies = WTFMove(allCookies)]() {
+            completionHandler(allCookies);
+        });
+
+        return;
+    }
+
</ins><span class="cx">     auto* cookieManager = pool-&gt;supplement&lt;WebKit::WebCookieManagerProxy&gt;();
</span><del>-
</del><span class="cx">     cookieManager-&gt;getAllCookies(dataStore.sessionID(), [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](const Vector&lt;WebCore::Cookie&gt;&amp; cookies, CallbackBase::Error error) {
</span><span class="cx">         completionHandler(cookies);
</span><span class="cx">     });
</span><span class="lines">@@ -63,9 +76,19 @@
</span><span class="cx"> void HTTPCookieStore::setCookie(const WebCore::Cookie&amp; cookie, Function&lt;void ()&gt;&amp;&amp; completionHandler)
</span><span class="cx"> {
</span><span class="cx">     auto&amp; dataStore = m_owningDataStore.websiteDataStore();
</span><del>-    auto pool = dataStore.processPoolForCookieStorageOperations();
</del><ins>+    auto* pool = dataStore.processPoolForCookieStorageOperations();
+    if (!pool) {
+        // FIXME: This is not necessarily the right storage session, but it's currently
+        // the best we can do in the absence of a process pool.
+        WebCore::NetworkStorageSession::defaultStorageSession().setCookie(cookie);
+        callOnMainThread([completionHandler = WTFMove(completionHandler)]() {
+            completionHandler();
+        });
+
+        return;
+    }
+
</ins><span class="cx">     auto* cookieManager = pool-&gt;supplement&lt;WebKit::WebCookieManagerProxy&gt;();
</span><del>-
</del><span class="cx">     cookieManager-&gt;setCookie(dataStore.sessionID(), cookie, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](CallbackBase::Error error) {
</span><span class="cx">         completionHandler();
</span><span class="cx">     });
</span><span class="lines">@@ -74,9 +97,19 @@
</span><span class="cx"> void HTTPCookieStore::deleteCookie(const WebCore::Cookie&amp; cookie, Function&lt;void ()&gt;&amp;&amp; completionHandler)
</span><span class="cx"> {
</span><span class="cx">     auto&amp; dataStore = m_owningDataStore.websiteDataStore();
</span><del>-    auto pool = dataStore.processPoolForCookieStorageOperations();
</del><ins>+    auto* pool = dataStore.processPoolForCookieStorageOperations();
+    if (!pool) {
+        // FIXME: This is not necessarily the right storage session, but it's currently
+        // the best we can do in the absence of a process pool.
+        WebCore::NetworkStorageSession::defaultStorageSession().deleteCookie(cookie);
+        callOnMainThread([completionHandler = WTFMove(completionHandler)]() {
+            completionHandler();
+        });
+
+        return;
+    }
+
</ins><span class="cx">     auto* cookieManager = pool-&gt;supplement&lt;WebKit::WebCookieManagerProxy&gt;();
</span><del>-
</del><span class="cx">     cookieManager-&gt;deleteCookie(dataStore.sessionID(), cookie, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](CallbackBase::Error error) {
</span><span class="cx">         completionHandler();
</span><span class="cx">     });
</span><span class="lines">@@ -115,10 +148,19 @@
</span><span class="cx">     m_cookieManagerProxyObserver = std::make_unique&lt;APIWebCookieManagerProxyObserver&gt;(*this);
</span><span class="cx"> 
</span><span class="cx">     auto&amp; dataStore = m_owningDataStore.websiteDataStore();
</span><del>-    auto* pool = dataStore.processPoolForCookieStorageNotifications();
</del><ins>+    auto* pool = dataStore.processPoolForCookieStorageOperations();
</ins><span class="cx"> 
</span><span class="cx">     if (!pool) {
</span><span class="cx">         registerForNewProcessPoolNotifications();
</span><ins>+        ASSERT(!m_observingUIProcessCookies);
+
+        // Listen for cookie notifications in the UIProcess in the meantime.
+        WebCore::startObservingCookieChanges(WebCore::NetworkStorageSession::defaultStorageSession(), [this] () {
+            cookiesDidChange();
+        });
+
+        m_observingUIProcessCookies = true;
+
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -136,6 +178,9 @@
</span><span class="cx">     if (m_observedCookieManagerProxy)
</span><span class="cx">         m_observedCookieManagerProxy-&gt;unregisterObserver(m_owningDataStore.websiteDataStore().sessionID(), *m_cookieManagerProxyObserver);
</span><span class="cx"> 
</span><ins>+    if (m_observingUIProcessCookies)
+        WebCore::stopObservingCookieChanges(WebCore::NetworkStorageSession::defaultStorageSession());
+
</ins><span class="cx">     if (m_processPoolCreationListenerIdentifier)
</span><span class="cx">         WebProcessPool::unregisterProcessPoolCreationListener(m_processPoolCreationListenerIdentifier);
</span><span class="cx"> 
</span><span class="lines">@@ -142,6 +187,7 @@
</span><span class="cx">     m_processPoolCreationListenerIdentifier = 0;
</span><span class="cx">     m_observedCookieManagerProxy = nullptr;
</span><span class="cx">     m_cookieManagerProxyObserver = nullptr;
</span><ins>+    m_observingUIProcessCookies = false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTTPCookieStore::cookiesDidChange()
</span><span class="lines">@@ -157,7 +203,7 @@
</span><span class="cx">     m_observedCookieManagerProxy-&gt;unregisterObserver(dataStore.sessionID(), *m_cookieManagerProxyObserver);
</span><span class="cx">     m_observedCookieManagerProxy = nullptr;
</span><span class="cx"> 
</span><del>-    auto* pool = dataStore.processPoolForCookieStorageNotifications();
</del><ins>+    auto* pool = dataStore.processPoolForCookieStorageOperations();
</ins><span class="cx"> 
</span><span class="cx">     if (!pool) {
</span><span class="cx">         registerForNewProcessPoolNotifications();
</span><span class="lines">@@ -178,6 +224,12 @@
</span><span class="cx">         if (!m_owningDataStore.websiteDataStore().isAssociatedProcessPool(newProcessPool))
</span><span class="cx">             return;
</span><span class="cx"> 
</span><ins>+        // Now that an associated process pool exists, we need to flush the UI process cookie store
+        // to make sure any changes are reflected within the new process pool.
+        WebCore::NetworkStorageSession::defaultStorageSession().flushCookieStore();
+        newProcessPool.ensureNetworkProcess();
+
+
</ins><span class="cx">         m_observedCookieManagerProxy = newProcessPool.supplement&lt;WebKit::WebCookieManagerProxy&gt;();
</span><span class="cx">         m_observedCookieManagerProxy-&gt;registerObserver(m_owningDataStore.websiteDataStore().sessionID(), *m_cookieManagerProxyObserver);
</span><span class="cx">         unregisterForNewProcessPoolNotifications();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIHTTPCookieStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStore.h (214126 => 214127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStore.h        2017-03-17 21:59:33 UTC (rev 214126)
+++ trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStore.h        2017-03-17 23:23:39 UTC (rev 214127)
</span><span class="lines">@@ -81,6 +81,7 @@
</span><span class="cx"> 
</span><span class="cx">     WebKit::WebCookieManagerProxy* m_observedCookieManagerProxy { nullptr };
</span><span class="cx">     std::unique_ptr&lt;APIWebCookieManagerProxyObserver&gt; m_cookieManagerProxyObserver;
</span><ins>+    bool m_observingUIProcessCookies { false };
</ins><span class="cx"> 
</span><span class="cx">     uint64_t m_processPoolCreationListenerIdentifier { 0 };
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessPoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (214126 => 214127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp        2017-03-17 21:59:33 UTC (rev 214126)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp        2017-03-17 23:23:39 UTC (rev 214127)
</span><span class="lines">@@ -144,8 +144,11 @@
</span><span class="cx"> Ref&lt;WebProcessPool&gt; WebProcessPool::create(API::ProcessPoolConfiguration&amp; configuration)
</span><span class="cx"> {
</span><span class="cx">     InitializeWebKit2();
</span><del>-    auto newPool = adoptRef(*new WebProcessPool(configuration));
</del><ins>+    return adoptRef(*new WebProcessPool(configuration));
+}
</ins><span class="cx"> 
</span><ins>+void WebProcessPool::notifyThisWebProcessPoolWasCreated()
+{
</ins><span class="cx">     auto&amp; listenerMap = processPoolCreationListenerFunctionMap();
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;uint64_t&gt; identifiers;
</span><span class="lines">@@ -164,7 +167,7 @@
</span><span class="cx">         // removing itself from the map of listeners.
</span><span class="cx">         // If the identifier still exists in the map later, we move it back in.
</span><span class="cx">         Function&lt;void(WebProcessPool&amp;)&gt; function = WTFMove(iterator-&gt;value);
</span><del>-        function(newPool.get());
</del><ins>+        function(*this);
</ins><span class="cx"> 
</span><span class="cx">         iterator = listenerMap.find(identifier);
</span><span class="cx">         if (iterator != listenerMap.end()) {
</span><span class="lines">@@ -172,8 +175,6 @@
</span><span class="cx">             iterator-&gt;value = WTFMove(function);
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-
-    return newPool;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static Vector&lt;WebProcessPool*&gt;&amp; processPools()
</span><span class="lines">@@ -278,6 +279,8 @@
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     processPoolCounter.increment();
</span><span class="cx"> #endif
</span><ins>+
+    notifyThisWebProcessPoolWasCreated();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(COCOA)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessPoolh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (214126 => 214127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessPool.h        2017-03-17 21:59:33 UTC (rev 214126)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.h        2017-03-17 23:23:39 UTC (rev 214127)
</span><span class="lines">@@ -113,6 +113,8 @@
</span><span class="cx">     explicit WebProcessPool(API::ProcessPoolConfiguration&amp;);        
</span><span class="cx">     virtual ~WebProcessPool();
</span><span class="cx"> 
</span><ins>+    void notifyThisWebProcessPoolWasCreated();
+
</ins><span class="cx">     API::ProcessPoolConfiguration&amp; configuration() { return m_configuration.get(); }
</span><span class="cx"> 
</span><span class="cx">     static const Vector&lt;WebProcessPool*&gt;&amp; allProcessPools();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (214126 => 214127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2017-03-17 21:59:33 UTC (rev 214126)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2017-03-17 23:23:39 UTC (rev 214127)
</span><span class="lines">@@ -106,29 +106,8 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Ref&lt;WebProcessPool&gt; WebsiteDataStore::processPoolForCookieStorageOperations()
</del><ins>+WebProcessPool* WebsiteDataStore::processPoolForCookieStorageOperations()
</ins><span class="cx"> {
</span><del>-    // Our concepts of WebProcess, WebProcessPool, WebsiteDataStore, and SessionIDs have all started to overlap
-    // without clear divisions of responsibilities.
-    // In practice, multiple WebProcessPools can contain &quot;the same session&quot;, especially since there is currently
-    // only a single default global SessionID.
-    //
-    // This means that multiple NetworkProcesses can be using the same session, which means that multiple
-    // NetworkProcesses can be referring to the same platform cookie storage.
-    //
-    // While this may cause complications with future APIs it is actually fine for implementing the WKHTTPCookieStore API
-    // because we only need one NetworkProcess to successfully make a requested platform cookie storage change.
-    //
-    // FIXME: We need to start to unravel this mess going forward.
-
-    auto pools = processPools(1);
-    ASSERT(!pools.isEmpty());
-
-    return **pools.begin();
-}
-
-WebProcessPool* WebsiteDataStore::processPoolForCookieStorageNotifications()
-{
</del><span class="cx">     auto pools = processPools(1, false);
</span><span class="cx">     return pools.isEmpty() ? nullptr : pools.begin()-&gt;get();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h (214126 => 214127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h        2017-03-17 21:59:33 UTC (rev 214126)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h        2017-03-17 23:23:39 UTC (rev 214127)
</span><span class="lines">@@ -103,8 +103,7 @@
</span><span class="cx"> 
</span><span class="cx">     StorageManager* storageManager() { return m_storageManager.get(); }
</span><span class="cx"> 
</span><del>-    Ref&lt;WebProcessPool&gt; processPoolForCookieStorageOperations();
-    WebProcessPool* processPoolForCookieStorageNotifications();
</del><ins>+    WebProcessPool* processPoolForCookieStorageOperations();
</ins><span class="cx">     bool isAssociatedProcessPool(WebProcessPool&amp;) const;
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre>
</div>
</div>

</body>
</html>