Title: [122197] trunk/Source
Revision
122197
Author
[email protected]
Date
2012-07-09 23:42:40 -0700 (Mon, 09 Jul 2012)

Log Message

[EFL] Battery status code needs refactoring to be reused in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=90760

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

Source/WebCore:

Rename BatteryClientEfl to BatteryProviderEfl and remove dependency
on BatteryController by introducing the BatteryProviderEflClient
interface. This will allow reusing the BatteryProviderEfl class
in WebKit2.

No new tests. Already tested by batterystatus/*.

* PlatformEfl.cmake:
* platform/efl/BatteryProviderEfl.cpp: Renamed from Source/WebCore/platform/efl/BatteryClientEfl.cpp.
(WebCore):
(WebCore::BatteryProviderEfl::BatteryProviderEfl):
(WebCore::BatteryProviderEfl::batteryStatus):
(WebCore::BatteryProviderEfl::startUpdating):
(WebCore::BatteryProviderEfl::stopUpdating):
(WebCore::BatteryProviderEfl::setBatteryStatus):
(WebCore::BatteryProviderEfl::timerFired):
(WebCore::BatteryProviderEfl::getBatteryStatus):
(WebCore::BatteryProviderEfl::setBatteryClient):
* platform/efl/BatteryProviderEfl.h: Copied from Source/WebCore/platform/efl/BatteryClientEfl.h.
(WebCore):
(BatteryProviderEfl):
(WebCore::BatteryProviderEfl::~BatteryProviderEfl):
* platform/efl/BatteryProviderEflClient.h: Added.
(WebCore):
(BatteryProviderEflClient):

Source/WebKit:

Add BatteryClientEfl to PlatformEfl.cmake.

* PlatformEfl.cmake:

Source/WebKit/efl:

Add BatteryClientEfl to WebKit, which uses BatteryProviderEfl from
WebCore internally.

* WebCoreSupport/BatteryClientEfl.cpp: Added.
(BatteryClientEfl::BatteryClientEfl):
(BatteryClientEfl::setController):
(BatteryClientEfl::startUpdating):
(BatteryClientEfl::stopUpdating):
(BatteryClientEfl::batteryControllerDestroyed):
(BatteryClientEfl::didChangeBatteryStatus):
* WebCoreSupport/BatteryClientEfl.h: Renamed from Source/WebCore/platform/efl/BatteryClientEfl.h.
(WebCore):
(BatteryClientEfl):
(BatteryClientEfl::~BatteryClientEfl):
* ewk/ewk_view.cpp:
(_ewk_view_priv_new):

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (122196 => 122197)


--- trunk/Source/WebCore/ChangeLog	2012-07-10 05:55:48 UTC (rev 122196)
+++ trunk/Source/WebCore/ChangeLog	2012-07-10 06:42:40 UTC (rev 122197)
@@ -1,3 +1,36 @@
+2012-07-09  Christophe Dumez  <[email protected]>
+
+        [EFL] Battery status code needs refactoring to be reused in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=90760
+
+        Reviewed by Hajime Morita.
+
+        Rename BatteryClientEfl to BatteryProviderEfl and remove dependency
+        on BatteryController by introducing the BatteryProviderEflClient
+        interface. This will allow reusing the BatteryProviderEfl class
+        in WebKit2.
+
+        No new tests. Already tested by batterystatus/*.
+
+        * PlatformEfl.cmake:
+        * platform/efl/BatteryProviderEfl.cpp: Renamed from Source/WebCore/platform/efl/BatteryClientEfl.cpp.
+        (WebCore):
+        (WebCore::BatteryProviderEfl::BatteryProviderEfl):
+        (WebCore::BatteryProviderEfl::batteryStatus):
+        (WebCore::BatteryProviderEfl::startUpdating):
+        (WebCore::BatteryProviderEfl::stopUpdating):
+        (WebCore::BatteryProviderEfl::setBatteryStatus):
+        (WebCore::BatteryProviderEfl::timerFired):
+        (WebCore::BatteryProviderEfl::getBatteryStatus):
+        (WebCore::BatteryProviderEfl::setBatteryClient):
+        * platform/efl/BatteryProviderEfl.h: Copied from Source/WebCore/platform/efl/BatteryClientEfl.h.
+        (WebCore):
+        (BatteryProviderEfl):
+        (WebCore::BatteryProviderEfl::~BatteryProviderEfl):
+        * platform/efl/BatteryProviderEflClient.h: Added.
+        (WebCore):
+        (BatteryProviderEflClient):
+
 2012-07-09  Hayato Ito  <[email protected]>
 
         Unreviewed gardening.

Modified: trunk/Source/WebCore/PlatformEfl.cmake (122196 => 122197)


--- trunk/Source/WebCore/PlatformEfl.cmake	2012-07-10 05:55:48 UTC (rev 122196)
+++ trunk/Source/WebCore/PlatformEfl.cmake	2012-07-10 06:42:40 UTC (rev 122197)
@@ -23,7 +23,7 @@
   page/efl/DragControllerEfl.cpp
   page/efl/EventHandlerEfl.cpp
   platform/Cursor.cpp
-  platform/efl/BatteryClientEfl.cpp
+  platform/efl/BatteryProviderEfl.cpp
   platform/efl/ClipboardEfl.cpp
   platform/efl/ColorChooserEfl.cpp
   platform/efl/ContextMenuEfl.cpp

Deleted: trunk/Source/WebCore/platform/efl/BatteryClientEfl.cpp (122196 => 122197)


--- trunk/Source/WebCore/platform/efl/BatteryClientEfl.cpp	2012-07-10 05:55:48 UTC (rev 122196)
+++ trunk/Source/WebCore/platform/efl/BatteryClientEfl.cpp	2012-07-10 06:42:40 UTC (rev 122197)
@@ -1,189 +0,0 @@
-/*
- *  Copyright (C) 2012 Samsung Electronics
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Library General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU Library General Public License
- *  along with this library; see the file COPYING.LIB.  If not, write to
- *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "BatteryClientEfl.h"
-
-#if ENABLE(BATTERY_STATUS)
-
-#include "BatteryController.h"
-#include "EventNames.h"
-#include <E_Ukit.h>
-#include <limits>
-
-namespace WebCore {
-
-BatteryClientEfl::BatteryClientEfl()
-    : m_controller(0)
-    , m_timer(this, &BatteryClientEfl::timerFired)
-    , m_batteryStatusRefreshInterval(1.0)
-{
-}
-
-BatteryStatus* BatteryClientEfl::batteryStatus() const
-{
-    return m_batteryStatus.get();
-}
-
-void BatteryClientEfl::setController(BatteryController* controller)
-{
-    m_controller = controller;
-}
-
-void BatteryClientEfl::startUpdating()
-{
-    if (m_timer.isActive())
-        return;
-
-    if (!e_dbus_init())
-        return;
-
-    if (!e_ukit_init()) {
-        e_dbus_shutdown();
-        return;
-    }
-
-    m_timer.startRepeating(m_batteryStatusRefreshInterval);
-}
-
-void BatteryClientEfl::stopUpdating()
-{
-    m_timer.stop();
-    e_ukit_shutdown();
-    e_dbus_shutdown();
-}
-
-void BatteryClientEfl::batteryControllerDestroyed()
-{
-    delete this;
-}
-
-void BatteryClientEfl::setBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus> batteryStatus)
-{
-    m_batteryStatus = batteryStatus;
-    m_controller->didChangeBatteryStatus(eventType, m_batteryStatus);
-}
-
-void BatteryClientEfl::timerFired(Timer<BatteryClientEfl>* timer)
-{
-    ASSERT_UNUSED(timer, timer == &m_timer);
-    E_DBus_Connection* edbusConnection = e_dbus_bus_get(DBUS_BUS_SYSTEM);
-    if (edbusConnection)
-        e_upower_get_all_devices(edbusConnection, getBatteryStatus, static_cast<void*>(this));
-}
-
-void BatteryClientEfl::getBatteryStatus(void* data, void* replyData, DBusError* dBusError)
-{
-    E_Ukit_Get_All_Devices_Return* eukitDeviceNames = static_cast<E_Ukit_Get_All_Devices_Return*>(replyData);
-    if (!eukitDeviceNames || !eukitDeviceNames->strings || dbus_error_is_set(dBusError)) {
-         dbus_error_free(dBusError);
-         return;
-    }
-
-    E_DBus_Connection* edbusConnection = e_dbus_bus_get(DBUS_BUS_SYSTEM);
-    Eina_List* list;
-    void* deviceName;
-    EINA_LIST_FOREACH(eukitDeviceNames->strings, list, deviceName)
-        e_upower_get_all_properties(edbusConnection, static_cast<char*>(deviceName), setBatteryClient, data);
-}
-
-void BatteryClientEfl::setBatteryClient(void* data, void* replyData, DBusError* dBusError)
-{
-    E_Ukit_Get_All_Properties_Return* eukitPropertyNames = static_cast<E_Ukit_Get_All_Properties_Return*>(replyData);
-
-    if (!eukitPropertyNames || dbus_error_is_set(dBusError)) {
-        dbus_error_free(dBusError);
-        return;
-    }
-
-    if (!eukitPropertyNames->properties)
-        return;
-
-    E_Ukit_Property* property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "Type"));
-    if (!property || property->val.u != E_UPOWER_SOURCE_BATTERY)
-        return;
-
-    BatteryClientEfl* client = static_cast<BatteryClientEfl*>(data);
-    BatteryStatus* clientBatteryStatus = client->batteryStatus();
-    bool charging = false;
-    bool chargingChanged = false;
-    static unsigned chargingState = 0;
-
-    property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "State"));
-    if (!property)
-        return;
-    if (!clientBatteryStatus || chargingState != property->val.u) {
-        chargingChanged = true;
-        chargingState = property->val.u;
-        (chargingState == E_UPOWER_STATE_FULL || chargingState == E_UPOWER_STATE_CHARGING) ? charging = true : charging = false;
-    } else
-        charging = clientBatteryStatus->charging();
-
-    bool chargingTimeChanged = false;
-    bool dischargingTimeChanged = false;
-    double chargingTime = std::numeric_limits<double>::infinity();
-    double dischargingTime = std::numeric_limits<double>::infinity();
-
-    if (charging) {
-        if (!clientBatteryStatus || clientBatteryStatus->dischargingTime() != std::numeric_limits<double>::infinity())
-            dischargingTimeChanged = true;
-        dischargingTime = std::numeric_limits<double>::infinity();
-        property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "TimeToFull"));
-        if (!property)
-            return;
-        if (!clientBatteryStatus || clientBatteryStatus->chargingTime() != property->val.x)
-            chargingTimeChanged = true;
-        chargingTime = property->val.x;
-    } else {
-        if (!clientBatteryStatus || clientBatteryStatus->chargingTime() != std::numeric_limits<double>::infinity())
-            chargingTimeChanged = true;
-        chargingTime = std::numeric_limits<double>::infinity();
-        property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "TimeToEmpty"));
-        if (!property)
-            return;
-        if (!clientBatteryStatus || clientBatteryStatus->dischargingTime() != property->val.x)
-            dischargingTimeChanged = true;
-        dischargingTime = property->val.x;
-    }
-
-    double level = 0;
-    bool levelChanged = false;
-
-    property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "Percentage"));
-    if (!property)
-        return;
-    if (!clientBatteryStatus || clientBatteryStatus->level() != property->val.d)
-        levelChanged = true;
-    level = property->val.d;
-
-    WTF::RefPtr<BatteryStatus> batteryStatus = BatteryStatus::create(charging, chargingTime, dischargingTime, level);
-    if (chargingChanged)
-        client->setBatteryStatus(eventNames().chargingchangeEvent, batteryStatus);
-    if (chargingTimeChanged)
-        client->setBatteryStatus(eventNames().chargingtimechangeEvent, batteryStatus);
-    if (dischargingTimeChanged)
-        client->setBatteryStatus(eventNames().dischargingtimechangeEvent, batteryStatus);
-    if (levelChanged)
-        client->setBatteryStatus(eventNames().levelchangeEvent, batteryStatus);
-}
-
-}
-
-#endif // BATTERY_STATUS
-

Deleted: trunk/Source/WebCore/platform/efl/BatteryClientEfl.h (122196 => 122197)


--- trunk/Source/WebCore/platform/efl/BatteryClientEfl.h	2012-07-10 05:55:48 UTC (rev 122196)
+++ trunk/Source/WebCore/platform/efl/BatteryClientEfl.h	2012-07-10 06:42:40 UTC (rev 122197)
@@ -1,64 +0,0 @@
-/*
- *  Copyright (C) 2012 Samsung Electronics
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Library General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU Library General Public License
- *  along with this library; see the file COPYING.LIB.  If not, write to
- *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- */
-
-#ifndef BatteryClientEfl_h
-#define BatteryClientEfl_h
-
-#if ENABLE(BATTERY_STATUS)
-
-#include "BatteryClient.h"
-#include "BatteryStatus.h"
-#include "Timer.h"
-#include <wtf/text/AtomicString.h>
-
-typedef struct DBusError DBusError;
-
-namespace WebCore {
-
-class BatteryController;
-
-class BatteryClientEfl : public BatteryClient {
-public:
-    BatteryClientEfl();
-    ~BatteryClientEfl() { };
-
-    virtual void setController(BatteryController*);
-    virtual void startUpdating();
-    virtual void stopUpdating();
-    virtual void batteryControllerDestroyed();
-
-    void setBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus>);
-    BatteryStatus* batteryStatus() const;
-
-private:
-    void timerFired(Timer<BatteryClientEfl>*);
-    static void getBatteryStatus(void* data, void* replyData, DBusError*);
-    static void setBatteryClient(void* data, void* replyData, DBusError*);
-
-    BatteryController* m_controller;
-    Timer<BatteryClientEfl> m_timer;
-    RefPtr<BatteryStatus> m_batteryStatus;
-    const double m_batteryStatusRefreshInterval;
-};
-
-}
-
-#endif // ENABLE(BATTERY_STATUS)
-#endif // BatteryClientEfl_h
-

Copied: trunk/Source/WebCore/platform/efl/BatteryProviderEfl.cpp (from rev 122196, trunk/Source/WebCore/platform/efl/BatteryClientEfl.cpp) (0 => 122197)


--- trunk/Source/WebCore/platform/efl/BatteryProviderEfl.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/efl/BatteryProviderEfl.cpp	2012-07-10 06:42:40 UTC (rev 122197)
@@ -0,0 +1,179 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "BatteryProviderEfl.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryProviderEflClient.h"
+#include "EventNames.h"
+#include <E_Ukit.h>
+#include <limits>
+
+namespace WebCore {
+
+BatteryProviderEfl::BatteryProviderEfl(BatteryProviderEflClient* client)
+    : m_client(client)
+    , m_timer(this, &BatteryProviderEfl::timerFired)
+    , m_batteryStatusRefreshInterval(1.0)
+{
+}
+
+BatteryStatus* BatteryProviderEfl::batteryStatus() const
+{
+    return m_batteryStatus.get();
+}
+
+void BatteryProviderEfl::startUpdating()
+{
+    if (m_timer.isActive())
+        return;
+
+    if (!e_dbus_init())
+        return;
+
+    if (!e_ukit_init()) {
+        e_dbus_shutdown();
+        return;
+    }
+
+    m_timer.startRepeating(m_batteryStatusRefreshInterval);
+}
+
+void BatteryProviderEfl::stopUpdating()
+{
+    m_timer.stop();
+    e_ukit_shutdown();
+    e_dbus_shutdown();
+}
+
+void BatteryProviderEfl::setBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus> batteryStatus)
+{
+    m_batteryStatus = batteryStatus;
+    m_client->didChangeBatteryStatus(eventType, m_batteryStatus);
+}
+
+void BatteryProviderEfl::timerFired(Timer<BatteryProviderEfl>* timer)
+{
+    ASSERT_UNUSED(timer, timer == &m_timer);
+    E_DBus_Connection* edbusConnection = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+    if (edbusConnection)
+        e_upower_get_all_devices(edbusConnection, getBatteryStatus, static_cast<void*>(this));
+}
+
+void BatteryProviderEfl::getBatteryStatus(void* data, void* replyData, DBusError* dBusError)
+{
+    E_Ukit_Get_All_Devices_Return* eukitDeviceNames = static_cast<E_Ukit_Get_All_Devices_Return*>(replyData);
+    if (!eukitDeviceNames || !eukitDeviceNames->strings || dbus_error_is_set(dBusError)) {
+         dbus_error_free(dBusError);
+         return;
+    }
+
+    E_DBus_Connection* edbusConnection = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+    Eina_List* list;
+    void* deviceName;
+    EINA_LIST_FOREACH(eukitDeviceNames->strings, list, deviceName)
+        e_upower_get_all_properties(edbusConnection, static_cast<char*>(deviceName), setBatteryClient, data);
+}
+
+void BatteryProviderEfl::setBatteryClient(void* data, void* replyData, DBusError* dBusError)
+{
+    E_Ukit_Get_All_Properties_Return* eukitPropertyNames = static_cast<E_Ukit_Get_All_Properties_Return*>(replyData);
+
+    if (!eukitPropertyNames || dbus_error_is_set(dBusError)) {
+        dbus_error_free(dBusError);
+        return;
+    }
+
+    if (!eukitPropertyNames->properties)
+        return;
+
+    E_Ukit_Property* property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "Type"));
+    if (!property || property->val.u != E_UPOWER_SOURCE_BATTERY)
+        return;
+
+    BatteryProviderEfl* client = static_cast<BatteryProviderEfl*>(data);
+    BatteryStatus* clientBatteryStatus = client->batteryStatus();
+    bool charging = false;
+    bool chargingChanged = false;
+    static unsigned chargingState = 0;
+
+    property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "State"));
+    if (!property)
+        return;
+    if (!clientBatteryStatus || chargingState != property->val.u) {
+        chargingChanged = true;
+        chargingState = property->val.u;
+        (chargingState == E_UPOWER_STATE_FULL || chargingState == E_UPOWER_STATE_CHARGING) ? charging = true : charging = false;
+    } else
+        charging = clientBatteryStatus->charging();
+
+    bool chargingTimeChanged = false;
+    bool dischargingTimeChanged = false;
+    double chargingTime = std::numeric_limits<double>::infinity();
+    double dischargingTime = std::numeric_limits<double>::infinity();
+
+    if (charging) {
+        if (!clientBatteryStatus || clientBatteryStatus->dischargingTime() != std::numeric_limits<double>::infinity())
+            dischargingTimeChanged = true;
+        dischargingTime = std::numeric_limits<double>::infinity();
+        property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "TimeToFull"));
+        if (!property)
+            return;
+        if (!clientBatteryStatus || clientBatteryStatus->chargingTime() != property->val.x)
+            chargingTimeChanged = true;
+        chargingTime = property->val.x;
+    } else {
+        if (!clientBatteryStatus || clientBatteryStatus->chargingTime() != std::numeric_limits<double>::infinity())
+            chargingTimeChanged = true;
+        chargingTime = std::numeric_limits<double>::infinity();
+        property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "TimeToEmpty"));
+        if (!property)
+            return;
+        if (!clientBatteryStatus || clientBatteryStatus->dischargingTime() != property->val.x)
+            dischargingTimeChanged = true;
+        dischargingTime = property->val.x;
+    }
+
+    double level = 0;
+    bool levelChanged = false;
+
+    property = static_cast<E_Ukit_Property*>(eina_hash_find(eukitPropertyNames->properties, "Percentage"));
+    if (!property)
+        return;
+    if (!clientBatteryStatus || clientBatteryStatus->level() != property->val.d)
+        levelChanged = true;
+    level = property->val.d;
+
+    WTF::RefPtr<BatteryStatus> batteryStatus = BatteryStatus::create(charging, chargingTime, dischargingTime, level);
+    if (chargingChanged)
+        client->setBatteryStatus(eventNames().chargingchangeEvent, batteryStatus);
+    if (chargingTimeChanged)
+        client->setBatteryStatus(eventNames().chargingtimechangeEvent, batteryStatus);
+    if (dischargingTimeChanged)
+        client->setBatteryStatus(eventNames().dischargingtimechangeEvent, batteryStatus);
+    if (levelChanged)
+        client->setBatteryStatus(eventNames().levelchangeEvent, batteryStatus);
+}
+
+}
+
+#endif // BATTERY_STATUS
+

Copied: trunk/Source/WebCore/platform/efl/BatteryProviderEfl.h (from rev 122196, trunk/Source/WebCore/platform/efl/BatteryClientEfl.h) (0 => 122197)


--- trunk/Source/WebCore/platform/efl/BatteryProviderEfl.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/efl/BatteryProviderEfl.h	2012-07-10 06:42:40 UTC (rev 122197)
@@ -0,0 +1,62 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BatteryProviderEfl_h
+#define BatteryProviderEfl_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryClient.h"
+#include "BatteryStatus.h"
+#include "Timer.h"
+#include <wtf/text/AtomicString.h>
+
+typedef struct DBusError DBusError;
+
+namespace WebCore {
+
+class BatteryProviderEflClient;
+
+class BatteryProviderEfl {
+public:
+    BatteryProviderEfl(BatteryProviderEflClient*);
+    ~BatteryProviderEfl() { }
+
+    virtual void startUpdating();
+    virtual void stopUpdating();
+
+    void setBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus>);
+    BatteryStatus* batteryStatus() const;
+
+private:
+    void timerFired(Timer<BatteryProviderEfl>*);
+    static void getBatteryStatus(void* data, void* replyData, DBusError*);
+    static void setBatteryClient(void* data, void* replyData, DBusError*);
+
+    BatteryProviderEflClient* m_client;
+    Timer<BatteryProviderEfl> m_timer;
+    RefPtr<BatteryStatus> m_batteryStatus;
+    const double m_batteryStatusRefreshInterval;
+};
+
+}
+
+#endif // ENABLE(BATTERY_STATUS)
+#endif // BatteryProviderEfl_h
+

Added: trunk/Source/WebCore/platform/efl/BatteryProviderEflClient.h (0 => 122197)


--- trunk/Source/WebCore/platform/efl/BatteryProviderEflClient.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/efl/BatteryProviderEflClient.h	2012-07-10 06:42:40 UTC (rev 122197)
@@ -0,0 +1,40 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics.  All rights reserved.
+ *  Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BatteryProviderEflClient_h
+#define BatteryProviderEflClient_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryStatus.h"
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+class BatteryProviderEflClient {
+public:
+    virtual void didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus>) = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(BATTERY_STATUS)
+
+#endif // BatteryProviderEflClient_h

Modified: trunk/Source/WebKit/ChangeLog (122196 => 122197)


--- trunk/Source/WebKit/ChangeLog	2012-07-10 05:55:48 UTC (rev 122196)
+++ trunk/Source/WebKit/ChangeLog	2012-07-10 06:42:40 UTC (rev 122197)
@@ -1,3 +1,14 @@
+2012-07-09  Christophe Dumez  <[email protected]>
+
+        [EFL] Battery status code needs refactoring to be reused in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=90760
+
+        Reviewed by Hajime Morita.
+
+        Add BatteryClientEfl to PlatformEfl.cmake.
+
+        * PlatformEfl.cmake:
+
 2012-07-08  Kihong Kwon  <[email protected]>
 
         [EFL] Change notifications directory path of WebKit_INCLUDE_DIRECTORIES in the PlatformEfl.cmake

Modified: trunk/Source/WebKit/PlatformEfl.cmake (122196 => 122197)


--- trunk/Source/WebKit/PlatformEfl.cmake	2012-07-10 05:55:48 UTC (rev 122196)
+++ trunk/Source/WebKit/PlatformEfl.cmake	2012-07-10 06:42:40 UTC (rev 122197)
@@ -91,6 +91,7 @@
 
 LIST(APPEND WebKit_SOURCES
     efl/WebCoreSupport/AssertMatchingEnums.cpp
+    efl/WebCoreSupport/BatteryClientEfl.cpp
     efl/WebCoreSupport/ChromeClientEfl.cpp
     efl/WebCoreSupport/DeviceOrientationClientEfl.cpp
     efl/WebCoreSupport/DeviceMotionClientEfl.cpp

Modified: trunk/Source/WebKit/efl/ChangeLog (122196 => 122197)


--- trunk/Source/WebKit/efl/ChangeLog	2012-07-10 05:55:48 UTC (rev 122196)
+++ trunk/Source/WebKit/efl/ChangeLog	2012-07-10 06:42:40 UTC (rev 122197)
@@ -1,3 +1,27 @@
+2012-07-09  Christophe Dumez  <[email protected]>
+
+        [EFL] Battery status code needs refactoring to be reused in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=90760
+
+        Reviewed by Hajime Morita.
+
+        Add BatteryClientEfl to WebKit, which uses BatteryProviderEfl from
+        WebCore internally.
+
+        * WebCoreSupport/BatteryClientEfl.cpp: Added.
+        (BatteryClientEfl::BatteryClientEfl):
+        (BatteryClientEfl::setController):
+        (BatteryClientEfl::startUpdating):
+        (BatteryClientEfl::stopUpdating):
+        (BatteryClientEfl::batteryControllerDestroyed):
+        (BatteryClientEfl::didChangeBatteryStatus):
+        * WebCoreSupport/BatteryClientEfl.h: Renamed from Source/WebCore/platform/efl/BatteryClientEfl.h.
+        (WebCore):
+        (BatteryClientEfl):
+        (BatteryClientEfl::~BatteryClientEfl):
+        * ewk/ewk_view.cpp:
+        (_ewk_view_priv_new):
+
 2012-07-09  Adam Klein  <[email protected]>
 
         Rename WebCore::WebKitMutationObserver to WebCore::MutationObserver

Added: trunk/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.cpp (0 => 122197)


--- trunk/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.cpp	                        (rev 0)
+++ trunk/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.cpp	2012-07-10 06:42:40 UTC (rev 122197)
@@ -0,0 +1,60 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics.  All rights reserved.
+ *  Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "BatteryClientEfl.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryController.h"
+
+BatteryClientEfl::BatteryClientEfl()
+    : m_controller(0)
+    , m_provider(this)
+{
+}
+
+void BatteryClientEfl::setController(WebCore::BatteryController* controller)
+{
+    m_controller = controller;
+}
+
+void BatteryClientEfl::startUpdating()
+{
+    m_provider.startUpdating();
+}
+
+void BatteryClientEfl::stopUpdating()
+{
+    m_provider.stopUpdating();
+}
+
+void BatteryClientEfl::batteryControllerDestroyed()
+{
+    delete this;
+}
+
+void BatteryClientEfl::didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<WebCore::BatteryStatus> status)
+{
+    ASSERT(m_controller);
+    m_controller->didChangeBatteryStatus(eventType, status);
+}
+
+#endif // ENABLE(BATTERY_STATUS)

Copied: trunk/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.h (from rev 122196, trunk/Source/WebCore/platform/efl/BatteryClientEfl.h) (0 => 122197)


--- trunk/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.h	                        (rev 0)
+++ trunk/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.h	2012-07-10 06:42:40 UTC (rev 122197)
@@ -0,0 +1,57 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics.  All rights reserved.
+ *  Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BatteryClientEfl_h
+#define BatteryClientEfl_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryClient.h"
+#include "BatteryProviderEfl.h"
+#include "BatteryProviderEflClient.h"
+#include "BatteryStatus.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+class BatteryController;
+}
+
+class BatteryClientEfl : public WebCore::BatteryClient, public WebCore::BatteryProviderEflClient {
+public:
+    BatteryClientEfl();
+    virtual ~BatteryClientEfl() { }
+
+    // BatteryClient interface.
+    virtual void setController(WebCore::BatteryController*);
+    virtual void startUpdating();
+    virtual void stopUpdating();
+    virtual void batteryControllerDestroyed();
+
+private:
+    // BatteryProviderEflClient interface.
+    virtual void didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<WebCore::BatteryStatus>);
+
+    WebCore::BatteryController* m_controller;
+    WebCore::BatteryProviderEfl m_provider;
+};
+
+#endif // ENABLE(BATTERY_STATUS)
+
+#endif // BatteryClientEfl_h

Modified: trunk/Source/WebKit/efl/ewk/ewk_view.cpp (122196 => 122197)


--- trunk/Source/WebKit/efl/ewk/ewk_view.cpp	2012-07-10 05:55:48 UTC (rev 122196)
+++ trunk/Source/WebKit/efl/ewk/ewk_view.cpp	2012-07-10 06:42:40 UTC (rev 122197)
@@ -754,7 +754,7 @@
 #endif
 
 #if ENABLE(BATTERY_STATUS)
-    WebCore::provideBatteryTo(priv->page.get(), new WebCore::BatteryClientEfl);
+    WebCore::provideBatteryTo(priv->page.get(), new BatteryClientEfl);
 #endif
 
     priv->pageSettings = priv->page->settings();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to