diff options
author | ikarienator@chromium.org <ikarienator@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 00:19:10 +0000 |
---|---|---|
committer | ikarienator@chromium.org <ikarienator@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 00:19:10 +0000 |
commit | ea4d18bcd417746286f009a0cadf51ebe408f3de (patch) | |
tree | 364d037655b6f89300be744ec51bda692eb5c498 /ppapi/proxy | |
parent | 50106bf5210c384f90a45cad94992ed22f931cac (diff) | |
download | chromium_src-ea4d18bcd417746286f009a0cadf51ebe408f3de.zip chromium_src-ea4d18bcd417746286f009a0cadf51ebe408f3de.tar.gz chromium_src-ea4d18bcd417746286f009a0cadf51ebe408f3de.tar.bz2 |
Revert 223482 "Simplify PPB_NetworkMonitor proxy."
> 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
TBR=sergeyu@chromium.org
Review URL: https://codereview.chromium.org/23463037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223484 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r-- | ppapi/proxy/interface_list.cc | 1 | ||||
-rw-r--r-- | ppapi/proxy/network_list_resource.cc | 89 | ||||
-rw-r--r-- | ppapi/proxy/network_list_resource.h | 52 | ||||
-rw-r--r-- | ppapi/proxy/network_monitor_resource.cc | 85 | ||||
-rw-r--r-- | ppapi/proxy/network_monitor_resource.h | 58 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 22 | ||||
-rw-r--r-- | ppapi/proxy/ppb_network_monitor_private_proxy.cc | 174 | ||||
-rw-r--r-- | ppapi/proxy/ppb_network_monitor_private_proxy.h | 58 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.cc | 5 | ||||
-rw-r--r-- | ppapi/proxy/serialized_structs.cc | 8 | ||||
-rw-r--r-- | ppapi/proxy/serialized_structs.h | 15 |
11 files changed, 248 insertions, 319 deletions
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 409f12f..115516f 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -107,6 +107,7 @@ #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 deleted file mode 100644 index 789e4f2..0000000 --- a/ppapi/proxy/network_list_resource.cc +++ /dev/null @@ -1,89 +0,0 @@ -// 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 deleted file mode 100644 index 618ba02..0000000 --- a/ppapi/proxy/network_list_resource.h +++ /dev/null @@ -1,52 +0,0 @@ -// 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 deleted file mode 100644 index 0dfb0b4..0000000 --- a/ppapi/proxy/network_monitor_resource.cc +++ /dev/null @@ -1,85 +0,0 @@ -// 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 deleted file mode 100644 index d227934..0000000 --- a/ppapi/proxy/network_monitor_resource.h +++ /dev/null @@ -1,58 +0,0 @@ -// 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 9108ea1e..b970d36 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -47,7 +47,6 @@ #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" @@ -62,6 +61,7 @@ #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::proxy::SerializedNetworkInfo) +IPC_STRUCT_TRAITS_BEGIN(ppapi::NetworkInfo) IPC_STRUCT_TRAITS_MEMBER(name) IPC_STRUCT_TRAITS_MEMBER(type) IPC_STRUCT_TRAITS_MEMBER(state) @@ -625,6 +625,11 @@ 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 */, @@ -1077,6 +1082,12 @@ 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, @@ -1430,13 +1441,6 @@ 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 new file mode 100644 index 0000000..26bad03 --- /dev/null +++ b/ppapi/proxy/ppb_network_monitor_private_proxy.cc @@ -0,0 +1,174 @@ +// 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 new file mode 100644 index 0000000..7dbcbd6 --- /dev/null +++ b/ppapi/proxy/ppb_network_monitor_private_proxy.h @@ -0,0 +1,58 @@ +// 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 a3ce05e..3bb1140 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -19,7 +19,6 @@ #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" @@ -31,6 +30,7 @@ #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,8 +313,7 @@ PP_Resource ResourceCreationProxy::CreateNetAddressFromNetAddressPrivate( PP_Resource ResourceCreationProxy::CreateNetworkMonitorPrivate( PP_Instance instance) { - return (new NetworkMonitorResource(GetConnection(), instance))-> - GetReference(); + return PPB_NetworkMonitor_Private_Proxy::CreateProxyResource(instance); } PP_Resource ResourceCreationProxy::CreatePrinting(PP_Instance instance) { diff --git a/ppapi/proxy/serialized_structs.cc b/ppapi/proxy/serialized_structs.cc index d645dd8..8c984d5 100644 --- a/ppapi/proxy/serialized_structs.cc +++ b/ppapi/proxy/serialized_structs.cc @@ -80,14 +80,6 @@ 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 74525f3..1f89ae2 100644 --- a/ppapi/proxy/serialized_structs.h +++ b/ppapi/proxy/serialized_structs.h @@ -16,8 +16,6 @@ #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" @@ -59,19 +57,6 @@ 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(); |