Move API::HTTPCookieStore ownership from API::WebsiteDataStore to WebKit::WebsiteData...
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2019 19:43:44 +0000 (19:43 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2019 19:43:44 +0000 (19:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194842

Reviewed by Geoff Garen.

We need a way to get from WebKit::WebsiteDataStore to API::HTTPCookieStore.  It can't be done before this.
This made an existing reference cycle easier to see, and we should fix it in a followup patch.

* UIProcess/API/APIWebsiteDataStore.cpp:
(API::WebsiteDataStore::httpCookieStore):
* UIProcess/API/APIWebsiteDataStore.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::cookieStore):
* UIProcess/WebsiteData/WebsiteDataStore.h:

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/APIHTTPCookieStore.cpp
Source/WebKit/UIProcess/API/APIHTTPCookieStore.h
Source/WebKit/UIProcess/API/APIWebsiteDataStore.cpp
Source/WebKit/UIProcess/API/APIWebsiteDataStore.h
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

index e7eb0b2..b8d57b7 100644 (file)
@@ -1,3 +1,20 @@
+2019-02-20  Alex Christensen  <achristensen@webkit.org>
+
+        Move API::HTTPCookieStore ownership from API::WebsiteDataStore to WebKit::WebsiteDataStore
+        https://bugs.webkit.org/show_bug.cgi?id=194842
+
+        Reviewed by Geoff Garen.
+
+        We need a way to get from WebKit::WebsiteDataStore to API::HTTPCookieStore.  It can't be done before this.
+        This made an existing reference cycle easier to see, and we should fix it in a followup patch.
+
+        * UIProcess/API/APIWebsiteDataStore.cpp:
+        (API::WebsiteDataStore::httpCookieStore):
+        * UIProcess/API/APIWebsiteDataStore.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::cookieStore):
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+
 2019-02-20  Chris Dumez  <cdumez@apple.com>
 
         Regression(PSON) Crash under WebKit::WebPageProxy::decidePolicyForNavigationActionSync
index 2e917fb..e174ef6 100644 (file)
@@ -37,8 +37,8 @@ using namespace WebKit;
 
 namespace API {
 
-HTTPCookieStore::HTTPCookieStore(WebsiteDataStore& websiteDataStore)
-    : m_owningDataStore(websiteDataStore.websiteDataStore())
+HTTPCookieStore::HTTPCookieStore(WebKit::WebsiteDataStore& websiteDataStore)
+    : m_owningDataStore(websiteDataStore)
 {
     if (!m_owningDataStore->processPoolForCookieStorageOperations())
         registerForNewProcessPoolNotifications();
index c61998a..df41125 100644 (file)
@@ -51,7 +51,7 @@ class WebsiteDataStore;
 
 class HTTPCookieStore final : public ObjectImpl<Object::Type::HTTPCookieStore> {
 public:
-    static Ref<HTTPCookieStore> create(WebsiteDataStore& websiteDataStore)
+    static Ref<HTTPCookieStore> create(WebKit::WebsiteDataStore& websiteDataStore)
     {
         return adoptRef(*new HTTPCookieStore(websiteDataStore));
     }
@@ -75,7 +75,7 @@ public:
     void cookieManagerDestroyed();
 
 private:
-    HTTPCookieStore(WebsiteDataStore&);
+    HTTPCookieStore(WebKit::WebsiteDataStore&);
 
     void registerForNewProcessPoolNotifications();
     void unregisterForNewProcessPoolNotifications();
@@ -87,6 +87,7 @@ private:
     void startObservingChangesToDefaultUIProcessCookieStore(Function<void()>&&);
     void stopObservingChangesToDefaultUIProcessCookieStore();
     
+    // FIXME: This is a reference cycle.
     Ref<WebKit::WebsiteDataStore> m_owningDataStore;
     HashSet<Observer*> m_observers;
 
index dbdbf9c..22740a7 100644 (file)
@@ -85,10 +85,7 @@ WebsiteDataStore::~WebsiteDataStore()
 
 HTTPCookieStore& WebsiteDataStore::httpCookieStore()
 {
-    if (!m_apiHTTPCookieStore)
-        m_apiHTTPCookieStore = HTTPCookieStore::create(*this);
-
-    return *m_apiHTTPCookieStore;
+    return m_websiteDataStore->cookieStore();
 }
 
 bool WebsiteDataStore::isPersistent()
index 9305950..6789eb2 100644 (file)
@@ -91,7 +91,6 @@ private:
     static WTF::String websiteDataDirectoryFileSystemRepresentation(const WTF::String& directoryName);
 
     Ref<WebKit::WebsiteDataStore> m_websiteDataStore;
-    RefPtr<HTTPCookieStore> m_apiHTTPCookieStore;
 };
 
 }
index 5c03556..ecf3ace 100644 (file)
@@ -2097,6 +2097,14 @@ void WebsiteDataStore::setMockWebAuthenticationConfiguration(MockWebAuthenticati
 }
 #endif
 
+API::HTTPCookieStore& WebsiteDataStore::cookieStore()
+{
+    if (!m_cookieStore)
+        m_cookieStore = API::HTTPCookieStore::create(*this);
+
+    return *m_cookieStore;
+}
+
 void WebsiteDataStore::didCreateNetworkProcess()
 {
 }
index 8f6e30f..dcadc34 100644 (file)
 #include <WebKitAdditions/WebsiteDataStoreAdditions.h>
 #endif
 
+namespace API {
+class HTTPCookieStore;
+}
+
 namespace WebCore {
 class SecurityOrigin;
 }
@@ -229,6 +233,8 @@ public:
     WebsiteDataStoreClient& client() { return m_client.get(); }
     void setClient(UniqueRef<WebsiteDataStoreClient>&& client) { m_client = WTFMove(client); }
 
+    API::HTTPCookieStore& cookieStore();
+
 #if HAVE(LOAD_OPTIMIZER)
 WEBSITEDATASTORE_LOADOPTIMIZER_ADDITIONS_1
 #endif
@@ -309,6 +315,8 @@ private:
 #endif
 
     UniqueRef<WebsiteDataStoreClient> m_client;
+
+    RefPtr<API::HTTPCookieStore> m_cookieStore;
 };
 
 }