Title: [122153] trunk/Source/WebKit2
Revision
122153
Author
[email protected]
Date
2012-07-09 13:46:07 -0700 (Mon, 09 Jul 2012)

Log Message

[WK2] Add missing Battery Status API integration to WebContext and WebPage
https://bugs.webkit.org/show_bug.cgi?id=90784

Patch by Christophe Dumez <[email protected]> on 2012-07-09
Reviewed by Anders Carlsson.

Integrate Battery Status API to WebPage, WebContext and
properly route messages to the WebBatteryManagerProxy.
Without this, the Battery Status tests are crashing for
WebKit2.

* UIProcess/API/C/WKContext.cpp:
(WKContextGetBatteryManager):
* UIProcess/API/C/WKContext.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext):
(WebKit::WebContext::~WebContext):
(WebKit::WebContext::disconnectProcess):
(WebKit::WebContext::didReceiveMessage):
* UIProcess/WebContext.h:
(WebKit):
(WebContext):
(WebKit::WebContext::batteryManagerProxy):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didReceiveMessage):
* WebProcess/WebCoreSupport/WebBatteryClient.cpp:
(WebKit::WebBatteryClient::setController):
(WebKit):
* WebProcess/WebCoreSupport/WebBatteryClient.h:
(WebBatteryClient):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (122152 => 122153)


--- trunk/Source/WebKit2/ChangeLog	2012-07-09 20:36:21 UTC (rev 122152)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-09 20:46:07 UTC (rev 122153)
@@ -1,3 +1,37 @@
+2012-07-09  Christophe Dumez  <[email protected]>
+
+        [WK2] Add missing Battery Status API integration to WebContext and WebPage
+        https://bugs.webkit.org/show_bug.cgi?id=90784
+
+        Reviewed by Anders Carlsson.
+
+        Integrate Battery Status API to WebPage, WebContext and
+        properly route messages to the WebBatteryManagerProxy.
+        Without this, the Battery Status tests are crashing for
+        WebKit2.
+
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextGetBatteryManager):
+        * UIProcess/API/C/WKContext.h:
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::WebContext):
+        (WebKit::WebContext::~WebContext):
+        (WebKit::WebContext::disconnectProcess):
+        (WebKit::WebContext::didReceiveMessage):
+        * UIProcess/WebContext.h:
+        (WebKit):
+        (WebContext):
+        (WebKit::WebContext::batteryManagerProxy):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::didReceiveMessage):
+        * WebProcess/WebCoreSupport/WebBatteryClient.cpp:
+        (WebKit::WebBatteryClient::setController):
+        (WebKit):
+        * WebProcess/WebCoreSupport/WebBatteryClient.h:
+        (WebBatteryClient):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+
 2012-07-09  Sudarsana Nagineni  <[email protected]>
 
         [EFL] [WK2] ASSERTION FAILED: !HashTranslator::equal(KeyTraits::emptyValue(), key)

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp (122152 => 122153)


--- trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp	2012-07-09 20:36:21 UTC (rev 122152)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp	2012-07-09 20:46:07 UTC (rev 122153)
@@ -170,6 +170,15 @@
     return toAPI(toImpl(contextRef)->applicationCacheManagerProxy());
 }
 
+WKBatteryManagerRef WKContextGetBatteryManager(WKContextRef contextRef)
+{
+#if ENABLE(BATTERY_STATUS)
+    return toAPI(toImpl(contextRef)->batteryManagerProxy());
+#else
+    return 0;
+#endif
+}
+
 WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef contextRef)
 {
     return toAPI(toImpl(contextRef)->databaseManagerProxy());

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContext.h (122152 => 122153)


--- trunk/Source/WebKit2/UIProcess/API/C/WKContext.h	2012-07-09 20:36:21 UTC (rev 122152)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContext.h	2012-07-09 20:46:07 UTC (rev 122153)
@@ -148,6 +148,7 @@
 WK_EXPORT void WKContextStopMemorySampler(WKContextRef context);
 
 WK_EXPORT WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef context);
+WK_EXPORT WKBatteryManagerRef WKContextGetBatteryManager(WKContextRef context);
 WK_EXPORT WKCookieManagerRef WKContextGetCookieManager(WKContextRef context);
 WK_EXPORT WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef context);
 WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef context);

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (122152 => 122153)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-07-09 20:36:21 UTC (rev 122152)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-07-09 20:46:07 UTC (rev 122153)
@@ -66,6 +66,10 @@
 #include "BuiltInPDFView.h"
 #endif
 
+#if ENABLE(BATTERY_STATUS)
+#include "WebBatteryManagerProxy.h"
+#endif
+
 #if USE(SOUP)
 #include "WebSoupRequestManagerProxy.h"
 #endif
@@ -130,6 +134,9 @@
     , m_memorySamplerEnabled(false)
     , m_memorySamplerInterval(1400.0)
     , m_applicationCacheManagerProxy(WebApplicationCacheManagerProxy::create(this))
+#if ENABLE(BATTERY_STATUS)
+    , m_batteryManagerProxy(WebBatteryManagerProxy::create(this))
+#endif
     , m_cookieManagerProxy(WebCookieManagerProxy::create(this))
     , m_databaseManagerProxy(WebDatabaseManagerProxy::create(this))
     , m_geolocationManagerProxy(WebGeolocationManagerProxy::create(this))
@@ -181,6 +188,11 @@
     m_applicationCacheManagerProxy->invalidate();
     m_applicationCacheManagerProxy->clearContext();
 
+#if ENABLE(BATTERY_STATUS)
+    m_batteryManagerProxy->invalidate();
+    m_batteryManagerProxy->clearContext();
+#endif
+
     m_cookieManagerProxy->invalidate();
     m_cookieManagerProxy->clearContext();
 
@@ -398,6 +410,9 @@
     m_downloads.clear();
 
     m_applicationCacheManagerProxy->invalidate();
+#if ENABLE(BATTERY_STATUS)
+    m_batteryManagerProxy->invalidate();
+#endif
     m_cookieManagerProxy->invalidate();
     m_databaseManagerProxy->invalidate();
     m_geolocationManagerProxy->invalidate();
@@ -731,6 +746,13 @@
         return;
     }
 
+#if ENABLE(BATTERY_STATUS)
+    if (messageID.is<CoreIPC::MessageClassWebBatteryManagerProxy>()) {
+        m_batteryManagerProxy->didReceiveMessage(connection, messageID, arguments);
+        return;
+    }
+#endif
+
     if (messageID.is<CoreIPC::MessageClassWebCookieManagerProxy>()) {
         m_cookieManagerProxy->didReceiveMessage(connection, messageID, arguments);
         return;

Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (122152 => 122153)


--- trunk/Source/WebKit2/UIProcess/WebContext.h	2012-07-09 20:36:21 UTC (rev 122152)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h	2012-07-09 20:46:07 UTC (rev 122153)
@@ -48,6 +48,9 @@
 
 class DownloadProxy;
 class WebApplicationCacheManagerProxy;
+#if ENABLE(BATTERY_STATUS)
+class WebBatteryManagerProxy;
+#endif
 class WebCookieManagerProxy;
 class WebDatabaseManagerProxy;
 class WebGeolocationManagerProxy;
@@ -154,6 +157,9 @@
     static HashSet<String, CaseFoldingHash> pdfAndPostScriptMIMETypes();
 
     WebApplicationCacheManagerProxy* applicationCacheManagerProxy() const { return m_applicationCacheManagerProxy.get(); }
+#if ENABLE(BATTERY_STATUS)
+    WebBatteryManagerProxy* batteryManagerProxy() const { return m_batteryManagerProxy.get(); }
+#endif
     WebCookieManagerProxy* cookieManagerProxy() const { return m_cookieManagerProxy.get(); }
     WebDatabaseManagerProxy* databaseManagerProxy() const { return m_databaseManagerProxy.get(); }
     WebGeolocationManagerProxy* geolocationManagerProxy() const { return m_geolocationManagerProxy.get(); }
@@ -299,6 +305,9 @@
     double m_memorySamplerInterval;
 
     RefPtr<WebApplicationCacheManagerProxy> m_applicationCacheManagerProxy;
+#if ENABLE(BATTERY_STATUS)
+    RefPtr<WebBatteryManagerProxy> m_batteryManagerProxy;
+#endif
     RefPtr<WebCookieManagerProxy> m_cookieManagerProxy;
     RefPtr<WebDatabaseManagerProxy> m_databaseManagerProxy;
     RefPtr<WebGeolocationManagerProxy> m_geolocationManagerProxy;

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (122152 => 122153)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2012-07-09 20:36:21 UTC (rev 122152)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2012-07-09 20:46:07 UTC (rev 122153)
@@ -307,6 +307,9 @@
         || messageID.is<CoreIPC::MessageClassWebContextLegacy>()
         || messageID.is<CoreIPC::MessageClassDownloadProxy>()
         || messageID.is<CoreIPC::MessageClassWebApplicationCacheManagerProxy>()
+#if ENABLE(BATTERY_STATUS)
+        || messageID.is<CoreIPC::MessageClassWebBatteryManagerProxy>()
+#endif
         || messageID.is<CoreIPC::MessageClassWebCookieManagerProxy>()
         || messageID.is<CoreIPC::MessageClassWebDatabaseManagerProxy>()
         || messageID.is<CoreIPC::MessageClassWebGeolocationManagerProxy>()

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.cpp (122152 => 122153)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.cpp	2012-07-09 20:36:21 UTC (rev 122152)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.cpp	2012-07-09 20:46:07 UTC (rev 122153)
@@ -36,6 +36,14 @@
 
 namespace WebKit {
 
+void WebBatteryClient::setController(WebCore::BatteryController*)
+{
+    // We provide an empty implementation for this method so that
+    // it compiles. We don't need it since WebBatteryManager
+    // retrieves the controller directly from the page by calling
+    // BatteryController::from().
+}
+
 void WebBatteryClient::startUpdating()
 {
     WebProcess::shared().batteryManager().registerWebPage(m_page);

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.h (122152 => 122153)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.h	2012-07-09 20:36:21 UTC (rev 122152)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebBatteryClient.h	2012-07-09 20:46:07 UTC (rev 122153)
@@ -44,6 +44,7 @@
     virtual ~WebBatteryClient() { }
 
 private:
+    virtual void setController(WebCore::BatteryController*) OVERRIDE;
     virtual void startUpdating() OVERRIDE;
     virtual void stopUpdating() OVERRIDE;
     virtual void batteryControllerDestroyed() OVERRIDE;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (122152 => 122153)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-07-09 20:36:21 UTC (rev 122152)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-07-09 20:46:07 UTC (rev 122153)
@@ -126,6 +126,10 @@
 #endif
 #endif
 
+#if ENABLE(BATTERY_STATUS)
+#include "WebBatteryClient.h"
+#endif
+
 #if ENABLE(WEB_INTENTS)
 #include "IntentData.h"
 #endif
@@ -262,6 +266,9 @@
     
     m_page = adoptPtr(new Page(pageClients));
 
+#if ENABLE(BATTERY_STATUS)
+    WebCore::provideBatteryTo(m_page.get(), new WebBatteryClient(this));
+#endif
 #if ENABLE(GEOLOCATION)
     WebCore::provideGeolocationTo(m_page.get(), new WebGeolocationClient(this));
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to