[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 <otcheung@rim.com> 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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 45714576
2013-04-22 Otto Derek Cheung <otcheung@rim.com>
[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 <xren@blackberry.com>
fix build warning(unused parameter)
......
......@@ -29,22 +29,24 @@ namespace WebCore {
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,24 +54,9 @@ void BatteryClientBlackBerry::batteryControllerDestroyed()
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));
}
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));
BatteryController::from(m_webPagePrivate->m_page)->updateBatteryStatus(BatteryStatus::create(charging, chargingTime, dischargingTime, level));
}
}
......
......@@ -23,8 +23,7 @@
#include "BatteryClient.h"
#include <BlackBerryPlatformBatteryStatusTracker.h>
#include <BlackBerryPlatformBatteryStatusTrackerListener.h>
#include <BatteryStatusHandler.h>
namespace BlackBerry {
namespace WebKit {
......@@ -36,7 +35,7 @@ namespace WebCore {
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 @@ public:
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;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment