- Revision
- 138514
- Author
- wei...@apple.com
- Date
- 2012-12-27 14:06:41 -0800 (Thu, 27 Dec 2012)
Log Message
Actually make use of the WebProcessSupplements by adding a supplement map to WebProcess
https://bugs.webkit.org/show_bug.cgi?id=105804
Reviewed by Dan Bernstein.
This continues the work of adding extensibility to WebProcess by adding a supplement
map, and using it as proof of concept for WebDatabaseManager and WebKeyValueStorageManager.
- A supplement is added to WebProcess by calling:
process->addSupplement<SupplementFoo>();
- A supplement can be used accessed by calling:
process->supplement<SupplementFoo>();
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::clearAllDatabases):
(WebKit::InjectedBundle::setDatabaseQuota):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
Switch to using the new supplement accessor.
* WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp:
(WebKit::WebKeyValueStorageManager::supplementName):
* WebProcess/KeyValueStorage/WebKeyValueStorageManager.h:
* WebProcess/WebCoreSupport/WebDatabaseManager.cpp:
(WebKit::WebDatabaseManager::supplementName):
* WebProcess/WebCoreSupport/WebDatabaseManager.h:
Add static supplementName functions. We might want to merge this with
the message class name, but for now we have both.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
Add supplements the new way. This should eventually move to the caller
of WebProcess::initialize, so that we can reduce #ifdefs and ports have
a chance to customize.
(WebKit::WebProcess::initializeWebProcess):
Iterate the supplements to give each a chance to initialize.
* WebProcess/WebProcess.h:
(WebKit::WebProcess::supplement):
(WebKit::WebProcess::addSupplement):
Add functions to add and get WebProcessSupplements.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (138513 => 138514)
--- trunk/Source/WebKit2/ChangeLog 2012-12-27 21:15:59 UTC (rev 138513)
+++ trunk/Source/WebKit2/ChangeLog 2012-12-27 22:06:41 UTC (rev 138514)
@@ -1,3 +1,48 @@
+2012-12-27 Sam Weinig <s...@webkit.org>
+
+ Actually make use of the WebProcessSupplements by adding a supplement map to WebProcess
+ https://bugs.webkit.org/show_bug.cgi?id=105804
+
+ Reviewed by Dan Bernstein.
+
+ This continues the work of adding extensibility to WebProcess by adding a supplement
+ map, and using it as proof of concept for WebDatabaseManager and WebKeyValueStorageManager.
+
+ - A supplement is added to WebProcess by calling:
+ process->addSupplement<SupplementFoo>();
+ - A supplement can be used accessed by calling:
+ process->supplement<SupplementFoo>();
+
+ * WebProcess/InjectedBundle/InjectedBundle.cpp:
+ (WebKit::InjectedBundle::clearAllDatabases):
+ (WebKit::InjectedBundle::setDatabaseQuota):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::updatePreferences):
+ Switch to using the new supplement accessor.
+
+ * WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp:
+ (WebKit::WebKeyValueStorageManager::supplementName):
+ * WebProcess/KeyValueStorage/WebKeyValueStorageManager.h:
+ * WebProcess/WebCoreSupport/WebDatabaseManager.cpp:
+ (WebKit::WebDatabaseManager::supplementName):
+ * WebProcess/WebCoreSupport/WebDatabaseManager.h:
+ Add static supplementName functions. We might want to merge this with
+ the message class name, but for now we have both.
+
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::WebProcess):
+ Add supplements the new way. This should eventually move to the caller
+ of WebProcess::initialize, so that we can reduce #ifdefs and ports have
+ a chance to customize.
+
+ (WebKit::WebProcess::initializeWebProcess):
+ Iterate the supplements to give each a chance to initialize.
+
+ * WebProcess/WebProcess.h:
+ (WebKit::WebProcess::supplement):
+ (WebKit::WebProcess::addSupplement):
+ Add functions to add and get WebProcessSupplements.
+
2012-12-26 Sam Weinig <s...@webkit.org>
Add an initial stab at a generic supplemental interface for WebProcess
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (138513 => 138514)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp 2012-12-27 21:15:59 UTC (rev 138513)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp 2012-12-27 22:06:41 UTC (rev 138514)
@@ -349,7 +349,7 @@
void InjectedBundle::clearAllDatabases()
{
#if ENABLE(SQL_DATABASE)
- WebProcess::shared().databaseManager().deleteAllDatabases();
+ WebProcess::shared().supplement<WebDatabaseManager>()->deleteAllDatabases();
#endif
}
@@ -358,7 +358,7 @@
#if ENABLE(SQL_DATABASE)
// Historically, we've used the following (somewhat non-sensical) string
// for the databaseIdentifier of local files.
- WebProcess::shared().databaseManager().setQuotaForOrigin("file__0", quota);
+ WebProcess::shared().supplement<WebDatabaseManager>()->setQuotaForOrigin("file__0", quota);
#endif
}
Modified: trunk/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp (138513 => 138514)
--- trunk/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp 2012-12-27 21:15:59 UTC (rev 138513)
+++ trunk/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.cpp 2012-12-27 22:06:41 UTC (rev 138514)
@@ -39,6 +39,12 @@
namespace WebKit {
+const AtomicString& WebKeyValueStorageManager::supplementName()
+{
+ DEFINE_STATIC_LOCAL(AtomicString, name, ("WebKeyValueStorageManager", AtomicString::ConstructFromLiteral));
+ return name;
+}
+
WebKeyValueStorageManager::WebKeyValueStorageManager(WebProcess* process)
: m_process(process)
{
Modified: trunk/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.h (138513 => 138514)
--- trunk/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.h 2012-12-27 21:15:59 UTC (rev 138513)
+++ trunk/Source/WebKit2/WebProcess/KeyValueStorage/WebKeyValueStorageManager.h 2012-12-27 22:06:41 UTC (rev 138514)
@@ -42,12 +42,14 @@
public:
explicit WebKeyValueStorageManager(WebProcess*);
- // WebProcessSupplement
- virtual void initialize(const WebProcessCreationParameters&) OVERRIDE;
+ static const AtomicString& supplementName();
const String& localStorageDirectory() const { return m_localStorageDirectory; }
private:
+ // WebProcessSupplement
+ virtual void initialize(const WebProcessCreationParameters&) OVERRIDE;
+
// CoreIPC::MessageReceiver
virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
void didReceiveWebKeyValueStorageManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp (138513 => 138514)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp 2012-12-27 21:15:59 UTC (rev 138513)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp 2012-12-27 22:06:41 UTC (rev 138514)
@@ -42,6 +42,12 @@
namespace WebKit {
+const AtomicString& WebDatabaseManager::supplementName()
+{
+ DEFINE_STATIC_LOCAL(AtomicString, name, ("WebDatabaseManager", AtomicString::ConstructFromLiteral));
+ return name;
+}
+
WebDatabaseManager::WebDatabaseManager(WebProcess* process)
: m_process(process)
{
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h (138513 => 138514)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h 2012-12-27 21:15:59 UTC (rev 138513)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h 2012-12-27 22:06:41 UTC (rev 138514)
@@ -42,13 +42,15 @@
public:
explicit WebDatabaseManager(WebProcess*);
- // WebProcessSupplement
- virtual void initialize(const WebProcessCreationParameters&) OVERRIDE;
+ static const AtomicString& supplementName();
void setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const;
void deleteAllDatabases() const;
private:
+ // WebProcessSupplement
+ virtual void initialize(const WebProcessCreationParameters&) OVERRIDE;
+
// CoreIPC::MessageReceiver
void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
// Implemented in generated WebDatabaseManagerMessageReceiver.cpp
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (138513 => 138514)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2012-12-27 21:15:59 UTC (rev 138513)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2012-12-27 22:06:41 UTC (rev 138514)
@@ -2343,7 +2343,7 @@
settings->setFullScreenEnabled(store.getBoolValueForKey(WebPreferencesKey::fullScreenEnabledKey()));
#endif
- settings->setLocalStorageDatabasePath(WebProcess::shared().keyValueStorageManager().localStorageDirectory());
+ settings->setLocalStorageDatabasePath(WebProcess::shared().supplement<WebKeyValueStorageManager>()->localStorageDirectory());
#if USE(AVFOUNDATION)
settings->setAVFoundationEnabled(store.getBoolValueForKey(WebPreferencesKey::isAVFoundationEnabledKey()));
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (138513 => 138514)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2012-12-27 21:15:59 UTC (rev 138513)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2012-12-27 22:06:41 UTC (rev 138514)
@@ -151,12 +151,8 @@
, m_applicationCacheManager(new WebApplicationCacheManager(this))
, m_resourceCacheManager(new WebResourceCacheManager(this))
, m_cookieManager(new WebCookieManager(this))
- , m_keyValueStorageManager(new WebKeyValueStorageManager(this))
, m_mediaCacheManager(new WebMediaCacheManager(this))
, m_authenticationManager(new AuthenticationManager(this))
-#if ENABLE(SQL_DATABASE)
- , m_databaseManager(new WebDatabaseManager(this))
-#endif
#if ENABLE(BATTERY_STATUS)
, m_batteryManager(this)
#endif
@@ -192,6 +188,14 @@
#if ENABLE(CUSTOM_PROTOCOLS)
CustomProtocolManager::shared().initialize(this);
#endif
+
+ // FIXME: This should moved to where WebProcess::initialize is called,
+ // so that ports have a chance to customize, and ifdefs in this file are
+ // limited.
+ addSupplement<WebKeyValueStorageManager>();
+#if ENABLE(SQL_DATABASE)
+ addSupplement<WebDatabaseManager>();
+#endif
}
void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, RunLoop* runLoop)
@@ -253,16 +257,15 @@
}
}
-#if ENABLE(SQL_DATABASE)
- m_databaseManager->initialize(parameters);
-#endif
+ WebProcessSupplementMap::const_iterator it = m_supplements.begin();
+ WebProcessSupplementMap::const_iterator end = m_supplements.end();
+ for (; it != end; ++it)
+ it->value->initialize(parameters);
#if ENABLE(ICONDATABASE)
m_iconDatabaseProxy->setEnabled(parameters.iconDatabaseEnabled);
#endif
- m_keyValueStorageManager->initialize(parameters);
-
if (!parameters.applicationCacheDirectory.isEmpty())
cacheStorage().setCacheDirectory(parameters.applicationCacheDirectory);
@@ -450,11 +453,6 @@
return *m_cookieManager;
}
-WebKeyValueStorageManager& WebProcess::keyValueStorageManager()
-{
- return *m_keyValueStorageManager;
-}
-
DownloadManager& WebProcess::downloadManager()
{
#if ENABLE(NETWORK_PROCESS)
@@ -470,13 +468,6 @@
return *m_authenticationManager;
}
-#if ENABLE(SQL_DATABASE)
-WebDatabaseManager& WebProcess::databaseManager()
-{
- return *m_databaseManager;
-}
-#endif
-
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
WebNotificationManager& WebProcess::notificationManager()
{
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (138513 => 138514)
--- trunk/Source/WebKit2/WebProcess/WebProcess.h 2012-12-27 21:15:59 UTC (rev 138513)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h 2012-12-27 22:06:41 UTC (rev 138514)
@@ -39,6 +39,8 @@
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
+#include <wtf/text/AtomicString.h>
+#include <wtf/text/AtomicStringHash.h>
#if USE(SOUP)
#include "WebSoupRequestManager.h"
@@ -86,6 +88,7 @@
class WebMediaCacheManager;
class WebPage;
class WebPageGroupProxy;
+class WebProcessSupplement;
class WebResourceCacheManager;
struct WebPageCreationParameters;
struct WebPageGroupData;
@@ -120,6 +123,18 @@
public:
static WebProcess& shared();
+ template <typename T>
+ T* supplement()
+ {
+ return static_cast<T*>(m_supplements.get(T::supplementName()));
+ }
+
+ template <typename T>
+ void addSupplement()
+ {
+ m_supplements.add(T::supplementName(), new T(this));
+ }
+
void initialize(CoreIPC::Connection::Identifier, WebCore::RunLoop*);
virtual CoreIPC::Connection* connection() const OVERRIDE { return m_connection.get(); }
@@ -183,14 +198,9 @@
WebApplicationCacheManager& applicationCacheManager();
WebResourceCacheManager& resourceCacheManager();
WebCookieManager& cookieManager();
- WebKeyValueStorageManager& keyValueStorageManager();
DownloadManager& downloadManager();
AuthenticationManager& authenticationManager();
-#if ENABLE(SQL_DATABASE)
- WebDatabaseManager& databaseManager();
-#endif
-
#if ENABLE(BATTERY_STATUS)
WebBatteryManager& batteryManager() { return m_batteryManager; }
#endif
@@ -376,17 +386,17 @@
HashMap<uint64_t, RefPtr<WebCore::PlatformMessagePortChannel> > m_messagePortChannels;
#endif
+ typedef HashMap<AtomicString, WebProcessSupplement*> WebProcessSupplementMap;
+ WebProcessSupplementMap m_supplements;
+
TextCheckerState m_textCheckerState;
WebGeolocationManager* m_geolocationManager;
WebApplicationCacheManager* m_applicationCacheManager;
WebResourceCacheManager* m_resourceCacheManager;
WebCookieManager* m_cookieManager;
- WebKeyValueStorageManager* m_keyValueStorageManager;
WebMediaCacheManager* m_mediaCacheManager;
AuthenticationManager* m_authenticationManager;
-#if ENABLE(SQL_DATABASE)
- WebDatabaseManager* m_databaseManager;
-#endif
+
#if ENABLE(BATTERY_STATUS)
WebBatteryManager m_batteryManager;
#endif