[iOS] TestWebKitAPI.WebKit.WKHTTPCookieStoreWithoutProcessPool fails because cookies...
authorsihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jun 2018 22:09:48 +0000 (22:09 +0000)
committersihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jun 2018 22:09:48 +0000 (22:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186303
<rdar://problem/40468716>

Reviewed by Geoffrey Garen.

No matter there is an observer or not, cookies in UI process should always be flushed to
file when new process pool is created, such that cookies created via API can be synced to
network process.

* UIProcess/API/APIHTTPCookieStore.cpp:
(API::HTTPCookieStore::HTTPCookieStore):
(API::HTTPCookieStore::registerObserver):
(API::HTTPCookieStore::cookieManagerDestroyed):
(API::HTTPCookieStore::registerForNewProcessPoolNotifications):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/APIHTTPCookieStore.cpp

index 7ec3353..9e33562 100644 (file)
@@ -1,3 +1,21 @@
+2018-06-05  Sihui Liu  <sihui_liu@apple.com>
+
+        [iOS] TestWebKitAPI.WebKit.WKHTTPCookieStoreWithoutProcessPool fails because cookies aren't flushed to file
+        https://bugs.webkit.org/show_bug.cgi?id=186303
+        <rdar://problem/40468716>
+
+        Reviewed by Geoffrey Garen.
+
+        No matter there is an observer or not, cookies in UI process should always be flushed to 
+        file when new process pool is created, such that cookies created via API can be synced to
+        network process.
+
+        * UIProcess/API/APIHTTPCookieStore.cpp:
+        (API::HTTPCookieStore::HTTPCookieStore):
+        (API::HTTPCookieStore::registerObserver):
+        (API::HTTPCookieStore::cookieManagerDestroyed):
+        (API::HTTPCookieStore::registerForNewProcessPoolNotifications):
+
 2018-06-05  Jeremy Jones  <jeremyj@apple.com>
 
         secheuristic should only use touch began and ended, not changed.
index ed5d738..ad92157 100644 (file)
@@ -40,6 +40,8 @@ namespace API {
 HTTPCookieStore::HTTPCookieStore(WebsiteDataStore& websiteDataStore)
     : m_owningDataStore(websiteDataStore.websiteDataStore())
 {
+    if (!m_owningDataStore->processPoolForCookieStorageOperations())
+        registerForNewProcessPoolNotifications();
 }
 
 HTTPCookieStore::~HTTPCookieStore()
@@ -151,7 +153,6 @@ void HTTPCookieStore::registerObserver(Observer& observer)
     auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
 
     if (!pool) {
-        registerForNewProcessPoolNotifications();
         ASSERT(!m_observingUIProcessCookies);
 
         // Listen for cookie notifications in the UIProcess in the meantime.
@@ -203,10 +204,8 @@ void HTTPCookieStore::cookieManagerDestroyed()
 
     auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
 
-    if (!pool) {
-        registerForNewProcessPoolNotifications();
+    if (!pool)
         return;
-    }
 
     m_observedCookieManagerProxy = pool->supplement<WebKit::WebCookieManagerProxy>();
     m_observedCookieManagerProxy->registerObserver(m_owningDataStore->sessionID(), *m_cookieManagerProxyObserver);
@@ -217,8 +216,6 @@ void HTTPCookieStore::registerForNewProcessPoolNotifications()
     ASSERT(!m_processPoolCreationListenerIdentifier);
 
     m_processPoolCreationListenerIdentifier = WebProcessPool::registerProcessPoolCreationListener([this](WebProcessPool& newProcessPool) {
-        ASSERT(m_cookieManagerProxyObserver);
-
         if (!m_owningDataStore->isAssociatedProcessPool(newProcessPool))
             return;
 
@@ -227,9 +224,10 @@ void HTTPCookieStore::registerForNewProcessPoolNotifications()
         WebCore::NetworkStorageSession::defaultStorageSession().flushCookieStore();
         newProcessPool.ensureNetworkProcess();
 
-
-        m_observedCookieManagerProxy = newProcessPool.supplement<WebKit::WebCookieManagerProxy>();
-        m_observedCookieManagerProxy->registerObserver(m_owningDataStore->sessionID(), *m_cookieManagerProxyObserver);
+        if (m_cookieManagerProxyObserver) {
+            m_observedCookieManagerProxy = newProcessPool.supplement<WebKit::WebCookieManagerProxy>();
+            m_observedCookieManagerProxy->registerObserver(m_owningDataStore->sessionID(), *m_cookieManagerProxyObserver);
+        }
         unregisterForNewProcessPoolNotifications();
     });
 }