[WK2] Add C API for Network Information API
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 21:22:00 +0000 (21:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 21:22:00 +0000 (21:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90762

Patch by Christophe Dumez <christophe.dumez@intel.com> on 2012-07-18
Reviewed by Kenneth Rohde Christiansen.

Add C API for WKNetworkInfo and WKNetworkInfoManager
so that they can be used by the client.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* UIProcess/API/C/WKContext.cpp:
(WKContextGetNetworkInfoManager):
* UIProcess/API/C/WKContext.h:
* UIProcess/API/C/WKNetworkInfo.cpp: Copied from Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.cpp.
(WKNetworkInfoGetTypeID):
(WKNetworkInfoCreate):
* UIProcess/API/C/WKNetworkInfo.h: Copied from Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.cpp.
* UIProcess/API/C/WKNetworkInfoManager.cpp:
(WKNetworkInfoManagerSetProvider):
(WKNetworkInfoManagerProviderDidChangeNetworkInformation):
* UIProcess/API/C/WKNetworkInfoManager.h:

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

Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.list.am
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/API/C/WKContext.h
Source/WebKit2/UIProcess/API/C/WKNetworkInfo.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKNetworkInfo.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.cpp
Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.h

index c8d1c35..04cc719 100644 (file)
@@ -298,6 +298,7 @@ SET(WebKit2_SOURCES
     UIProcess/API/C/WKKeyValueStorageManager.cpp
     UIProcess/API/C/WKMediaCacheManager.cpp
     UIProcess/API/C/WKNavigationData.cpp
+    UIProcess/API/C/WKNetworkInfo.cpp
     UIProcess/API/C/WKNetworkInfoManager.cpp
     UIProcess/API/C/WKNotification.cpp
     UIProcess/API/C/WKNotificationManager.cpp
index 8493f53..f6ee5e5 100644 (file)
@@ -1,5 +1,30 @@
 2012-07-18  Christophe Dumez  <christophe.dumez@intel.com>
 
+        [WK2] Add C API for Network Information API
+        https://bugs.webkit.org/show_bug.cgi?id=90762
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Add C API for WKNetworkInfo and WKNetworkInfoManager
+        so that they can be used by the client.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextGetNetworkInfoManager):
+        * UIProcess/API/C/WKContext.h:
+        * UIProcess/API/C/WKNetworkInfo.cpp: Copied from Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.cpp.
+        (WKNetworkInfoGetTypeID):
+        (WKNetworkInfoCreate):
+        * UIProcess/API/C/WKNetworkInfo.h: Copied from Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.cpp.
+        * UIProcess/API/C/WKNetworkInfoManager.cpp:
+        (WKNetworkInfoManagerSetProvider):
+        (WKNetworkInfoManagerProviderDidChangeNetworkInformation):
+        * UIProcess/API/C/WKNetworkInfoManager.h:
+
+2012-07-18  Christophe Dumez  <christophe.dumez@intel.com>
+
         [EFL][WK2] ewk_cookie_manager_persistent_storage_set is not exported
         https://bugs.webkit.org/show_bug.cgi?id=91647
 
index 3992935..0eb27b3 100644 (file)
@@ -71,6 +71,7 @@ webkit2_h_api += \
        $(WebKit2)/UIProcess/API/C/WKMediaCacheManager.h \
        $(WebKit2)/UIProcess/API/C/WKNativeEvent.h \
        $(WebKit2)/UIProcess/API/C/WKNavigationData.h \
+       $(WebKit2)/UIProcess/API/C/WKNetworkInfo.h \
        $(WebKit2)/UIProcess/API/C/WKNetworkInfoManager.h \
        $(WebKit2)/UIProcess/API/C/WKNotification.h \
        $(WebKit2)/UIProcess/API/C/WKNotificationManager.h \
@@ -572,6 +573,8 @@ webkit2_sources += \
        Source/WebKit2/UIProcess/API/C/WKNativeEvent.h \
        Source/WebKit2/UIProcess/API/C/WKNavigationData.cpp \
        Source/WebKit2/UIProcess/API/C/WKNavigationData.h \
+       Source/WebKit2/UIProcess/API/C/WKNetworkInfo.cpp \
+       Source/WebKit2/UIProcess/API/C/WKNetworkInfo.h \
        Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.cpp \
        Source/WebKit2/UIProcess/API/C/WKNetworkInfoManager.h \
        Source/WebKit2/UIProcess/API/C/WKNotification.cpp \
index 25d894f..80e5a65 100644 (file)
@@ -167,6 +167,7 @@ HEADERS += \
     UIProcess/API/C/WKOpenPanelParameters.h \
     UIProcess/API/C/WKOpenPanelResultListener.h \
     UIProcess/API/C/WKNavigationData.h \
+    UIProcess/API/C/WKNetworkInfo.h \
     UIProcess/API/C/WKNetworkInfoManager.h \
     UIProcess/API/C/WKNotification.h \
     UIProcess/API/C/WKNotificationManager.h \
@@ -547,6 +548,7 @@ SOURCES += \
     UIProcess/API/C/WKOpenPanelParameters.cpp \
     UIProcess/API/C/WKOpenPanelResultListener.cpp \
     UIProcess/API/C/WKNavigationData.cpp \
+    UIProcess/API/C/WKNetworkInfo.cpp \
     UIProcess/API/C/WKNetworkInfoManager.cpp \
     UIProcess/API/C/WKPage.cpp \
     UIProcess/API/C/WKPageGroup.cpp \
index 7bfc04a..f4dfec9 100644 (file)
@@ -189,6 +189,15 @@ WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef contextRef)
     return toAPI(toImpl(contextRef)->geolocationManagerProxy());
 }
 
+WKNetworkInfoManagerRef WKContextGetNetworkInfoManager(WKContextRef contextRef)
+{
+#if ENABLE(NETWORK_INFO)
+    return toAPI(toImpl(contextRef)->networkInfoManagerProxy());
+#else
+    return 0;
+#endif
+}
+
 WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef contextRef)
 {
     return toAPI(toImpl(contextRef)->iconDatabase());
index 85e4c15..10ae0aa 100644 (file)
@@ -155,6 +155,7 @@ WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef co
 WK_EXPORT WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef context);
 WK_EXPORT WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef context);
 WK_EXPORT WKMediaCacheManagerRef WKContextGetMediaCacheManager(WKContextRef context);
+WK_EXPORT WKNetworkInfoManagerRef WKContextGetNetworkInfoManager(WKContextRef context);
 WK_EXPORT WKNotificationManagerRef WKContextGetNotificationManager(WKContextRef context);
 WK_EXPORT WKPluginSiteDataManagerRef WKContextGetPluginSiteDataManager(WKContextRef context);
 WK_EXPORT WKResourceCacheManagerRef WKContextGetResourceCacheManager(WKContextRef context);
diff --git a/Source/WebKit2/UIProcess/API/C/WKNetworkInfo.cpp b/Source/WebKit2/UIProcess/API/C/WKNetworkInfo.cpp
new file mode 100644 (file)
index 0000000..a9bfd3c
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WKNetworkInfo.h"
+
+#if ENABLE(NETWORK_INFO)
+#include "WKAPICast.h"
+#include "WebNetworkInfo.h"
+
+using namespace WebKit;
+#endif
+
+WKTypeID WKNetworkInfoGetTypeID()
+{
+#if ENABLE(NETWORK_INFO)
+    return toAPI(WebNetworkInfo::APIType);
+#else
+    return 0;
+#endif
+}
+
+WKNetworkInfoRef WKNetworkInfoCreate(double bandwidth, bool isMetered)
+{
+#if ENABLE(NETWORK_INFO)
+    RefPtr<WebNetworkInfo> networkInfo = WebNetworkInfo::create(bandwidth, isMetered);
+    return toAPI(networkInfo.release().leakRef());
+#else
+    return 0;
+#endif
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKNetworkInfo.h b/Source/WebKit2/UIProcess/API/C/WKNetworkInfo.h
new file mode 100644 (file)
index 0000000..cff864a
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WKNetworkInfo_h
+#define WKNetworkInfo_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKNetworkInfoGetTypeID();
+
+WK_EXPORT WKNetworkInfoRef WKNetworkInfoCreate(double bandwidth, bool isMetered);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKNetworkInfo_h
index 1e0733a..85620ad 100644 (file)
@@ -39,3 +39,17 @@ WKTypeID WKNetworkInfoManagerGetTypeID()
     return 0;
 #endif
 }
+
+void WKNetworkInfoManagerSetProvider(WKNetworkInfoManagerRef networkInfoManager, const WKNetworkInfoProvider* provider)
+{
+#if ENABLE(NETWORK_INFO)
+    toImpl(networkInfoManager)->initializeProvider(provider);
+#endif
+}
+
+void WKNetworkInfoManagerProviderDidChangeNetworkInformation(WKNetworkInfoManagerRef networkInfoManager, WKStringRef eventType, WKNetworkInfoRef networkInfo)
+{
+#if ENABLE(NETWORK_INFO)
+    toImpl(networkInfoManager)->providerDidChangeNetworkInformation(AtomicString(toImpl(eventType)->string()), toImpl(networkInfo));
+#endif
+}
index efecf4e..dd92eb8 100644 (file)
@@ -52,6 +52,10 @@ enum { kWKNetworkInfoProviderCurrentVersion = 0 };
 
 WK_EXPORT WKTypeID WKNetworkInfoManagerGetTypeID();
 
+WK_EXPORT void WKNetworkInfoManagerSetProvider(WKNetworkInfoManagerRef networkInfoManager, const WKNetworkInfoProvider* provider);
+
+WK_EXPORT void WKNetworkInfoManagerProviderDidChangeNetworkInformation(WKNetworkInfoManagerRef networkInfoManager, WKStringRef eventType, WKNetworkInfoRef networkInfo);
+
 #ifdef __cplusplus
 }
 #endif