summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-17 00:03:44 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-17 00:03:44 +0000
commitde9c2085ba61d079f9266c70fb11837a3f54416d (patch)
tree30d98cc46b1b60818f64244c0a90f39e2908726d /ppapi
parent7d0d0ed9dac7a7c74a954ecec3c11446121423ec (diff)
downloadchromium_src-de9c2085ba61d079f9266c70fb11837a3f54416d.zip
chromium_src-de9c2085ba61d079f9266c70fb11837a3f54416d.tar.gz
chromium_src-de9c2085ba61d079f9266c70fb11837a3f54416d.tar.bz2
Simplify PPB_NetworkMonitor proxy.
The new proxy is based on ppapi::proxy::PluginResource and ppapi::host::ResourceHost which simplifies code significantly. Also the permission check is consistent with socket APIs now. BUG=281781 Review URL: https://chromiumcodereview.appspot.com/23819033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223482 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/ppapi_proxy.gypi6
-rw-r--r--ppapi/ppapi_shared.gypi2
-rw-r--r--ppapi/proxy/interface_list.cc1
-rw-r--r--ppapi/proxy/network_list_resource.cc89
-rw-r--r--ppapi/proxy/network_list_resource.h52
-rw-r--r--ppapi/proxy/network_monitor_resource.cc85
-rw-r--r--ppapi/proxy/network_monitor_resource.h58
-rw-r--r--ppapi/proxy/ppapi_messages.h22
-rw-r--r--ppapi/proxy/ppb_network_monitor_private_proxy.cc174
-rw-r--r--ppapi/proxy/ppb_network_monitor_private_proxy.h58
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc5
-rw-r--r--ppapi/proxy/serialized_structs.cc8
-rw-r--r--ppapi/proxy/serialized_structs.h15
-rw-r--r--ppapi/shared_impl/api_id.h1
-rw-r--r--ppapi/shared_impl/ppb_network_list_private_shared.cc123
-rw-r--r--ppapi/shared_impl/ppb_network_list_private_shared.h88
-rw-r--r--ppapi/thunk/interfaces_ppb_private_no_permissions.h5
-rw-r--r--ppapi/thunk/ppb_network_list_api.h8
18 files changed, 324 insertions, 476 deletions
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi
index 52b97e9..d0bbe65 100644
--- a/ppapi/ppapi_proxy.gypi
+++ b/ppapi/ppapi_proxy.gypi
@@ -82,6 +82,10 @@
'proxy/locking_resource_releaser.h',
'proxy/net_address_resource.cc',
'proxy/net_address_resource.h',
+ 'proxy/network_list_resource.cc',
+ 'proxy/network_list_resource.h',
+ 'proxy/network_monitor_resource.cc',
+ 'proxy/network_monitor_resource.h',
'proxy/network_proxy_resource.cc',
'proxy/network_proxy_resource.h',
'proxy/pdf_resource.cc',
@@ -127,8 +131,6 @@
'proxy/ppb_instance_proxy.h',
'proxy/ppb_message_loop_proxy.cc',
'proxy/ppb_message_loop_proxy.h',
- 'proxy/ppb_network_monitor_private_proxy.cc',
- 'proxy/ppb_network_monitor_private_proxy.h',
'proxy/ppb_testing_proxy.cc',
'proxy/ppb_testing_proxy.h',
'proxy/ppb_var_deprecated_proxy.cc',
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index e638498..8c9b658 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -68,8 +68,6 @@
'shared_impl/ppb_memory_shared.cc',
'shared_impl/ppb_message_loop_shared.cc',
'shared_impl/ppb_message_loop_shared.h',
- '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',
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index 115516f..409f12f 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -107,7 +107,6 @@
#include "ppapi/proxy/ppb_image_data_proxy.h"
#include "ppapi/proxy/ppb_instance_proxy.h"
#include "ppapi/proxy/ppb_message_loop_proxy.h"
-#include "ppapi/proxy/ppb_network_monitor_private_proxy.h"
#include "ppapi/proxy/ppb_testing_proxy.h"
#include "ppapi/proxy/ppb_var_deprecated_proxy.h"
#include "ppapi/proxy/ppb_video_decoder_proxy.h"
diff --git a/ppapi/proxy/network_list_resource.cc b/ppapi/proxy/network_list_resource.cc
new file mode 100644
index 0000000..789e4f2
--- /dev/null
+++ b/ppapi/proxy/network_list_resource.cc
@@ -0,0 +1,89 @@
+// Copyright 2013 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/proxy/network_list_resource.h"
+
+#include <algorithm>
+
+#include "base/logging.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/shared_impl/array_writer.h"
+#include "ppapi/shared_impl/var.h"
+#include "ppapi/thunk/enter.h"
+
+namespace ppapi {
+namespace proxy {
+
+NetworkListResource::NetworkListResource(PP_Instance instance,
+ const SerializedNetworkList& list)
+ : Resource(OBJECT_IS_PROXY, instance),
+ list_(list) {
+}
+
+NetworkListResource::~NetworkListResource() {}
+
+thunk::PPB_NetworkList_API* NetworkListResource::AsPPB_NetworkList_API() {
+ return this;
+}
+
+uint32_t NetworkListResource::GetCount() {
+ return static_cast<uint32_t>(list_.size());
+}
+
+PP_Var NetworkListResource::GetName(uint32_t index) {
+ if (index >= list_.size())
+ return PP_MakeUndefined();
+ return StringVar::StringToPPVar(list_.at(index).name);
+}
+
+PP_NetworkListType_Private NetworkListResource::GetType(uint32_t index) {
+ if (index >= list_.size())
+ return PP_NETWORKLIST_UNKNOWN;
+ return list_.at(index).type;
+}
+
+PP_NetworkListState_Private NetworkListResource::GetState(uint32_t index) {
+ if (index >= list_.size())
+ return PP_NETWORKLIST_DOWN;
+ return list_.at(index).state;
+}
+
+int32_t NetworkListResource::GetIpAddresses(uint32_t index,
+ const PP_ArrayOutput& output) {
+ ArrayWriter writer(output);
+ if (index >= list_.size() || !writer.is_valid())
+ return PP_ERROR_BADARGUMENT;
+
+ thunk::EnterResourceCreationNoLock enter(pp_instance());
+ if (enter.failed())
+ return PP_ERROR_FAILED;
+
+ const std::vector<PP_NetAddress_Private>& addresses =
+ list_.at(index).addresses;
+ std::vector<PP_Resource> addr_resources;
+ for (size_t i = 0; i < addresses.size(); ++i) {
+ addr_resources.push_back(
+ enter.functions()->CreateNetAddressFromNetAddressPrivate(
+ pp_instance(), addresses[i]));
+ }
+ if (!writer.StoreResourceVector(addr_resources))
+ return PP_ERROR_FAILED;
+
+ return PP_OK;
+}
+
+PP_Var NetworkListResource::GetDisplayName(uint32_t index) {
+ if (index >= list_.size())
+ return PP_MakeUndefined();
+ return StringVar::StringToPPVar(list_.at(index).display_name);
+}
+
+uint32_t NetworkListResource::GetMTU(uint32_t index) {
+ if (index >= list_.size())
+ return 0;
+ return list_.at(index).mtu;
+}
+
+} // namespace proxy
+} // namespace thunk
diff --git a/ppapi/proxy/network_list_resource.h b/ppapi/proxy/network_list_resource.h
new file mode 100644
index 0000000..618ba02
--- /dev/null
+++ b/ppapi/proxy/network_list_resource.h
@@ -0,0 +1,52 @@
+// Copyright 2013 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_PROXY_NETWORK_LIST_RESOURCE_H_
+#define PPAPI_PROXY_NETWORK_LIST_RESOURCE_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "ppapi/c/private/ppb_net_address_private.h"
+#include "ppapi/proxy/ppapi_proxy_export.h"
+#include "ppapi/proxy/serialized_structs.h"
+#include "ppapi/shared_impl/resource.h"
+#include "ppapi/thunk/ppb_network_list_api.h"
+
+namespace ppapi {
+namespace proxy {
+
+class NetworkListResource
+ : public Resource,
+ public thunk::PPB_NetworkList_API {
+ public:
+ NetworkListResource(PP_Instance instance,
+ const SerializedNetworkList& list);
+ virtual ~NetworkListResource();
+
+ // Resource override.
+ virtual thunk::PPB_NetworkList_API* AsPPB_NetworkList_API() OVERRIDE;
+
+ // PPB_NetworkList_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,
+ const PP_ArrayOutput& output) OVERRIDE;
+ virtual PP_Var GetDisplayName(uint32_t index) OVERRIDE;
+ virtual uint32_t GetMTU(uint32_t index) OVERRIDE;
+
+ private:
+ SerializedNetworkList list_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkListResource);
+};
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_NETWORK_LIST_RESOURCE_H_
diff --git a/ppapi/proxy/network_monitor_resource.cc b/ppapi/proxy/network_monitor_resource.cc
new file mode 100644
index 0000000..0dfb0b4
--- /dev/null
+++ b/ppapi/proxy/network_monitor_resource.cc
@@ -0,0 +1,85 @@
+// Copyright 2013 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/proxy/network_monitor_resource.h"
+
+#include "ppapi/proxy/dispatch_reply_message.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_network_monitor_api.h"
+
+namespace ppapi {
+namespace proxy {
+
+NetworkMonitorResource::NetworkMonitorResource(Connection connection,
+ PP_Instance instance)
+ : PluginResource(connection, instance),
+ current_list_(0),
+ forbidden_(false),
+ network_list_(NULL) {
+ SendCreate(BROWSER, PpapiHostMsg_NetworkMonitor_Create());
+}
+
+NetworkMonitorResource::~NetworkMonitorResource() {}
+
+ppapi::thunk::PPB_NetworkMonitor_API*
+NetworkMonitorResource::AsPPB_NetworkMonitor_API() {
+ return this;
+}
+
+void NetworkMonitorResource::OnReplyReceived(
+ const ResourceMessageReplyParams& params,
+ const IPC::Message& msg) {
+ IPC_BEGIN_MESSAGE_MAP(NetworkMonitorResource, msg)
+ PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
+ PpapiPluginMsg_NetworkMonitor_NetworkList, OnPluginMsgNetworkList)
+ PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_0(
+ PpapiPluginMsg_NetworkMonitor_Forbidden, OnPluginMsgForbidden)
+ PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
+ PluginResource::OnReplyReceived(params, msg))
+ IPC_END_MESSAGE_MAP()
+}
+
+int32_t NetworkMonitorResource::UpdateNetworkList(
+ PP_Resource* network_list,
+ scoped_refptr<TrackedCallback> callback) {
+ if (!network_list)
+ return PP_ERROR_BADARGUMENT;
+ if (TrackedCallback::IsPending(update_callback_))
+ return PP_ERROR_INPROGRESS;
+ if (forbidden_)
+ return PP_ERROR_NOACCESS;
+
+ if (current_list_.get()) {
+ *network_list = current_list_.Release();
+ return PP_OK;
+ }
+
+ network_list_ = network_list;
+ update_callback_ = callback;
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void NetworkMonitorResource::OnPluginMsgNetworkList(
+ const ResourceMessageReplyParams& params,
+ const SerializedNetworkList& list) {
+ current_list_ = ScopedPPResource(
+ new NetworkListResource(pp_instance(), list));
+
+ if (TrackedCallback::IsPending(update_callback_)) {
+ *network_list_ = current_list_.Release();
+ update_callback_->Run(PP_OK);
+ }
+}
+
+void NetworkMonitorResource::OnPluginMsgForbidden(
+ const ResourceMessageReplyParams& params) {
+ forbidden_ = true;
+
+ if (TrackedCallback::IsPending(update_callback_))
+ update_callback_->Run(PP_ERROR_NOACCESS);
+}
+
+} // namespace proxy
+} // namespace ppapi
diff --git a/ppapi/proxy/network_monitor_resource.h b/ppapi/proxy/network_monitor_resource.h
new file mode 100644
index 0000000..d227934
--- /dev/null
+++ b/ppapi/proxy/network_monitor_resource.h
@@ -0,0 +1,58 @@
+// Copyright 2013 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_PROXY_NETWORK_MONITOR_RESOURCE_H_
+#define PPAPI_PROXY_NETWORK_MONITOR_RESOURCE_H_
+
+#include <list>
+
+#include "ppapi/proxy/network_list_resource.h"
+#include "ppapi/proxy/plugin_resource.h"
+#include "ppapi/shared_impl/scoped_pp_resource.h"
+#include "ppapi/thunk/ppb_network_monitor_api.h"
+
+namespace base {
+class MessageLoopProxy;
+} // namespace base
+
+namespace ppapi {
+namespace proxy {
+
+class NetworkMonitorResource : public PluginResource,
+ public thunk::PPB_NetworkMonitor_API {
+ public:
+ explicit NetworkMonitorResource(Connection connection,
+ PP_Instance instance);
+ virtual ~NetworkMonitorResource();
+
+ // PluginResource overrides.
+ ppapi::thunk::PPB_NetworkMonitor_API* AsPPB_NetworkMonitor_API() OVERRIDE;
+ virtual void OnReplyReceived(const ResourceMessageReplyParams& params,
+ const IPC::Message& msg) OVERRIDE;
+
+ // thunk::PPB_NetworkMonitor_API interface
+ virtual int32_t UpdateNetworkList(
+ PP_Resource* network_list,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+
+ private:
+ // IPC message handlers for the messages received from the browser.
+ void OnPluginMsgNetworkList(const ResourceMessageReplyParams& params,
+ const SerializedNetworkList& list);
+ void OnPluginMsgForbidden(const ResourceMessageReplyParams& params);
+
+ ScopedPPResource current_list_;
+ bool forbidden_;
+
+ // Parameters passed to UpdateNetworkList().
+ PP_Resource* network_list_;
+ scoped_refptr<TrackedCallback> update_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkMonitorResource);
+};
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_NETWORK_MONITOR_RESOURCE_H_
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index b970d36..9108ea1e 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -47,6 +47,7 @@
#include "ppapi/c/private/ppb_talk_private.h"
#include "ppapi/c/private/ppp_flash_browser_operations.h"
#include "ppapi/proxy/host_resolver_private_resource.h"
+#include "ppapi/proxy/network_list_resource.h"
#include "ppapi/proxy/ppapi_param_traits.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/proxy/resource_message_params.h"
@@ -61,7 +62,6 @@
#include "ppapi/shared_impl/ppapi_preferences.h"
#include "ppapi/shared_impl/ppb_device_ref_shared.h"
#include "ppapi/shared_impl/ppb_input_event_shared.h"
-#include "ppapi/shared_impl/ppb_network_list_private_shared.h"
#include "ppapi/shared_impl/ppb_view_shared.h"
#include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h"
#include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h"
@@ -315,7 +315,7 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::URLResponseInfoData)
IPC_STRUCT_TRAITS_MEMBER(body_as_file_ref)
IPC_STRUCT_TRAITS_END()
-IPC_STRUCT_TRAITS_BEGIN(ppapi::NetworkInfo)
+IPC_STRUCT_TRAITS_BEGIN(ppapi::proxy::SerializedNetworkInfo)
IPC_STRUCT_TRAITS_MEMBER(name)
IPC_STRUCT_TRAITS_MEMBER(type)
IPC_STRUCT_TRAITS_MEMBER(state)
@@ -625,11 +625,6 @@ IPC_MESSAGE_ROUTED2(PpapiMsg_PPPMessaging_HandleMessage,
IPC_MESSAGE_ROUTED1(PpapiMsg_PPPMouseLock_MouseLockLost,
PP_Instance /* instance */)
-// PPB_NetworkMonitor_Private.
-IPC_MESSAGE_ROUTED2(PpapiMsg_PPBNetworkMonitor_NetworkList,
- uint32 /* plugin_dispatcher_id */,
- ppapi::NetworkList /* network_list */)
-
// PPP_Printing
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPPrinting_QuerySupportedFormats,
PP_Instance /* instance */,
@@ -1082,12 +1077,6 @@ IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_DeliverSamples,
std::string /* serialized_block_info */)
#endif // !defined(OS_NACL) && !defined(NACL_WIN64)
-// PPB_NetworkMonitor_Private.
-IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBNetworkMonitor_Start,
- uint32 /* plugin_dispatcher_id */)
-IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBNetworkMonitor_Stop,
- uint32 /* plugin_dispatcher_id */)
-
// PPB_Testing.
IPC_SYNC_MESSAGE_ROUTED3_1(
PpapiHostMsg_PPBTesting_ReadImageData,
@@ -1441,6 +1430,13 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_Graphics2D_ReadImageData,
PP_Point /* top_left */)
IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Graphics2D_ReadImageDataAck)
+// NetworkMonitor.
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_NetworkMonitor_Create)
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_NetworkMonitor_NetworkList,
+ ppapi::proxy::SerializedNetworkList /* network_list */)
+IPC_MESSAGE_CONTROL0(PpapiPluginMsg_NetworkMonitor_Forbidden)
+
+
// NetworkProxy ----------------------------------------------------------------
IPC_MESSAGE_CONTROL0(PpapiHostMsg_NetworkProxy_Create)
diff --git a/ppapi/proxy/ppb_network_monitor_private_proxy.cc b/ppapi/proxy/ppb_network_monitor_private_proxy.cc
deleted file mode 100644
index 26bad03..0000000
--- a/ppapi/proxy/ppb_network_monitor_private_proxy.cc
+++ /dev/null
@@ -1,174 +0,0 @@
-// 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/proxy/ppb_network_monitor_private_proxy.h"
-
-#include "ppapi/proxy/enter_proxy.h"
-#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/shared_impl/proxy_lock.h"
-#include "ppapi/thunk/ppb_network_monitor_api.h"
-
-namespace ppapi {
-namespace proxy {
-
-class PPB_NetworkMonitor_Private_Proxy::NetworkMonitor
- : public Resource,
- public thunk::PPB_NetworkMonitor_API,
- public base::SupportsWeakPtr<
- PPB_NetworkMonitor_Private_Proxy::NetworkMonitor> {
- public:
- NetworkMonitor(PP_Instance instance,
- PPB_NetworkMonitor_Private_Proxy* proxy)
- : Resource(OBJECT_IS_PROXY, instance),
- proxy_(proxy),
- initial_list_sent_(false),
- network_list_(NULL) {
- }
-
- virtual ~NetworkMonitor() {
- if (TrackedCallback::IsPending(update_callback_))
- update_callback_->PostAbort();
- proxy_->OnNetworkMonitorDeleted(this, pp_instance());
- }
-
- // thunk::PPB_NetworkMonitor_API interface.
- virtual int32_t UpdateNetworkList(
- PP_Resource* network_list,
- scoped_refptr<TrackedCallback> callback) OVERRIDE {
- if (!network_list)
- return PP_ERROR_BADARGUMENT;
- if (TrackedCallback::IsPending(update_callback_))
- return PP_ERROR_INPROGRESS;
-
- if (current_list_ && !initial_list_sent_) {
- initial_list_sent_ = true;
- thunk::EnterResourceCreationNoLock enter(pp_instance());
- *network_list = PPB_NetworkList_Private_Shared::Create(
- OBJECT_IS_PROXY, pp_instance(), current_list_);
- return PP_OK;
- }
-
- network_list_ = network_list;
- update_callback_ = callback;
- return PP_OK_COMPLETIONPENDING;
- }
-
- // Resource overrides.
- virtual ppapi::thunk::PPB_NetworkMonitor_API*
- AsPPB_NetworkMonitor_API() OVERRIDE {
- return this;
- }
-
- // This is invoked when a network list is received for this monitor (either
- // initially or on a change).
- void OnNetworkListReceived(const scoped_refptr<NetworkListStorage>& list) {
- current_list_ = list;
-
- if (TrackedCallback::IsPending(update_callback_)) {
- initial_list_sent_ = true;
- {
- thunk::EnterResourceCreationNoLock enter(pp_instance());
- *network_list_ = PPB_NetworkList_Private_Shared::Create(
- OBJECT_IS_PROXY, pp_instance(), list);
- network_list_ = NULL;
- }
- update_callback_->Run(PP_OK);
- }
- }
-
- private:
- PPB_NetworkMonitor_Private_Proxy* proxy_;
- scoped_refptr<NetworkListStorage> current_list_;
- bool initial_list_sent_;
-
- // Parameters passed to UpdateNetworkList();
- PP_Resource* network_list_;
- scoped_refptr<TrackedCallback> update_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(NetworkMonitor);
-};
-
-PPB_NetworkMonitor_Private_Proxy::PPB_NetworkMonitor_Private_Proxy(
- Dispatcher* dispatcher)
- : InterfaceProxy(dispatcher),
- monitors_(ObserverList<NetworkMonitor>::NOTIFY_EXISTING_ONLY) {
-}
-
-PPB_NetworkMonitor_Private_Proxy::~PPB_NetworkMonitor_Private_Proxy() {
- DCHECK(!monitors_.might_have_observers());
-}
-
-// static
-PP_Resource PPB_NetworkMonitor_Private_Proxy::CreateProxyResource(
- PP_Instance instance) {
- // TODO(dmichael): Check that this thread has a valid message loop associated
- // with it.
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return 0;
- PPB_NetworkMonitor_Private_Proxy* proxy =
- static_cast<PPB_NetworkMonitor_Private_Proxy*>(
- dispatcher->GetInterfaceProxy(kApiID));
- if (!proxy)
- return 0;
-
- scoped_refptr<NetworkMonitor> result(new NetworkMonitor(instance, proxy));
-
- bool first_network_monitor = !proxy->monitors_.might_have_observers();
- proxy->monitors_.AddObserver(result.get());
- if (first_network_monitor) {
- // If that is the first network monitor then send Start message.
- PluginGlobals::Get()->GetBrowserSender()->Send(
- new PpapiHostMsg_PPBNetworkMonitor_Start(
- dispatcher->plugin_dispatcher_id()));
-
- // We could have received network list message after sending the
- // previous Stop message. This list is stale now, so reset it
- // here.
- proxy->current_list_ = NULL;
- } else if (proxy->current_list_.get()) {
- result->OnNetworkListReceived(proxy->current_list_);
- }
-
- return result->GetReference();
-}
-
-bool PPB_NetworkMonitor_Private_Proxy::OnMessageReceived(
- const IPC::Message& msg) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(PPB_NetworkMonitor_Private_Proxy, msg)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBNetworkMonitor_NetworkList,
- OnPluginMsgNetworkList)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void PPB_NetworkMonitor_Private_Proxy::OnPluginMsgNetworkList(
- uint32 plugin_dispatcher_id,
- const ppapi::NetworkList& list) {
- scoped_refptr<NetworkListStorage> list_storage(new NetworkListStorage(list));
- current_list_ = list_storage;
- FOR_EACH_OBSERVER(NetworkMonitor, monitors_,
- OnNetworkListReceived(list_storage));
-}
-
-void PPB_NetworkMonitor_Private_Proxy::OnNetworkMonitorDeleted(
- NetworkMonitor* monitor,
- PP_Instance instance) {
- monitors_.RemoveObserver(monitor);
- if (!monitors_.might_have_observers()) {
- // Send Stop message if that was the last NetworkMonitor.
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (dispatcher) {
- PluginGlobals::Get()->GetBrowserSender()->Send(
- new PpapiHostMsg_PPBNetworkMonitor_Stop(
- dispatcher->plugin_dispatcher_id()));
- }
- current_list_ = NULL;
- }
-}
-
-} // namespace proxy
-} // namespace ppapi
diff --git a/ppapi/proxy/ppb_network_monitor_private_proxy.h b/ppapi/proxy/ppb_network_monitor_private_proxy.h
deleted file mode 100644
index 7dbcbd6..0000000
--- a/ppapi/proxy/ppb_network_monitor_private_proxy.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// 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_PROXY_PPB_NETWORK_MONITOR_PRIVATE_PROXY_H_
-#define PPAPI_PROXY_PPB_NETWORK_MONITOR_PRIVATE_PROXY_H_
-
-#include <list>
-
-#include "base/observer_list.h"
-#include "ppapi/proxy/interface_proxy.h"
-#include "ppapi/shared_impl/ppb_network_list_private_shared.h"
-#include "ppapi/shared_impl/scoped_pp_resource.h"
-#include "ppapi/thunk/ppb_network_monitor_api.h"
-
-namespace base {
-class MessageLoopProxy;
-} // namespace base
-
-namespace ppapi {
-namespace proxy {
-
-class PPB_NetworkMonitor_Private_Proxy : public InterfaceProxy {
- public:
- explicit PPB_NetworkMonitor_Private_Proxy(Dispatcher* dispatcher);
- virtual ~PPB_NetworkMonitor_Private_Proxy();
-
- // Creates n NetworkManager object in the plugin process.
- static PP_Resource CreateProxyResource(PP_Instance instance);
-
- // InterfaceProxy implementation.
- virtual bool OnMessageReceived(const IPC::Message& msg);
-
- static const ApiID kApiID = API_ID_PPB_NETWORKMANAGER_PRIVATE;
-
- private:
- class NetworkMonitor;
- friend class NetworkMonitor;
-
- // IPC message handler for the messages received from the browser.
- void OnPluginMsgNetworkList(uint32 plugin_dispatcher_id,
- const ppapi::NetworkList& list);
-
- // Called by NetworkMonitor destructor.
- void OnNetworkMonitorDeleted(NetworkMonitor* monitor,
- PP_Instance instance);
-
- ObserverList<NetworkMonitor> monitors_;
-
- scoped_refptr<NetworkListStorage> current_list_;
-
- DISALLOW_COPY_AND_ASSIGN(PPB_NetworkMonitor_Private_Proxy);
-};
-
-} // namespace proxy
-} // namespace ppapi
-
-#endif // PPAPI_PROXY_PPB_NETWORK_MONITOR_PRIVATE_PROXY_H_
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc
index 3bb1140..a3ce05e 100644
--- a/ppapi/proxy/resource_creation_proxy.cc
+++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -19,6 +19,7 @@
#include "ppapi/proxy/host_resolver_private_resource.h"
#include "ppapi/proxy/host_resolver_resource.h"
#include "ppapi/proxy/net_address_resource.h"
+#include "ppapi/proxy/network_monitor_resource.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/plugin_resource_tracker.h"
@@ -30,7 +31,6 @@
#include "ppapi/proxy/ppb_flash_message_loop_proxy.h"
#include "ppapi/proxy/ppb_graphics_3d_proxy.h"
#include "ppapi/proxy/ppb_image_data_proxy.h"
-#include "ppapi/proxy/ppb_network_monitor_private_proxy.h"
#include "ppapi/proxy/ppb_video_decoder_proxy.h"
#include "ppapi/proxy/ppb_x509_certificate_private_proxy.h"
#include "ppapi/proxy/printing_resource.h"
@@ -313,7 +313,8 @@ PP_Resource ResourceCreationProxy::CreateNetAddressFromNetAddressPrivate(
PP_Resource ResourceCreationProxy::CreateNetworkMonitorPrivate(
PP_Instance instance) {
- return PPB_NetworkMonitor_Private_Proxy::CreateProxyResource(instance);
+ return (new NetworkMonitorResource(GetConnection(), instance))->
+ GetReference();
}
PP_Resource ResourceCreationProxy::CreatePrinting(PP_Instance instance) {
diff --git a/ppapi/proxy/serialized_structs.cc b/ppapi/proxy/serialized_structs.cc
index 8c984d5..d645dd8 100644
--- a/ppapi/proxy/serialized_structs.cc
+++ b/ppapi/proxy/serialized_structs.cc
@@ -80,6 +80,14 @@ void SerializedFontDescription::SetToPPBrowserFontDescription(
desc->word_spacing = word_spacing;
}
+SerializedNetworkInfo::SerializedNetworkInfo()
+ : type(PP_NETWORKLIST_UNKNOWN),
+ state(PP_NETWORKLIST_DOWN),
+ mtu(0) {
+}
+
+SerializedNetworkInfo::~SerializedNetworkInfo() {}
+
SerializedTrueTypeFontDesc::SerializedTrueTypeFontDesc()
: family(),
generic_family(),
diff --git a/ppapi/proxy/serialized_structs.h b/ppapi/proxy/serialized_structs.h
index 1f89ae2..74525f3 100644
--- a/ppapi/proxy/serialized_structs.h
+++ b/ppapi/proxy/serialized_structs.h
@@ -16,6 +16,8 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_rect.h"
+#include "ppapi/c/private/ppb_net_address_private.h"
+#include "ppapi/c/private/ppb_network_list_private.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/shared_impl/host_resource.h"
@@ -57,6 +59,19 @@ struct PPAPI_PROXY_EXPORT SerializedFontDescription {
int32_t word_spacing;
};
+struct PPAPI_PROXY_EXPORT SerializedNetworkInfo {
+ SerializedNetworkInfo();
+ ~SerializedNetworkInfo();
+
+ 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<SerializedNetworkInfo> SerializedNetworkList;
+
struct PPAPI_PROXY_EXPORT SerializedTrueTypeFontDesc {
SerializedTrueTypeFontDesc();
~SerializedTrueTypeFontDesc();
diff --git a/ppapi/shared_impl/api_id.h b/ppapi/shared_impl/api_id.h
index 49e0dcb..c482a02 100644
--- a/ppapi/shared_impl/api_id.h
+++ b/ppapi/shared_impl/api_id.h
@@ -35,7 +35,6 @@ enum ApiID {
API_ID_PPB_IMAGE_DATA,
API_ID_PPB_INSTANCE,
API_ID_PPB_INSTANCE_PRIVATE,
- API_ID_PPB_NETWORKMANAGER_PRIVATE,
API_ID_PPB_OPENGLES2,
API_ID_PPB_PDF,
API_ID_PPB_SURFACE_3D,
diff --git a/ppapi/shared_impl/ppb_network_list_private_shared.cc b/ppapi/shared_impl/ppb_network_list_private_shared.cc
deleted file mode 100644
index d299c06..0000000
--- a/ppapi/shared_impl/ppb_network_list_private_shared.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-// 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/array_writer.h"
-#include "ppapi/shared_impl/ppb_network_list_private_shared.h"
-#include "ppapi/shared_impl/var.h"
-#include "ppapi/thunk/enter.h"
-
-namespace ppapi {
-
-NetworkInfo::NetworkInfo()
- : type(PP_NETWORKLIST_UNKNOWN),
- state(PP_NETWORKLIST_DOWN),
- mtu(0) {
-}
-
-NetworkInfo::~NetworkInfo() {
-}
-
-NetworkListStorage::NetworkListStorage(const NetworkList& list)
- : list_(list) {
-}
-
-NetworkListStorage::~NetworkListStorage() {
-}
-
-PPB_NetworkList_Private_Shared::PPB_NetworkList_Private_Shared(
- ResourceObjectType type,
- PP_Instance instance,
- const scoped_refptr<NetworkListStorage>& list)
- : Resource(type, instance),
- list_(list) {
-}
-
-PPB_NetworkList_Private_Shared::~PPB_NetworkList_Private_Shared() {
-}
-
-// static
-PP_Resource PPB_NetworkList_Private_Shared::Create(
- ResourceObjectType type,
- PP_Instance instance,
- const scoped_refptr<NetworkListStorage>& list) {
- scoped_refptr<PPB_NetworkList_Private_Shared> object(
- new PPB_NetworkList_Private_Shared(type, instance, list));
- return object->GetReference();
-}
-
-::ppapi::thunk::PPB_NetworkList_API*
-PPB_NetworkList_Private_Shared::AsPPB_NetworkList_API() {
- return this;
-}
-
-const NetworkList& PPB_NetworkList_Private_Shared::GetNetworkListData() const {
- return list_->list();
-}
-
-uint32_t PPB_NetworkList_Private_Shared::GetCount() {
- return static_cast<uint32_t>(list_->list().size());
-}
-
-PP_Var PPB_NetworkList_Private_Shared::GetName(uint32_t index) {
- if (index >= list_->list().size())
- return PP_MakeUndefined();
- return StringVar::StringToPPVar(list_->list().at(index).name);
-}
-
-PP_NetworkListType_Private PPB_NetworkList_Private_Shared::GetType(
- uint32_t index) {
- if (index >= list_->list().size())
- return PP_NETWORKLIST_UNKNOWN;
- return list_->list().at(index).type;
-}
-
-PP_NetworkListState_Private PPB_NetworkList_Private_Shared::GetState(
- uint32_t index) {
- if (index >= list_->list().size())
- return PP_NETWORKLIST_DOWN;
- return list_->list().at(index).state;
-}
-
-int32_t PPB_NetworkList_Private_Shared::GetIpAddresses(
- uint32_t index,
- const PP_ArrayOutput& output) {
- ArrayWriter writer(output);
- if (index >= list_->list().size() || !writer.is_valid())
- return PP_ERROR_BADARGUMENT;
-
- thunk::EnterResourceCreationNoLock enter(pp_instance());
- if (enter.failed())
- return PP_ERROR_FAILED;
-
- const std::vector<PP_NetAddress_Private>& addresses =
- list_->list().at(index).addresses;
- std::vector<PP_Resource> addr_resources;
- for (size_t i = 0; i < addresses.size(); ++i) {
- addr_resources.push_back(
- enter.functions()->CreateNetAddressFromNetAddressPrivate(
- pp_instance(), addresses[i]));
- }
- if (!writer.StoreResourceVector(addr_resources))
- return PP_ERROR_FAILED;
-
- return PP_OK;
-}
-
-PP_Var PPB_NetworkList_Private_Shared::GetDisplayName(uint32_t index) {
- if (index >= list_->list().size())
- return PP_MakeUndefined();
- return StringVar::StringToPPVar(list_->list().at(index).display_name);
-}
-
-uint32_t PPB_NetworkList_Private_Shared::GetMTU(uint32_t index) {
- if (index >= list_->list().size())
- return 0;
- return list_->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
deleted file mode 100644
index 8396003..0000000
--- a/ppapi/shared_impl/ppb_network_list_private_shared.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// 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 <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "ppapi/c/private/ppb_net_address_private.h"
-#include "ppapi/shared_impl/resource.h"
-#include "ppapi/thunk/ppb_network_list_api.h"
-
-namespace ppapi {
-
-struct PPAPI_SHARED_EXPORT 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;
-
-// NetworkListStorage is refcounted container for NetworkList. It
-// allows sharing of one NetworkList object between multiple
-// NetworkList resources.
-class PPAPI_SHARED_EXPORT NetworkListStorage
- : public base::RefCountedThreadSafe<NetworkListStorage> {
- public:
- explicit NetworkListStorage(const NetworkList& list);
-
- const NetworkList& list() { return list_; }
-
- private:
- friend class base::RefCountedThreadSafe<NetworkListStorage>;
- ~NetworkListStorage();
-
- NetworkList list_;
-
- DISALLOW_COPY_AND_ASSIGN(NetworkListStorage);
-};
-
-class PPAPI_SHARED_EXPORT PPB_NetworkList_Private_Shared
- : public ::ppapi::Resource,
- public ::ppapi::thunk::PPB_NetworkList_API {
- public:
- static PP_Resource Create(ResourceObjectType type,
- PP_Instance instance,
- const scoped_refptr<NetworkListStorage>& list);
-
- virtual ~PPB_NetworkList_Private_Shared();
-
- // Resource override.
- virtual ::ppapi::thunk::PPB_NetworkList_API*
- AsPPB_NetworkList_API() OVERRIDE;
-
- // PPB_NetworkList_API implementation.
- virtual const NetworkList& GetNetworkListData() const OVERRIDE;
- 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,
- const PP_ArrayOutput& output) 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,
- const scoped_refptr<NetworkListStorage>& list);
-
- scoped_refptr<NetworkListStorage> 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/thunk/interfaces_ppb_private_no_permissions.h b/ppapi/thunk/interfaces_ppb_private_no_permissions.h
index 13a60d1..de1faad 100644
--- a/ppapi/thunk/interfaces_ppb_private_no_permissions.h
+++ b/ppapi/thunk/interfaces_ppb_private_no_permissions.h
@@ -9,8 +9,6 @@
// These interfaces don't require private permissions. However, they only work
// for whitelisted origins.
-UNPROXIED_API(PPB_NetworkList_Private)
-PROXIED_API(PPB_NetworkMonitor_Private)
PROXIED_IFACE(NoAPIName, PPB_HOSTRESOLVER_PRIVATE_INTERFACE_0_1,
PPB_HostResolver_Private_0_1)
@@ -39,8 +37,7 @@ PROXIED_IFACE(NoAPIName, PPB_NETADDRESS_PRIVATE_INTERFACE_1_1,
PPB_NetAddress_Private_1_1)
PROXIED_IFACE(NoAPIName, PPB_NETWORKLIST_PRIVATE_INTERFACE_0_3,
PPB_NetworkList_Private_0_3)
-PROXIED_IFACE(PPB_NetworkMonitor_Private,
- PPB_NETWORKMONITOR_PRIVATE_INTERFACE_0_3,
+PROXIED_IFACE(NoAPIName, PPB_NETWORKMONITOR_PRIVATE_INTERFACE_0_3,
PPB_NetworkMonitor_Private_0_3)
PROXIED_IFACE(NoAPIName, PPB_EXT_CRXFILESYSTEM_PRIVATE_INTERFACE_0_1,
diff --git a/ppapi/thunk/ppb_network_list_api.h b/ppapi/thunk/ppb_network_list_api.h
index b8fb9a3..661399a 100644
--- a/ppapi/thunk/ppb_network_list_api.h
+++ b/ppapi/thunk/ppb_network_list_api.h
@@ -11,20 +11,12 @@
#include "ppapi/thunk/ppapi_thunk_export.h"
namespace ppapi {
-
-struct NetworkInfo;
-typedef std::vector<NetworkInfo> NetworkList;
-
namespace thunk {
class PPAPI_THUNK_EXPORT PPB_NetworkList_API {
public:
virtual ~PPB_NetworkList_API() {}
- // This function is not exposed through the C API, but returns the
- // internal data for easy proxying.
- virtual const NetworkList& GetNetworkListData() const = 0;
-
// Private API
virtual uint32_t GetCount() = 0;
virtual PP_Var GetName(uint32_t index) = 0;