WebProcessPools should always have a WebsiteDataStore
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Apr 2017 00:18:52 +0000 (00:18 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Apr 2017 00:18:52 +0000 (00:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171252

Reviewed by Alex Christensen.

* UIProcess/API/APIWebsiteDataStore.cpp:
(API::WebsiteDataStore::registerSharedResourceLoadObserver): Deleted.
* UIProcess/API/APIWebsiteDataStore.h:
* UIProcess/API/C/WKContext.cpp:
(WKContextGetWebsiteDataStore):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitialize):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::WebProcessPool):
(WebKit::WebProcessPool::createWebPage):
* UIProcess/WebProcessPool.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::isAssociatedProcessPool):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp
Source/WebKit2/UIProcess/API/APIWebsiteDataStore.h
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/UIProcess/WebProcessPool.h
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp

index f8d1e24..0c67f4a 100644 (file)
@@ -1,3 +1,24 @@
+2017-04-24  Brady Eidson  <beidson@apple.com>
+
+        WebProcessPools should always have a WebsiteDataStore
+        https://bugs.webkit.org/show_bug.cgi?id=171252
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/API/APIWebsiteDataStore.cpp:
+        (API::WebsiteDataStore::registerSharedResourceLoadObserver): Deleted.
+        * UIProcess/API/APIWebsiteDataStore.h:
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextGetWebsiteDataStore):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitialize):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::WebProcessPool):
+        (WebKit::WebProcessPool::createWebPage):
+        * UIProcess/WebProcessPool.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::isAssociatedProcessPool):
+
 2017-04-24  Youenn Fablet  <youenn@apple.com>
 
         Set defaults video getUserMedia constraints
index 51bf9f9..f957a62 100644 (file)
@@ -87,11 +87,6 @@ void WebsiteDataStore::setResourceLoadStatisticsEnabled(bool enabled)
     m_websiteDataStore->setResourceLoadStatisticsEnabled(enabled);
 }
 
-void WebsiteDataStore::registerSharedResourceLoadObserver()
-{
-    m_websiteDataStore->registerSharedResourceLoadObserver();
-}
-    
 #if !PLATFORM(COCOA) && !PLATFORM(GTK)
 WebKit::WebsiteDataStore::Configuration WebsiteDataStore::defaultDataStoreConfiguration()
 {
index fb19635..b392fd6 100644 (file)
@@ -46,7 +46,6 @@ public:
 
     bool resourceLoadStatisticsEnabled() const;
     void setResourceLoadStatisticsEnabled(bool);
-    void registerSharedResourceLoadObserver();
 
     WebKit::WebsiteDataStore& websiteDataStore() { return *m_websiteDataStore; }
     HTTPCookieStore& httpCookieStore();
index bce39d0..1d22593 100644 (file)
@@ -404,7 +404,7 @@ WKCookieManagerRef WKContextGetCookieManager(WKContextRef contextRef)
 
 WKWebsiteDataStoreRef WKContextGetWebsiteDataStore(WKContextRef context)
 {
-    return toAPI(toImpl(context)->websiteDataStore());
+    return toAPI(&toImpl(context)->websiteDataStore());
 }
 
 WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef context)
index abb099a..34f524c 100644 (file)
@@ -149,8 +149,7 @@ void WebProcessPool::platformInitialize()
 
     setLegacyCustomProtocolManagerClient(std::make_unique<LegacyCustomProtocolManagerClient>());
 
-    if (m_websiteDataStore)
-        m_websiteDataStore->registerSharedResourceLoadObserver();
+    m_websiteDataStore->websiteDataStore().registerSharedResourceLoadObserver();
 }
 
 #if PLATFORM(IOS)
index 10ab539..f9a7c00 100644 (file)
@@ -229,7 +229,7 @@ WebProcessPool::WebProcessPool(API::ProcessPoolConfiguration& configuration)
     , m_shouldUseFontSmoothing(true)
     , m_memorySamplerEnabled(false)
     , m_memorySamplerInterval(1400.0)
-    , m_websiteDataStore(m_configuration->shouldHaveLegacyDataStore() ? API::WebsiteDataStore::create(legacyWebsiteDataStoreConfiguration(m_configuration)).ptr() : nullptr)
+    , m_websiteDataStore(m_configuration->shouldHaveLegacyDataStore() ? API::WebsiteDataStore::create(legacyWebsiteDataStoreConfiguration(m_configuration)) : API::WebsiteDataStore::defaultDataStore())
 #if PLATFORM(MAC)
     , m_highPerformanceGraphicsUsageSampler(std::make_unique<HighPerformanceGraphicsUsageSampler>(*this))
     , m_perActivityStateCPUUsageSampler(std::make_unique<PerActivityStateCPUUsageSampler>(*this))
@@ -909,8 +909,8 @@ Ref<WebPageProxy> WebProcessPool::createWebPage(PageClient& pageClient, Ref<API:
 
     if (!pageConfiguration->websiteDataStore()) {
         ASSERT(!pageConfiguration->sessionID().isValid());
-        pageConfiguration->setWebsiteDataStore(m_websiteDataStore.get());
-        pageConfiguration->setSessionID(pageConfiguration->preferences()->privateBrowsingEnabled() ? SessionID::legacyPrivateSessionID() : SessionID::defaultSessionID());
+        pageConfiguration->setWebsiteDataStore(m_websiteDataStore.ptr());
+        pageConfiguration->setSessionID(pageConfiguration->preferences()->privateBrowsingEnabled() ? SessionID::legacyPrivateSessionID() : m_websiteDataStore->websiteDataStore().sessionID());
     }
 
     RefPtr<WebProcessProxy> process;
index 0ec8273..13edc1d 100644 (file)
@@ -172,7 +172,7 @@ public:
     // Disconnect the process from the context.
     void disconnectProcess(WebProcessProxy*);
 
-    API::WebsiteDataStore* websiteDataStore() const { return m_websiteDataStore.get(); }
+    API::WebsiteDataStore& websiteDataStore() const { return m_websiteDataStore.get(); }
 
     Ref<WebPageProxy> createWebPage(PageClient&, Ref<API::PageConfiguration>&&);
 
@@ -523,7 +523,7 @@ private:
 
     RefPtr<WebIconDatabase> m_iconDatabase;
 
-    const RefPtr<API::WebsiteDataStore> m_websiteDataStore;
+    const Ref<API::WebsiteDataStore> m_websiteDataStore;
 
     typedef HashMap<const char*, RefPtr<WebContextSupplement>, PtrHash<const char*>> WebContextSupplementMap;
     WebContextSupplementMap m_supplements;
index b3b7423..e70ccc2 100644 (file)
@@ -1106,18 +1106,7 @@ void WebsiteDataStore::webProcessDidCloseConnection(WebProcessProxy& webProcessP
 
 bool WebsiteDataStore::isAssociatedProcessPool(WebProcessPool& processPool) const
 {
-    if (auto dataStore = processPool.websiteDataStore()) {
-        if (&dataStore->websiteDataStore() == this)
-            return true;
-    } else if (&API::WebsiteDataStore::defaultDataStore()->websiteDataStore() == this) {
-        // If a process pool doesn't have an explicit data store and this is the default WebsiteDataStore,
-        // add that process pool to the set.
-        // FIXME: This behavior is weird and necessitated by the fact that process pools don't always
-        // have a data store; they should.
-        return true;
-    }
-
-    return false;
+    return &processPool.websiteDataStore().websiteDataStore() == this;
 }
 
 HashSet<RefPtr<WebProcessPool>> WebsiteDataStore::processPools(size_t count, bool ensureAPoolExists) const