Commit 383c3b01 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

[EFL] Battery status code needs refactoring to be reused in WebKit2

https://bugs.webkit.org/show_bug.cgi?id=90760

Patch by Christophe Dumez <christophe.dumez@intel.com> 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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@122197 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ccdf2515
2012-07-09 Christophe Dumez <christophe.dumez@intel.com>
[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 <hayato@chromium.org>
 
Unreviewed gardening.
......@@ -23,7 +23,7 @@ LIST(APPEND WebCore_SOURCES
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
......
......@@ -18,35 +18,30 @@
*/
#include "config.h"
#include "BatteryClientEfl.h"
#include "BatteryProviderEfl.h"
#if ENABLE(BATTERY_STATUS)
#include "BatteryController.h"
#include "BatteryProviderEflClient.h"
#include "EventNames.h"
#include <E_Ukit.h>
#include <limits>
namespace WebCore {
BatteryClientEfl::BatteryClientEfl()
: m_controller(0)
, m_timer(this, &BatteryClientEfl::timerFired)
BatteryProviderEfl::BatteryProviderEfl(BatteryProviderEflClient* client)
: m_client(client)
, m_timer(this, &BatteryProviderEfl::timerFired)
, m_batteryStatusRefreshInterval(1.0)
{
}
BatteryStatus* BatteryClientEfl::batteryStatus() const
BatteryStatus* BatteryProviderEfl::batteryStatus() const
{
return m_batteryStatus.get();
}
void BatteryClientEfl::setController(BatteryController* controller)
{
m_controller = controller;
}
void BatteryClientEfl::startUpdating()
void BatteryProviderEfl::startUpdating()
{
if (m_timer.isActive())
return;
......@@ -62,25 +57,20 @@ void BatteryClientEfl::startUpdating()
m_timer.startRepeating(m_batteryStatusRefreshInterval);
}
void BatteryClientEfl::stopUpdating()
void BatteryProviderEfl::stopUpdating()
{
m_timer.stop();
e_ukit_shutdown();
e_dbus_shutdown();
}
void BatteryClientEfl::batteryControllerDestroyed()
{
delete this;
}
void BatteryClientEfl::setBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus> batteryStatus)
void BatteryProviderEfl::setBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus> batteryStatus)
{
m_batteryStatus = batteryStatus;
m_controller->didChangeBatteryStatus(eventType, m_batteryStatus);
m_client->didChangeBatteryStatus(eventType, m_batteryStatus);
}
void BatteryClientEfl::timerFired(Timer<BatteryClientEfl>* timer)
void BatteryProviderEfl::timerFired(Timer<BatteryProviderEfl>* timer)
{
ASSERT_UNUSED(timer, timer == &m_timer);
E_DBus_Connection* edbusConnection = e_dbus_bus_get(DBUS_BUS_SYSTEM);
......@@ -88,7 +78,7 @@ void BatteryClientEfl::timerFired(Timer<BatteryClientEfl>* timer)
e_upower_get_all_devices(edbusConnection, getBatteryStatus, static_cast<void*>(this));
}
void BatteryClientEfl::getBatteryStatus(void* data, void* replyData, DBusError* dBusError)
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)) {
......@@ -103,7 +93,7 @@ void BatteryClientEfl::getBatteryStatus(void* data, void* replyData, DBusError*
e_upower_get_all_properties(edbusConnection, static_cast<char*>(deviceName), setBatteryClient, data);
}
void BatteryClientEfl::setBatteryClient(void* data, void* replyData, DBusError* dBusError)
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);
......@@ -119,7 +109,7 @@ void BatteryClientEfl::setBatteryClient(void* data, void* replyData, DBusError*
if (!property || property->val.u != E_UPOWER_SOURCE_BATTERY)
return;
BatteryClientEfl* client = static_cast<BatteryClientEfl*>(data);
BatteryProviderEfl* client = static_cast<BatteryProviderEfl*>(data);
BatteryStatus* clientBatteryStatus = client->batteryStatus();
bool charging = false;
bool chargingChanged = false;
......
......@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef BatteryClientEfl_h
#define BatteryClientEfl_h
#ifndef BatteryProviderEfl_h
#define BatteryProviderEfl_h
#if ENABLE(BATTERY_STATUS)
......@@ -31,28 +31,26 @@ typedef struct DBusError DBusError;
namespace WebCore {
class BatteryController;
class BatteryProviderEflClient;
class BatteryClientEfl : public BatteryClient {
class BatteryProviderEfl {
public:
BatteryClientEfl();
~BatteryClientEfl() { };
BatteryProviderEfl(BatteryProviderEflClient*);
~BatteryProviderEfl() { }
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>*);
void timerFired(Timer<BatteryProviderEfl>*);
static void getBatteryStatus(void* data, void* replyData, DBusError*);
static void setBatteryClient(void* data, void* replyData, DBusError*);
BatteryController* m_controller;
Timer<BatteryClientEfl> m_timer;
BatteryProviderEflClient* m_client;
Timer<BatteryProviderEfl> m_timer;
RefPtr<BatteryStatus> m_batteryStatus;
const double m_batteryStatusRefreshInterval;
};
......@@ -60,5 +58,5 @@ private:
}
#endif // ENABLE(BATTERY_STATUS)
#endif // BatteryClientEfl_h
#endif // BatteryProviderEfl_h
/*
* 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
2012-07-09 Christophe Dumez <christophe.dumez@intel.com>
[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 <kihong.kwon@samsung.com>
[EFL] Change notifications directory path of WebKit_INCLUDE_DIRECTORIES in the PlatformEfl.cmake
......
......@@ -91,6 +91,7 @@ ENDIF ()
LIST(APPEND WebKit_SOURCES
efl/WebCoreSupport/AssertMatchingEnums.cpp
efl/WebCoreSupport/BatteryClientEfl.cpp
efl/WebCoreSupport/ChromeClientEfl.cpp
efl/WebCoreSupport/DeviceOrientationClientEfl.cpp
efl/WebCoreSupport/DeviceMotionClientEfl.cpp
......
2012-07-09 Christophe Dumez <christophe.dumez@intel.com>
[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 <adamk@chromium.org>
Rename WebCore::WebKitMutationObserver to WebCore::MutationObserver
......
/*
* 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)
/*
* 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
......@@ -754,7 +754,7 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
#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();
......
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