[EFL][WK2] Use C API inside BatteryProvider and NetworkInfoProvider
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Feb 2013 17:09:32 +0000 (17:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Feb 2013 17:09:32 +0000 (17:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107821

Patch by Sudarsana Nagineni <sudarsana.nagineni@intel.com> on 2013-02-15
Reviewed by Anders Carlsson.

BatteryProvider and NetworkInfoProvider should use C API
instead of accessing the internal C++ classes directly.

* UIProcess/API/efl/ewk_context.cpp:
(EwkContext::EwkContext):
* UIProcess/efl/BatteryProvider.cpp:
(BatteryProvider::~BatteryProvider):
(BatteryProvider::create):
(BatteryProvider::BatteryProvider):
(BatteryProvider::didChangeBatteryStatus):
* UIProcess/efl/BatteryProvider.h:
(BatteryProvider):
* UIProcess/efl/NetworkInfoProvider.cpp:
(NetworkInfoProvider::create):
(NetworkInfoProvider::NetworkInfoProvider):
(NetworkInfoProvider::~NetworkInfoProvider):
* UIProcess/efl/NetworkInfoProvider.h:
(NetworkInfoProvider):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143008 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
Source/WebKit2/UIProcess/efl/BatteryProvider.cpp
Source/WebKit2/UIProcess/efl/BatteryProvider.h
Source/WebKit2/UIProcess/efl/NetworkInfoProvider.cpp
Source/WebKit2/UIProcess/efl/NetworkInfoProvider.h

index 4e4fbb45bc2c6092e8d961d25b0f20664fd3657d..30717aa20554d18ece5d5f6417e2918bbdf96e36 100644 (file)
@@ -1,3 +1,29 @@
+2013-02-15  Sudarsana Nagineni  <sudarsana.nagineni@intel.com>
+
+        [EFL][WK2] Use C API inside BatteryProvider and NetworkInfoProvider
+        https://bugs.webkit.org/show_bug.cgi?id=107821
+
+        Reviewed by Anders Carlsson.
+
+        BatteryProvider and NetworkInfoProvider should use C API
+        instead of accessing the internal C++ classes directly.
+
+        * UIProcess/API/efl/ewk_context.cpp:
+        (EwkContext::EwkContext):
+        * UIProcess/efl/BatteryProvider.cpp:
+        (BatteryProvider::~BatteryProvider):
+        (BatteryProvider::create):
+        (BatteryProvider::BatteryProvider):
+        (BatteryProvider::didChangeBatteryStatus):
+        * UIProcess/efl/BatteryProvider.h:
+        (BatteryProvider):
+        * UIProcess/efl/NetworkInfoProvider.cpp:
+        (NetworkInfoProvider::create):
+        (NetworkInfoProvider::NetworkInfoProvider):
+        (NetworkInfoProvider::~NetworkInfoProvider):
+        * UIProcess/efl/NetworkInfoProvider.h:
+        (NetworkInfoProvider):
+
 2013-02-15  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
 
         [WK2][EFL]REGRESSION (r141978): ewk_view_type_check api test failing
index 31b65d74da8b645c22d560b3aec6fb8fd330b677..abf96b4a2d8f6b43e9eb1e7084b86b8cf9ef6887 100644 (file)
@@ -30,6 +30,7 @@
 #include "WKContextSoup.h"
 #include "WKNumber.h"
 #include "WKString.h"
+#include "WebContext.h"
 #include "WebIconDatabase.h"
 #include "ewk_context_private.h"
 #include "ewk_cookie_manager_private.h"
@@ -64,10 +65,10 @@ EwkContext::EwkContext(WKContextRef context)
     , m_databaseManager(EwkDatabaseManager::create(WKContextGetDatabaseManager(context)))
     , m_storageManager(EwkStorageManager::create(WKContextGetKeyValueStorageManager(context)))
 #if ENABLE(BATTERY_STATUS)
-    , m_batteryProvider(BatteryProvider::create(toImpl(context)))
+    , m_batteryProvider(BatteryProvider::create(context))
 #endif
 #if ENABLE(NETWORK_INFO)
-    , m_networkInfoProvider(NetworkInfoProvider::create(toImpl(context)))
+    , m_networkInfoProvider(NetworkInfoProvider::create(context))
 #endif
     , m_downloadManager(DownloadManagerEfl::create(context))
     , m_requestManagerClient(RequestManagerClientEfl::create(context))
index 96346317f84e07747d8864fd5e40908d32ab2161..52b14eb12ad14f1268faa43fab439aa59daa3efd 100644 (file)
@@ -30,9 +30,7 @@
 
 #include "WKAPICast.h"
 #include "WKBatteryManager.h"
-#include "WebBatteryManagerProxy.h"
-#include "WebBatteryStatus.h"
-#include "WebContext.h"
+#include "WKBatteryStatus.h"
 
 using namespace WebCore;
 using namespace WebKit;
@@ -56,21 +54,20 @@ BatteryProvider::~BatteryProvider()
 {
     m_provider.stopUpdating();
 
-    ASSERT(m_context->batteryManagerProxy());
-    m_context->batteryManagerProxy()->initializeProvider(0);
+    WKBatteryManagerSetProvider(m_batteryManager.get(), 0);
 }
 
-PassRefPtr<BatteryProvider> BatteryProvider::create(PassRefPtr<WebContext> context)
+PassRefPtr<BatteryProvider> BatteryProvider::create(WKContextRef context)
 {
     ASSERT(context);
     return adoptRef(new BatteryProvider(context));
 }
 
-BatteryProvider::BatteryProvider(PassRefPtr<WebContext> context)
-    : m_context(context)
+BatteryProvider::BatteryProvider(WKContextRef context)
+    : m_batteryManager(WKContextGetBatteryManager(context))
     , m_provider(this)
 {
-    ASSERT(m_context);
+    ASSERT(m_batteryManager);
 
     WKBatteryProvider wkBatteryProvider = {
         kWKBatteryProviderCurrentVersion,
@@ -79,8 +76,7 @@ BatteryProvider::BatteryProvider(PassRefPtr<WebContext> context)
         stopUpdatingCallback
     };
 
-    ASSERT(m_context->batteryManagerProxy());
-    m_context->batteryManagerProxy()->initializeProvider(&wkBatteryProvider);
+    WKBatteryManagerSetProvider(m_batteryManager.get(), &wkBatteryProvider);
 }
 
 void BatteryProvider::startUpdating()
@@ -95,9 +91,8 @@ void BatteryProvider::stopUpdating()
 
 void BatteryProvider::didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus> status)
 {
-    RefPtr<WebBatteryStatus> batteryStatus = WebBatteryStatus::create(status->charging(), status->chargingTime(), status->dischargingTime(), status->level());
+    WKRetainPtr<WKBatteryStatusRef> wkBatteryStatus = adoptWK(WKBatteryStatusCreate(status->charging(), status->chargingTime(), status->dischargingTime(), status->level()));
 
-    ASSERT(m_context->batteryManagerProxy());
-    m_context->batteryManagerProxy()->providerDidChangeBatteryStatus(eventType, batteryStatus.get());
+    WKBatteryManagerProviderDidChangeBatteryStatus(m_batteryManager.get(), toAPI(eventType.impl()), wkBatteryStatus.get());
 }
 #endif // ENABLE(BATTERY_STATUS)
index d76336cd23f682c29058165bd335ab3d8c524015..893d0f8ea4ed707d94f8d7cdf40cf0b59d847ca8 100644 (file)
@@ -31,8 +31,8 @@
 #include "BatteryProviderEfl.h"
 #include "BatteryProviderEflClient.h"
 #include "BatteryStatus.h"
-#include "WebContext.h"
 #include <WebKit2/WKBase.h>
+#include <WebKit2/WKRetainPtr.h>
 #include <wtf/PassRefPtr.h>
 
 namespace WebKit {
@@ -40,18 +40,18 @@ namespace WebKit {
 class BatteryProvider : public RefCounted<BatteryProvider>, public WebCore::BatteryProviderEflClient {
 public:
     virtual ~BatteryProvider();
-    static PassRefPtr<BatteryProvider> create(PassRefPtr<WebContext>);
+    static PassRefPtr<BatteryProvider> create(WKContextRef);
 
     void startUpdating();
     void stopUpdating();
 
 private:
-    explicit BatteryProvider(PassRefPtr<WebContext>);
+    explicit BatteryProvider(WKContextRef);
 
     // BatteryProviderEflClient interface.
     virtual void didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<WebCore::BatteryStatus>);
 
-    RefPtr<WebContext> m_context;
+    WKRetainPtr<WKBatteryManagerRef> m_batteryManager;
     WebCore::BatteryProviderEfl m_provider;
 };
 
index 4a4621b7082ef0c259349b081ad8e6f338a7d76c..de7f05f533aea5af5b716b990006182ad8ad1a8b 100644 (file)
@@ -29,8 +29,6 @@
 #if ENABLE(NETWORK_INFO)
 
 #include "WKNetworkInfoManager.h"
-#include "WebContext.h"
-#include "WebNetworkInfoManagerProxy.h"
 #include <NotImplemented.h>
 
 using namespace WebKit;
@@ -60,16 +58,19 @@ static bool isMeteredCallback(WKNetworkInfoManagerRef, const void* clientInfo)
     return toNetworkInfoProvider(clientInfo)->metered();
 }
 
-PassRefPtr<NetworkInfoProvider> NetworkInfoProvider::create(PassRefPtr<WebContext> context)
+PassRefPtr<NetworkInfoProvider> NetworkInfoProvider::create(WKContextRef context)
 {
     return adoptRef(new NetworkInfoProvider(context));
 }
 
-NetworkInfoProvider::NetworkInfoProvider(PassRefPtr<WebContext> context)
+NetworkInfoProvider::NetworkInfoProvider(WKContextRef context)
     : m_context(context)
 {
     ASSERT(m_context);
 
+    WKNetworkInfoManagerRef wkNetworkInfoManager = WKContextGetNetworkInfoManager(m_context.get());
+    ASSERT(wkNetworkInfoManager);
+
     WKNetworkInfoProvider wkNetworkInfoProvider = {
         kWKNetworkInfoProviderCurrentVersion,
         this, // clientInfo
@@ -79,14 +80,15 @@ NetworkInfoProvider::NetworkInfoProvider(PassRefPtr<WebContext> context)
         isMeteredCallback
     };
 
-    ASSERT(m_context->networkInfoManagerProxy());
-    m_context->networkInfoManagerProxy()->initializeProvider(&wkNetworkInfoProvider);
+    WKNetworkInfoManagerSetProvider(wkNetworkInfoManager, &wkNetworkInfoProvider);
 }
 
 NetworkInfoProvider::~NetworkInfoProvider()
 {
-    ASSERT(m_context->networkInfoManagerProxy());
-    m_context->networkInfoManagerProxy()->initializeProvider(0);
+    WKNetworkInfoManagerRef wkNetworkInfoManager = WKContextGetNetworkInfoManager(m_context.get());
+    ASSERT(wkNetworkInfoManager);
+
+    WKNetworkInfoManagerSetProvider(wkNetworkInfoManager, 0);
 }
 
 void NetworkInfoProvider::networkInfoControllerDestroyed()
index 89bf96e28e927bf1f610a71a7c79dbc833f0ce00..bf72384aac10f6e7c691369e4985a74451fa8523 100644 (file)
 
 #if ENABLE(NETWORK_INFO)
 
-#include "WebContext.h"
 #include <NetworkInfoClient.h>
 #include <NetworkInfoProviderEfl.h>
 #include <WebKit2/WKBase.h>
+#include <WebKit2/WKContext.h>
 #include <WebKit2/WKRetainPtr.h>
 #include <wtf/PassRefPtr.h>
 
@@ -40,7 +40,7 @@ namespace WebKit {
 class NetworkInfoProvider : public RefCounted<NetworkInfoProvider>, public WebCore::NetworkInfoClient {
 public:
     virtual ~NetworkInfoProvider();
-    static PassRefPtr<NetworkInfoProvider> create(PassRefPtr<WebContext>);
+    static PassRefPtr<NetworkInfoProvider> create(WKContextRef);
 
     // NetworkInfoClient interface.
     virtual void networkInfoControllerDestroyed();
@@ -52,9 +52,9 @@ public:
     virtual void stopUpdating();
 
 private:
-    explicit NetworkInfoProvider(PassRefPtr<WebContext>);
+    explicit NetworkInfoProvider(WKContextRef);
 
-    RefPtr<WebContext> m_context;
+    WKRetainPtr<WKContextRef> m_context;
     WebCore::NetworkInfoProviderEfl m_provider;
 };