Title: [148885] trunk/Source/WebKit/blackberry
Revision
148885
Author
[email protected]
Date
2013-04-22 08:43:59 -0700 (Mon, 22 Apr 2013)

Log Message

[BlackBerry] Update BatteryClientBlackBerry to use our port's new listener interface
https://bugs.webkit.org/show_bug.cgi?id=114892

Patch by Otto Derek Cheung <[email protected]> on 2013-04-22
Reviewed by Rob Buis.
PR 328147

Modify the client so we only have one listener for battery change events.
The dispatch of different event listeners are handled by BatteryController.

* WebCoreSupport/BatteryClientBlackBerry.cpp:
(WebCore::BatteryClientBlackBerry::BatteryClientBlackBerry):
(WebCore::BatteryClientBlackBerry::startUpdating):
(WebCore::BatteryClientBlackBerry::stopUpdating):
(WebCore::BatteryClientBlackBerry::onStatusChange):
* WebCoreSupport/BatteryClientBlackBerry.h:
(BatteryClientBlackBerry):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/ChangeLog (148884 => 148885)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-04-22 15:31:30 UTC (rev 148884)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-04-22 15:43:59 UTC (rev 148885)
@@ -1,3 +1,22 @@
+2013-04-22  Otto Derek Cheung  <[email protected]>
+
+        [BlackBerry] Update BatteryClientBlackBerry to use our port's new listener interface
+        https://bugs.webkit.org/show_bug.cgi?id=114892
+
+        Reviewed by Rob Buis.
+        PR 328147
+
+        Modify the client so we only have one listener for battery change events.
+        The dispatch of different event listeners are handled by BatteryController.
+
+        * WebCoreSupport/BatteryClientBlackBerry.cpp:
+        (WebCore::BatteryClientBlackBerry::BatteryClientBlackBerry):
+        (WebCore::BatteryClientBlackBerry::startUpdating):
+        (WebCore::BatteryClientBlackBerry::stopUpdating):
+        (WebCore::BatteryClientBlackBerry::onStatusChange):
+        * WebCoreSupport/BatteryClientBlackBerry.h:
+        (BatteryClientBlackBerry):
+
 2013-04-22  Xuefei Ren  <[email protected]>
 
         fix build warning(unused parameter)

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.cpp (148884 => 148885)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.cpp	2013-04-22 15:31:30 UTC (rev 148884)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.cpp	2013-04-22 15:43:59 UTC (rev 148885)
@@ -29,22 +29,24 @@
 
 BatteryClientBlackBerry::BatteryClientBlackBerry(BlackBerry::WebKit::WebPagePrivate* webPagePrivate)
     : m_webPagePrivate(webPagePrivate)
-    , m_tracker(0)
+    , m_isActive(false)
 {
 }
 
 void BatteryClientBlackBerry::startUpdating()
 {
-    if (m_tracker)
-        m_tracker->resume();
-    else
-        m_tracker = BlackBerry::Platform::BatteryStatusTracker::create(this);
+    if (!m_isActive) {
+        BlackBerry::Platform::BatteryStatusHandler::instance()->addListener(this);
+        m_isActive = true;
+    }
 }
 
 void BatteryClientBlackBerry::stopUpdating()
 {
-    if (m_tracker)
-        m_tracker->suspend();
+    if (m_isActive) {
+        BlackBerry::Platform::BatteryStatusHandler::instance()->removeListener(this);
+        m_isActive = false;
+    }
 }
 
 void BatteryClientBlackBerry::batteryControllerDestroyed()
@@ -52,26 +54,11 @@
     delete this;
 }
 
-void BatteryClientBlackBerry::onLevelChange(bool charging, double chargingTime, double dischargingTime, double level)
+void BatteryClientBlackBerry::onStatusChange(bool charging, double chargingTime, double dischargingTime, double level)
 {
-    BatteryController::from(m_webPagePrivate->m_page)->didChangeBatteryStatus("levelchange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
+    BatteryController::from(m_webPagePrivate->m_page)->updateBatteryStatus(BatteryStatus::create(charging, chargingTime, dischargingTime, level));
 }
 
-void BatteryClientBlackBerry::onChargingChange(bool charging, double chargingTime, double dischargingTime, double level)
-{
-    BatteryController::from(m_webPagePrivate->m_page)->didChangeBatteryStatus("chargingchange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
 }
 
-void BatteryClientBlackBerry::onChargingTimeChange(bool charging, double chargingTime, double dischargingTime, double level)
-{
-    BatteryController::from(m_webPagePrivate->m_page)->didChangeBatteryStatus("chargingtimechange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
-}
-
-void BatteryClientBlackBerry::onDischargingTimeChange(bool charging, double chargingTime, double dischargingTime, double level)
-{
-    BatteryController::from(m_webPagePrivate->m_page)->didChangeBatteryStatus("dischargingtimechange", BatteryStatus::create(charging, chargingTime, dischargingTime, level));
-}
-
-}
-
 #endif // BATTERY_STATUS

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.h (148884 => 148885)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.h	2013-04-22 15:31:30 UTC (rev 148884)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/BatteryClientBlackBerry.h	2013-04-22 15:43:59 UTC (rev 148885)
@@ -23,8 +23,7 @@
 
 #include "BatteryClient.h"
 
-#include <BlackBerryPlatformBatteryStatusTracker.h>
-#include <BlackBerryPlatformBatteryStatusTrackerListener.h>
+#include <BatteryStatusHandler.h>
 
 namespace BlackBerry {
 namespace WebKit {
@@ -36,7 +35,7 @@
 
 class BatteryStatus;
 
-class BatteryClientBlackBerry : public BatteryClient, public BlackBerry::Platform::BatteryStatusTrackerListener {
+class BatteryClientBlackBerry : public BatteryClient, public BlackBerry::Platform::BatteryStatusListener {
 public:
     explicit BatteryClientBlackBerry(BlackBerry::WebKit::WebPagePrivate*);
     ~BatteryClientBlackBerry() { }
@@ -45,14 +44,11 @@
     virtual void stopUpdating();
     virtual void batteryControllerDestroyed();
 
-    void onLevelChange(bool charging, double chargingTime, double dischargingTime, double level);
-    void onChargingChange(bool charging, double chargingTime, double dischargingTime, double level);
-    void onChargingTimeChange(bool charging, double chargingTime, double dischargingTime, double level);
-    void onDischargingTimeChange(bool charging, double chargingTime, double dischargingTime, double level);
+    void onStatusChange(bool charging, double chargingTime, double dischargingTime, double level);
 
 private:
     BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate;
-    BlackBerry::Platform::BatteryStatusTracker* m_tracker;
+    bool m_isActive;
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to