diff options
23 files changed, 661 insertions, 17 deletions
diff --git a/ppapi/api/private/ppb_network_list_private.idl b/ppapi/api/private/ppb_network_list_private.idl index 00c8a0f..540aa1d 100644 --- a/ppapi/api/private/ppb_network_list_private.idl +++ b/ppapi/api/private/ppb_network_list_private.idl @@ -17,19 +17,24 @@ label Chrome { [assert_size(4)] enum PP_NetworkListType_Private { /** + * Type of the network interface is not known. + */ + PP_NETWORKLIST_UNKNOWN = 0, + + /** * Wired Ethernet network. */ - PP_NETWORKLIST_ETHERNET = 0, + PP_NETWORKLIST_ETHERNET = 1, /** * Wireless Wi-Fi network. */ - PP_NETWORKLIST_WIFI = 1, + PP_NETWORKLIST_WIFI = 2, /** * Cellular network (e.g. LTE). */ - PP_NETWORKLIST_CELLULAR = 2 + PP_NETWORKLIST_CELLULAR = 3 }; /** @@ -85,15 +90,15 @@ interface PPB_NetworkList_Private { * @return Returns type of the network interface with the specified * <code>index</code>. */ - PP_NetworkListType_Private GetType([in] PP_Resource resource, - [in] uint32_t index); + PP_NetworkListType_Private GetType([in] PP_Resource resource, + [in] uint32_t index); /** * @return Returns current state of the network interface with the * specified <code>index</code>. */ - PP_NetworkListState_Private GetState([in] PP_Resource resource, - [in] uint32_t index); + PP_NetworkListState_Private GetState([in] PP_Resource resource, + [in] uint32_t index); /** * Gets list of IP addresses for the network interface with the @@ -108,8 +113,8 @@ interface PPB_NetworkList_Private { int32_t GetIpAddresses( [in] PP_Resource resource, [in] uint32_t index, - [out, size_is(count)] PP_NetAddress_Private[] addresses, - [in] int32_t count); + [inout, size_is(count)] PP_NetAddress_Private[] addresses, + [in] uint32_t count); /** * @return Returns display name for the network interface with the @@ -120,7 +125,7 @@ interface PPB_NetworkList_Private { /** * @return Returns MTU for the network interface with the specified - * <code>index</code>. + * <code>index</code> or 0 if MTU is unknown. */ uint32_t GetMTU([in] PP_Resource resource, [in] uint32_t index); diff --git a/ppapi/c/private/ppb_network_list_private.h b/ppapi/c/private/ppb_network_list_private.h index 90cbbe8..2cba362 100644 --- a/ppapi/c/private/ppb_network_list_private.h +++ b/ppapi/c/private/ppb_network_list_private.h @@ -4,7 +4,7 @@ */ /* From private/ppb_network_list_private.idl, - * modified Fri Feb 24 10:14:10 2012. + * modified Thu Mar 1 16:24:33 2012. */ #ifndef PPAPI_C_PRIVATE_PPB_NETWORK_LIST_PRIVATE_H_ @@ -35,17 +35,21 @@ */ typedef enum { /** + * Type of the network interface is not known. + */ + PP_NETWORKLIST_UNKNOWN = 0, + /** * Wired Ethernet network. */ - PP_NETWORKLIST_ETHERNET = 0, + PP_NETWORKLIST_ETHERNET = 1, /** * Wireless Wi-Fi network. */ - PP_NETWORKLIST_WIFI = 1, + PP_NETWORKLIST_WIFI = 2, /** * Cellular network (e.g. LTE). */ - PP_NETWORKLIST_CELLULAR = 2 + PP_NETWORKLIST_CELLULAR = 3 } PP_NetworkListType_Private; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetworkListType_Private, 4); @@ -122,8 +126,8 @@ struct PPB_NetworkList_Private_0_2 { */ int32_t (*GetIpAddresses)(PP_Resource resource, uint32_t index, - struct PP_NetAddress_Private* addresses[], - int32_t count); + struct PP_NetAddress_Private addresses[], + uint32_t count); /** * @return Returns display name for the network interface with the * specified <code>index</code>. @@ -131,7 +135,7 @@ struct PPB_NetworkList_Private_0_2 { struct PP_Var (*GetDisplayName)(PP_Resource resource, uint32_t index); /** * @return Returns MTU for the network interface with the specified - * <code>index</code>. + * <code>index</code> or 0 if MTU is unknown. */ uint32_t (*GetMTU)(PP_Resource resource, uint32_t index); }; diff --git a/ppapi/cpp/private/network_list_private.cc b/ppapi/cpp/private/network_list_private.cc new file mode 100644 index 0000000..d08410e --- /dev/null +++ b/ppapi/cpp/private/network_list_private.cc @@ -0,0 +1,107 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/private/network_list_private.h" + +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/var.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_NetworkList_Private>() { + return PPB_NETWORKLIST_PRIVATE_INTERFACE; +} + +} // namespace + +NetworkListPrivate::NetworkListPrivate(PP_Resource resource) + : Resource(resource) { +} + +// static +bool NetworkListPrivate::IsAvailable() { + return has_interface<PPB_NetworkList_Private>(); +} + +uint32_t NetworkListPrivate::GetCount() { + if (!has_interface<PPB_NetworkList_Private>()) + return 0; + return get_interface<PPB_NetworkList_Private>()->GetCount(pp_resource()); +} + +std::string NetworkListPrivate::GetName(uint32_t index) { + if (!has_interface<PPB_NetworkList_Private>()) + return std::string(); + Var result(PASS_REF, + get_interface<PPB_NetworkList_Private>()->GetName( + pp_resource(), index)); + return result.is_string() ? result.AsString() : std::string(); +} + +PP_NetworkListType_Private NetworkListPrivate::GetType(uint32_t index) { + if (!has_interface<PPB_NetworkList_Private>()) + return PP_NETWORKLIST_ETHERNET; + return get_interface<PPB_NetworkList_Private>()->GetType( + pp_resource(), index); +} + +PP_NetworkListState_Private NetworkListPrivate::GetState(uint32_t index) { + if (!has_interface<PPB_NetworkList_Private>()) + return PP_NETWORKLIST_DOWN; + return get_interface<PPB_NetworkList_Private>()->GetState( + pp_resource(), index); +} + +void NetworkListPrivate::GetIpAddresses( + uint32_t index, + std::vector<PP_NetAddress_Private>* addresses) { + if (!has_interface<PPB_NetworkList_Private>()) + return; + + // Most netword interfaces don't have more than 3 network + // interfaces. + addresses->resize(3); + + int32_t result = get_interface<PPB_NetworkList_Private>()->GetIpAddresses( + pp_resource(), index, &addresses->front(), addresses->size()); + + if (result < 0) { + addresses->resize(0); + return; + } + + if (result <= static_cast<int32_t>(addresses->size())) { + addresses->resize(result); + return; + } + + addresses->resize(result); + result = get_interface<PPB_NetworkList_Private>()->GetIpAddresses( + pp_resource(), index, &addresses->front(), addresses->size()); + if (result < 0) { + addresses->resize(0); + } else if (result < static_cast<int32_t>(addresses->size())) { + addresses->resize(result); + } +} + +std::string NetworkListPrivate::GetDisplayName(uint32_t index) { + if (!has_interface<PPB_NetworkList_Private>()) + return std::string(); + Var result(PASS_REF, + get_interface<PPB_NetworkList_Private>()->GetDisplayName( + pp_resource(), index)); + return result.is_string() ? result.AsString() : std::string(); +} + +uint32_t NetworkListPrivate::GetMTU(uint32_t index) { + if (!has_interface<PPB_NetworkList_Private>()) + return 0; + return get_interface<PPB_NetworkList_Private>()->GetMTU( + pp_resource(), index); +} + +} // namespace pp diff --git a/ppapi/cpp/private/network_list_private.h b/ppapi/cpp/private/network_list_private.h new file mode 100644 index 0000000..223941d1 --- /dev/null +++ b/ppapi/cpp/private/network_list_private.h @@ -0,0 +1,56 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ +#define PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ + +#include <string> +#include <vector> + +#include "ppapi/c/private/ppb_network_list_private.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class NetworkListPrivate : public Resource { + public: + explicit NetworkListPrivate(PP_Resource resource); + + /// Returns true if the required interface is available. + static bool IsAvailable(); + + /// @return Returns the number of available network interfaces or 0 + /// if the list has never been updated. + uint32_t GetCount(); + + /// @return Returns the name for the network interface with the + /// specified <code>index</code>. + std::string GetName(uint32_t index); + + /// @return Returns the type of the network interface with the + /// specified <code>index</code>. + PP_NetworkListType_Private GetType(uint32_t index); + + /// @return Returns the current state of the network interface with + /// the specified <code>index</code>. + PP_NetworkListState_Private GetState(uint32_t index); + + /// Gets the list of IP addresses for the network interface with the + /// specified <code>index</code> and stores them in + /// <code>addresses</code>. + void GetIpAddresses(uint32_t index, + std::vector<PP_NetAddress_Private>* addresses); + + /// @return Returns the display name for the network interface with + /// the specified <code>index</code>. + std::string GetDisplayName(uint32_t index); + + /// @return Returns the MTU for the network interface with the + /// specified <code>index</code>. + uint32_t GetMTU(uint32_t index); +}; + +} // namespace pp + +#endif // PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ diff --git a/ppapi/cpp/private/network_monitor_private.cc b/ppapi/cpp/private/network_monitor_private.cc new file mode 100644 index 0000000..2f931ea --- /dev/null +++ b/ppapi/cpp/private/network_monitor_private.cc @@ -0,0 +1,35 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/private/network_monitor_private.h" + +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_NetworkMonitor_Private>() { + return PPB_NETWORKMONITOR_PRIVATE_INTERFACE; +} + +} // namespace + +NetworkMonitorPrivate::NetworkMonitorPrivate( + const InstanceHandle& instance, + PPB_NetworkMonitor_Callback callback, + void* user_data) { + if (has_interface<PPB_NetworkMonitor_Private>()) { + PassRefFromConstructor(get_interface<PPB_NetworkMonitor_Private>()->Create( + instance.pp_instance(), callback, user_data)); + } +} + +// static +bool NetworkMonitorPrivate::IsAvailable() { + return has_interface<PPB_NetworkMonitor_Private>(); +} + +} // namespace pp diff --git a/ppapi/cpp/private/network_monitor_private.h b/ppapi/cpp/private/network_monitor_private.h new file mode 100644 index 0000000..693bbcd --- /dev/null +++ b/ppapi/cpp/private/network_monitor_private.h @@ -0,0 +1,28 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ +#define PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ + +#include "ppapi/c/private/ppb_network_monitor_private.h" +#include "ppapi/cpp/resource.h" +#include "ppapi/cpp/instance_handle.h" + +namespace pp { + +class Instance; + +class NetworkMonitorPrivate : public Resource { + public: + NetworkMonitorPrivate(const InstanceHandle& instance, + PPB_NetworkMonitor_Callback callback, + void* user_data); + + // Returns true if the required interface is available. + static bool IsAvailable(); +}; + +} // namespace pp + +#endif // PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 56df78c1..8a36c7f 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -88,6 +88,8 @@ 'shared_impl/ppb_instance_shared.cc', 'shared_impl/ppb_instance_shared.h', 'shared_impl/ppb_memory_shared.cc', + 'shared_impl/ppb_network_list_private_shared.cc', + 'shared_impl/ppb_network_list_private_shared.h', 'shared_impl/ppb_opengles2_shared.cc', 'shared_impl/ppb_opengles2_shared.h', 'shared_impl/ppb_resource_array_shared.cc', @@ -202,6 +204,10 @@ 'thunk/ppb_message_loop_api.h', 'thunk/ppb_messaging_thunk.cc', 'thunk/ppb_mouse_lock_thunk.cc', + 'thunk/ppb_network_list_private_api.h', + 'thunk/ppb_network_list_private_thunk.cc', + 'thunk/ppb_network_monitor_private_api.h', + 'thunk/ppb_network_monitor_private_thunk.cc', 'thunk/ppb_pdf_api.h', 'thunk/ppb_resource_array_api.h', 'thunk/ppb_resource_array_thunk.cc', diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index b99e463..3aa4056 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -102,6 +102,8 @@ 'c/private/ppb_pdf.h', 'c/private/ppb_proxy_private.h', 'c/private/ppp_instance_private.h', + 'c/private/ppb_network_list_private.h', + 'c/private/ppb_network_monitor_private.h', 'c/private/ppb_tcp_socket_private.h', 'c/private/ppb_udp_socket_private.h', @@ -253,6 +255,10 @@ 'cpp/private/instance_private.h', 'cpp/private/net_address_private.cc', 'cpp/private/net_address_private.h', + 'cpp/private/network_list_private.cc', + 'cpp/private/network_list_private.h', + 'cpp/private/network_monitor_private.cc', + 'cpp/private/network_monitor_private.h', 'cpp/private/tcp_socket_private.cc', 'cpp/private/tcp_socket_private.h', 'cpp/private/udp_socket_private.cc', diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 4a7ef62..036492e 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -58,6 +58,8 @@ #include "ppapi/c/private/ppb_flash_net_connector.h" #include "ppapi/c/private/ppb_flash_tcp_socket.h" #include "ppapi/c/private/ppb_net_address_private.h" +#include "ppapi/c/private/ppb_network_list_private.h" +#include "ppapi/c/private/ppb_network_monitor_private.h" #include "ppapi/c/private/ppb_pdf.h" #include "ppapi/c/private/ppb_tcp_socket_private.h" #include "ppapi/c/private/ppb_udp_socket_private.h" diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 40a8924..962c9ad 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -238,6 +238,14 @@ PP_Resource ResourceCreationProxy::CreateMouseInputEvent( instance, data))->GetReference(); } +PP_Resource ResourceCreationProxy::CreateNetworkMonitor( + PP_Instance instance, + PPB_NetworkMonitor_Callback callback, + void* user_data) { + NOTIMPLEMENTED(); // Not proxied yet. + return 0; +} + PP_Resource ResourceCreationProxy::CreateGraphics3D( PP_Instance instance, PP_Resource share_context, diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index c7f84ab..2b9428a 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -101,6 +101,10 @@ class ResourceCreationProxy : public InterfaceProxy, const PP_Point* mouse_position, int32_t click_count, const PP_Point* mouse_movement) OVERRIDE; + virtual PP_Resource CreateNetworkMonitor( + PP_Instance instance, + PPB_NetworkMonitor_Callback callback, + void* user_data) OVERRIDE; virtual PP_Resource CreateResourceArray(PP_Instance instance, const PP_Resource elements[], uint32_t size) OVERRIDE; diff --git a/ppapi/shared_impl/ppb_network_list_private_shared.cc b/ppapi/shared_impl/ppb_network_list_private_shared.cc new file mode 100644 index 0000000..b06e4c5 --- /dev/null +++ b/ppapi/shared_impl/ppb_network_list_private_shared.cc @@ -0,0 +1,98 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <algorithm> + +#include "base/logging.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/shared_impl/ppb_network_list_private_shared.h" +#include "ppapi/shared_impl/var.h" + +namespace ppapi { + +PPB_NetworkList_Private_Shared::NetworkInfo::NetworkInfo() + : type(PP_NETWORKLIST_UNKNOWN), + state(PP_NETWORKLIST_DOWN), + mtu(0) { +} + +PPB_NetworkList_Private_Shared::NetworkInfo::~NetworkInfo() { +} + +PPB_NetworkList_Private_Shared::PPB_NetworkList_Private_Shared( + ResourceObjectType type, + PP_Instance instance, + scoped_ptr<NetworkList> list) + : Resource(type, instance), + list_(list.Pass()) { +} + +PPB_NetworkList_Private_Shared::~PPB_NetworkList_Private_Shared() { +} + +// static +PP_Resource PPB_NetworkList_Private_Shared::Create( + ResourceObjectType type, + PP_Instance instance, + scoped_ptr<NetworkList> list) { + scoped_refptr<PPB_NetworkList_Private_Shared> object( + new PPB_NetworkList_Private_Shared(type, instance, list.Pass())); + return object->GetReference(); +} + +::ppapi::thunk::PPB_NetworkList_Private_API* +PPB_NetworkList_Private_Shared::AsPPB_NetworkList_Private_API() { + return this; +} + +uint32_t PPB_NetworkList_Private_Shared::GetCount() { + return list_->size(); +} + +PP_Var PPB_NetworkList_Private_Shared::GetName(uint32_t index) { + if (index >= list_->size()) + return PP_MakeUndefined(); + return StringVar::StringToPPVar(list_->at(index).name); +} + +PP_NetworkListType_Private PPB_NetworkList_Private_Shared::GetType( + uint32_t index) { + if (index >= list_->size()) + return PP_NETWORKLIST_UNKNOWN; + return list_->at(index).type; +} + +PP_NetworkListState_Private PPB_NetworkList_Private_Shared::GetState( + uint32_t index) { + if (index >= list_->size()) + return PP_NETWORKLIST_DOWN; + return list_->at(index).state; +} + +int32_t PPB_NetworkList_Private_Shared::GetIpAddresses( + uint32_t index, + struct PP_NetAddress_Private addresses[], + uint32_t count) { + if (index >= list_->size()) + return PP_ERROR_FAILED; + count = std::min( + count, static_cast<uint32_t>(list_->at(index).addresses.size())); + memcpy(addresses, &(list_->at(index).addresses[0]), + sizeof(PP_NetAddress_Private) * count); + return list_->at(index).addresses.size(); +} + +PP_Var PPB_NetworkList_Private_Shared::GetDisplayName(uint32_t index) { + if (index >= list_->size()) + return PP_MakeUndefined(); + return StringVar::StringToPPVar(list_->at(index).display_name); +} + +uint32_t PPB_NetworkList_Private_Shared::GetMTU(uint32_t index) { + if (index >= list_->size()) + return 0; + return list_->at(index).mtu; +} + +} // namespace thunk diff --git a/ppapi/shared_impl/ppb_network_list_private_shared.h b/ppapi/shared_impl/ppb_network_list_private_shared.h new file mode 100644 index 0000000..731d543 --- /dev/null +++ b/ppapi/shared_impl/ppb_network_list_private_shared.h @@ -0,0 +1,67 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ + +#include <vector> + +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_network_list_private_api.h" + +namespace ppapi { + +class PPAPI_SHARED_EXPORT PPB_NetworkList_Private_Shared + : public ::ppapi::Resource, + public ::ppapi::thunk::PPB_NetworkList_Private_API { + public: + struct NetworkInfo { + NetworkInfo(); + ~NetworkInfo(); + + std::string name; + PP_NetworkListType_Private type; + PP_NetworkListState_Private state; + std::vector<PP_NetAddress_Private> addresses; + std::string display_name; + int mtu; + }; + typedef std::vector<NetworkInfo> NetworkList; + + static PP_Resource Create(ResourceObjectType type, + PP_Instance instance, + scoped_ptr<NetworkList> list); + + virtual ~PPB_NetworkList_Private_Shared(); + + // Resource override. + virtual ::ppapi::thunk::PPB_NetworkList_Private_API* + AsPPB_NetworkList_Private_API() OVERRIDE; + + // PPB_NetworkList_Private_API implementation. + virtual uint32_t GetCount() OVERRIDE; + virtual PP_Var GetName(uint32_t index) OVERRIDE; + virtual PP_NetworkListType_Private GetType(uint32_t index) OVERRIDE; + virtual PP_NetworkListState_Private GetState(uint32_t index) OVERRIDE; + virtual int32_t GetIpAddresses(uint32_t index, + PP_NetAddress_Private addresses[], + uint32_t count) OVERRIDE; + virtual PP_Var GetDisplayName(uint32_t index) OVERRIDE; + virtual uint32_t GetMTU(uint32_t index) OVERRIDE; + + private: + PPB_NetworkList_Private_Shared(ResourceObjectType type, + PP_Instance instance, + scoped_ptr<NetworkList> list); + + scoped_ptr<NetworkList> list_; + + DISALLOW_COPY_AND_ASSIGN(PPB_NetworkList_Private_Shared); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h index 34df0ea..6a1cda9 100644 --- a/ppapi/shared_impl/resource.h +++ b/ppapi/shared_impl/resource.h @@ -44,6 +44,8 @@ F(PPB_InputEvent_API) \ F(PPB_LayerCompositor_API) \ F(PPB_MessageLoop_API) \ + F(PPB_NetworkList_Private_API) \ + F(PPB_NetworkMonitor_Private_API) \ F(PPB_PDFFont_API) \ F(PPB_ResourceArray_API) \ F(PPB_Scrollbar_API) \ diff --git a/ppapi/thunk/interfaces_ppb_private.h b/ppapi/thunk/interfaces_ppb_private.h index 1b43ebe..9adaa45 100644 --- a/ppapi/thunk/interfaces_ppb_private.h +++ b/ppapi/thunk/interfaces_ppb_private.h @@ -35,6 +35,12 @@ PROXIED_IFACE(PPB_UDPSocket_Private, PPB_UDPSOCKET_PRIVATE_INTERFACE_0_2, PROXIED_IFACE(PPB_UDPSocket_Private, PPB_UDPSOCKET_PRIVATE_INTERFACE_0_3, PPB_UDPSocket_Private_0_3) +UNPROXIED_IFACE(PPB_NetworkList_Private, PPB_NETWORKLIST_PRIVATE_INTERFACE_0_2, + PPB_NetworkList_Private_0_2) +UNPROXIED_IFACE(PPB_NetworkMonitor_Private, + PPB_NETWORKMONITOR_PRIVATE_INTERFACE_0_2, + PPB_NetworkMonitor_Private_0_2) + // Hack to keep font working. The Font 0.6 API is binary compatible with // BrowserFont 1.0, so just map the string to the same thing. // TODO(brettw) remove support for the old Font API. diff --git a/ppapi/thunk/ppb_network_list_private_api.h b/ppapi/thunk/ppb_network_list_private_api.h new file mode 100644 index 0000000..fbe57f0 --- /dev/null +++ b/ppapi/thunk/ppb_network_list_private_api.h @@ -0,0 +1,32 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_THUNK_PPB_NETWORK_LIST_PRIVATE_API_H_ +#define PPAPI_THUNK_PPB_NETWORK_LIST_PRIVATE_API_H_ + +#include "ppapi/c/private/ppb_network_list_private.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_NetworkList_Private_API { + public: + virtual ~PPB_NetworkList_Private_API() {} + + virtual uint32_t GetCount() = 0; + virtual PP_Var GetName(uint32_t index) = 0; + virtual PP_NetworkListType_Private GetType(uint32_t index) = 0; + virtual PP_NetworkListState_Private GetState(uint32_t index) = 0; + virtual int32_t GetIpAddresses(uint32_t index, + PP_NetAddress_Private addresses[], + uint32_t count) = 0; + virtual PP_Var GetDisplayName(uint32_t index) = 0; + virtual uint32_t GetMTU(uint32_t index) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_NETWORK_LIST_PRIVATE_API_H_ diff --git a/ppapi/thunk/ppb_network_list_private_thunk.cc b/ppapi/thunk/ppb_network_list_private_thunk.cc new file mode 100644 index 0000000..a5ee1e4 --- /dev/null +++ b/ppapi/thunk/ppb_network_list_private_thunk.cc @@ -0,0 +1,92 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/c/pp_errors.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/ppb_network_list_private_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +typedef EnterResource<PPB_NetworkList_Private_API> EnterNetworkList; + +PP_Bool IsNetworkList(PP_Resource resource) { + EnterNetworkList enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +uint32_t GetCount(PP_Resource network_list) { + EnterNetworkList enter(network_list, true); + if (enter.failed()) + return 0; + return enter.object()->GetCount(); +} + +PP_Var GetName(PP_Resource network_list, uint32_t index) { + EnterNetworkList enter(network_list, true); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.object()->GetName(index); +} + +PP_NetworkListType_Private GetType(PP_Resource network_list, uint32_t index) { + EnterNetworkList enter(network_list, true); + if (enter.failed()) + return PP_NETWORKLIST_UNKNOWN; + return enter.object()->GetType(index); +} + +PP_NetworkListState_Private GetState(PP_Resource network_list, uint32_t index) { + EnterNetworkList enter(network_list, true); + if (enter.failed()) + return PP_NETWORKLIST_DOWN; + return enter.object()->GetState(index); +} + +int32_t GetIpAddresses(PP_Resource network_list, + uint32_t index, + struct PP_NetAddress_Private addresses[], + uint32_t count) { + EnterNetworkList enter(network_list, true); + if (enter.failed()) + return enter.retval(); + return enter.object()->GetIpAddresses(index, addresses, count); +} + +PP_Var GetDisplayName(PP_Resource network_list, uint32_t index) { + EnterNetworkList enter(network_list, true); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.object()->GetDisplayName(index); +} + +uint32_t GetMTU(PP_Resource network_list, uint32_t index) { + EnterNetworkList enter(network_list, true); + if (enter.failed()) + return 0; + return enter.object()->GetMTU(index); +} + +const PPB_NetworkList_Private g_ppb_network_list_private_thunk = { + &IsNetworkList, + &GetCount, + &GetName, + &GetType, + &GetState, + &GetIpAddresses, + &GetDisplayName, + &GetMTU, +}; + +} // namespace + +const PPB_NetworkList_Private_0_2* GetPPB_NetworkList_Private_0_2_Thunk() { + return &g_ppb_network_list_private_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_network_monitor_private_api.h b/ppapi/thunk/ppb_network_monitor_private_api.h new file mode 100644 index 0000000..124f644 --- /dev/null +++ b/ppapi/thunk/ppb_network_monitor_private_api.h @@ -0,0 +1,22 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_THUNK_PPB_NETWORK_MONITOR_PRIVATE_API_H_ +#define PPAPI_THUNK_PPB_NETWORK_MONITOR_PRIVATE_API_H_ + +#include "ppapi/c/private/ppb_network_monitor_private.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_NetworkMonitor_Private_API { + public: + virtual ~PPB_NetworkMonitor_Private_API() {} +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_NETWORK_MONITOR_PRIVATE_API_H_ diff --git a/ppapi/thunk/ppb_network_monitor_private_thunk.cc b/ppapi/thunk/ppb_network_monitor_private_thunk.cc new file mode 100644 index 0000000..e692601 --- /dev/null +++ b/ppapi/thunk/ppb_network_monitor_private_thunk.cc @@ -0,0 +1,45 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/c/pp_errors.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/ppb_network_monitor_private_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +typedef EnterResource<PPB_NetworkMonitor_Private_API> EnterNetworkMonitor; + +PP_Resource Create(PP_Instance instance, + PPB_NetworkMonitor_Callback callback, + void* user_data) { + EnterFunction<ResourceCreationAPI> enter(instance, true); + if (enter.failed()) + return 0; + return enter.functions()->CreateNetworkMonitor(instance, callback, user_data); +} + +PP_Bool IsNetworkMonitor(PP_Resource resource) { + EnterNetworkMonitor enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +const PPB_NetworkMonitor_Private g_ppb_network_monitor_private_thunk = { + &Create, + &IsNetworkMonitor, +}; + +} // namespace + +const PPB_NetworkMonitor_Private_0_2* +GetPPB_NetworkMonitor_Private_0_2_Thunk() { + return &g_ppb_network_monitor_private_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index d567a18..8b9360f5 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -20,6 +20,7 @@ #include "ppapi/c/ppb_websocket.h" #include "ppapi/c/dev/pp_video_dev.h" #include "ppapi/c/dev/ppb_transport_dev.h" +#include "ppapi/c/private/ppb_network_monitor_private.h" #include "ppapi/shared_impl/api_id.h" struct PP_Flash_Menu; @@ -103,6 +104,10 @@ class ResourceCreationAPI { const PP_Point* mouse_position, int32_t click_count, const PP_Point* mouse_movement) = 0; + virtual PP_Resource CreateNetworkMonitor( + PP_Instance instance, + PPB_NetworkMonitor_Callback callback, + void* user_data) = 0; virtual PP_Resource CreateResourceArray(PP_Instance instance, const PP_Resource elements[], uint32_t size) = 0; diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index ba0f3c5..864a229 100644 --- a/webkit/plugins/ppapi/plugin_module.cc +++ b/webkit/plugins/ppapi/plugin_module.cc @@ -75,6 +75,8 @@ #include "ppapi/c/private/ppb_flash_tcp_socket.h" #include "ppapi/c/private/ppb_gpu_blacklist_private.h" #include "ppapi/c/private/ppb_instance_private.h" +#include "ppapi/c/private/ppb_network_list_private.h" +#include "ppapi/c/private/ppb_network_monitor_private.h" #include "ppapi/c/private/ppb_pdf.h" #include "ppapi/c/private/ppb_proxy_private.h" #include "ppapi/c/private/ppb_tcp_server_socket_private.h" diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc index 4ef430e..a9005c3 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.cc +++ b/webkit/plugins/ppapi/resource_creation_impl.cc @@ -244,6 +244,14 @@ PP_Resource ResourceCreationImpl::CreateMouseInputEvent( instance, data))->GetReference(); } +PP_Resource ResourceCreationImpl::CreateNetworkMonitor( + PP_Instance instance, + PPB_NetworkMonitor_Callback callback, + void* user_data) { + NOTIMPLEMENTED(); + return 0; +} + PP_Resource ResourceCreationImpl::CreateScrollbar(PP_Instance instance, PP_Bool vertical) { return PPB_Scrollbar_Impl::Create(instance, PP_ToBool(vertical)); diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h index f7c2a70..3da5037 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.h +++ b/webkit/plugins/ppapi/resource_creation_impl.h @@ -88,6 +88,10 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase, const PP_Point* mouse_position, int32_t click_count, const PP_Point* mouse_movement) OVERRIDE; + virtual PP_Resource CreateNetworkMonitor( + PP_Instance instance, + PPB_NetworkMonitor_Callback callback, + void* user_data) OVERRIDE; virtual PP_Resource CreateResourceArray(PP_Instance instance, const PP_Resource elements[], uint32_t size) OVERRIDE; |