Title: [149717] trunk/Source/WebKit2
Revision
149717
Author
[email protected]
Date
2013-05-08 00:51:48 -0700 (Wed, 08 May 2013)

Log Message

[WK2] Make the WebBatteryManager a supplement to the WebProcess
https://bugs.webkit.org/show_bug.cgi?id=115715

Reviewed by Andreas Kling.

WebBatteryManager should inherit from WebProcessSupplement and should be used as such
by the WebProcess. This removes the need for the m_batteryManager member variable in
the WebProcess class and brings the WebBatteryManager in line with other manager classes
of which instances are controlled by the WebProcess class.

* WebProcess/Battery/WebBatteryManager.cpp:
(WebKit::WebBatteryManager::supplementName): Specify the supplement's name.
(WebKit):
* WebProcess/Battery/WebBatteryManager.h:
(WebBatteryManager): Inherit from the WebProcessSupplement interface.
* WebProcess/WebCoreSupport/WebBatteryClient.cpp:
(WebKit::WebBatteryClient::startUpdating): Access the WebBatteryManager as a supplement.
(WebKit::WebBatteryClient::stopUpdating): Ditto.
(WebKit::WebBatteryClient::batteryControllerDestroyed): Ditto.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess): Add the WebBatteryManager instance as a supplement.
* WebProcess/WebProcess.h:
(WebProcess): Remove the m_batteryManager member variable and its getter method.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (149716 => 149717)


--- trunk/Source/WebKit2/ChangeLog	2013-05-08 07:40:11 UTC (rev 149716)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-08 07:51:48 UTC (rev 149717)
@@ -1,3 +1,29 @@
+2013-05-08  Zan Dobersek  <[email protected]>
+
+        [WK2] Make the WebBatteryManager a supplement to the WebProcess
+        https://bugs.webkit.org/show_bug.cgi?id=115715
+
+        Reviewed by Andreas Kling.
+
+        WebBatteryManager should inherit from WebProcessSupplement and should be used as such
+        by the WebProcess. This removes the need for the m_batteryManager member variable in
+        the WebProcess class and brings the WebBatteryManager in line with other manager classes
+        of which instances are controlled by the WebProcess class.
+
+        * WebProcess/Battery/WebBatteryManager.cpp:
+        (WebKit::WebBatteryManager::supplementName): Specify the supplement's name.
+        (WebKit):
+        * WebProcess/Battery/WebBatteryManager.h:
+        (WebBatteryManager): Inherit from the WebProcessSupplement interface.
+        * WebProcess/WebCoreSupport/WebBatteryClient.cpp:
+        (WebKit::WebBatteryClient::startUpdating): Access the WebBatteryManager as a supplement.
+        (WebKit::WebBatteryClient::stopUpdating): Ditto.
+        (WebKit::WebBatteryClient::batteryControllerDestroyed): Ditto.
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::WebProcess): Add the WebBatteryManager instance as a supplement.
+        * WebProcess/WebProcess.h:
+        (WebProcess): Remove the m_batteryManager member variable and its getter method.
+
 2013-05-06  Darin Adler  <[email protected]>
 
         Use adoptCF and adoptNS in more places

Modified: trunk/Source/WebKit2/WebProcess/Battery/WebBatteryManager.cpp (149716 => 149717)


--- trunk/Source/WebKit2/WebProcess/Battery/WebBatteryManager.cpp	2013-05-08 07:40:11 UTC (rev 149716)
+++ trunk/Source/WebKit2/WebProcess/Battery/WebBatteryManager.cpp	2013-05-08 07:51:48 UTC (rev 149717)
@@ -40,6 +40,11 @@
 
 namespace WebKit {
 
+const char* WebBatteryManager::supplementName()
+{
+    return "WebBatteryManager";
+}
+
 WebBatteryManager::WebBatteryManager(WebProcess* process)
     : m_process(process)
 {

Modified: trunk/Source/WebKit2/WebProcess/Battery/WebBatteryManager.h (149716 => 149717)


--- trunk/Source/WebKit2/WebProcess/Battery/WebBatteryManager.h	2013-05-08 07:40:11 UTC (rev 149716)
+++ trunk/Source/WebKit2/WebProcess/Battery/WebBatteryManager.h	2013-05-08 07:51:48 UTC (rev 149717)
@@ -31,6 +31,7 @@
 #include "MessageReceiver.h"
 #include "WebBatteryStatus.h"
 #include "WebCoreArgumentCoders.h"
+#include "WebProcessSupplement.h"
 #include <wtf/HashSet.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/text/AtomicString.h>
@@ -40,13 +41,15 @@
 class WebPage;
 class WebProcess;
 
-class WebBatteryManager : private CoreIPC::MessageReceiver {
+class WebBatteryManager : public WebProcessSupplement, private CoreIPC::MessageReceiver {
     WTF_MAKE_NONCOPYABLE(WebBatteryManager);
 
 public:
     explicit WebBatteryManager(WebProcess*);
     ~WebBatteryManager();
 
+    static const char* supplementName();
+
     void registerWebPage(WebPage*);
     void unregisterWebPage(WebPage*);
 

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.cpp (149716 => 149717)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.cpp	2013-05-08 07:40:11 UTC (rev 149716)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.cpp	2013-05-08 07:51:48 UTC (rev 149717)
@@ -38,17 +38,17 @@
 
 void WebBatteryClient::startUpdating()
 {
-    WebProcess::shared().batteryManager().registerWebPage(m_page);
+    WebProcess::shared().supplement<WebBatteryManager>()->registerWebPage(m_page);
 }
 
 void WebBatteryClient::stopUpdating()
 {
-    WebProcess::shared().batteryManager().unregisterWebPage(m_page);
+    WebProcess::shared().supplement<WebBatteryManager>()->unregisterWebPage(m_page);
 }
 
 void WebBatteryClient::batteryControllerDestroyed()
 {
-    WebProcess::shared().batteryManager().unregisterWebPage(m_page);
+    WebProcess::shared().supplement<WebBatteryManager>()->unregisterWebPage(m_page);
     delete this;
 }
 

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (149716 => 149717)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2013-05-08 07:40:11 UTC (rev 149716)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2013-05-08 07:51:48 UTC (rev 149717)
@@ -114,6 +114,10 @@
 #include "WebDatabaseManager.h"
 #endif
 
+#if ENABLE(BATTERY_STATUS)
+#include "WebBatteryManager.h"
+#endif
+
 #if ENABLE(NETWORK_PROCESS)
 #include "WebResourceLoadScheduler.h"
 #endif
@@ -160,9 +164,6 @@
     , m_networkAccessManager(0)
 #endif
     , m_textCheckerState()
-#if ENABLE(BATTERY_STATUS)
-    , m_batteryManager(this)
-#endif
 #if ENABLE(NETWORK_INFO)
     , m_networkInfoManager(this)
 #endif
@@ -207,6 +208,9 @@
 #if ENABLE(CUSTOM_PROTOCOLS)
     addSupplement<CustomProtocolManager>();
 #endif
+#if ENABLE(BATTERY_STATUS)
+    addSupplement<WebBatteryManager>();
+#endif
 }
 
 void WebProcess::initializeProcess(const ChildProcessInitializationParameters& parameters)

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (149716 => 149717)


--- trunk/Source/WebKit2/WebProcess/WebProcess.h	2013-05-08 07:40:11 UTC (rev 149716)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h	2013-05-08 07:51:48 UTC (rev 149717)
@@ -57,10 +57,6 @@
 #include <dispatch/dispatch.h>
 #endif
 
-#if ENABLE(BATTERY_STATUS)
-#include "WebBatteryManager.h"
-#endif
-
 #if ENABLE(NETWORK_INFO)
 #include "WebNetworkInfoManager.h"
 #endif
@@ -152,9 +148,6 @@
 #if PLATFORM(QT)
     QNetworkAccessManager* networkAccessManager() { return m_networkAccessManager; }
 #endif
-#if ENABLE(BATTERY_STATUS)
-    WebBatteryManager& batteryManager() { return m_batteryManager; }
-#endif
 #if ENABLE(NETWORK_INFO)
     WebNetworkInfoManager& networkInfoManager() { return m_networkInfoManager; }
 #endif
@@ -317,9 +310,6 @@
 
     TextCheckerState m_textCheckerState;
 
-#if ENABLE(BATTERY_STATUS)
-    WebBatteryManager m_batteryManager;
-#endif
 #if ENABLE(NETWORK_INFO)
     WebNetworkInfoManager m_networkInfoManager;
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to