summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy
diff options
context:
space:
mode:
authorygorshenin@chromium.org <ygorshenin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-12 12:50:46 +0000
committerygorshenin@chromium.org <ygorshenin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-12 12:50:46 +0000
commit6a68537cb2c5f7458c41829234aafe5bae466892 (patch)
tree4e083ab4e39e351fbedd376196612fb650f7d45e /ppapi/proxy
parent01e74f584c59c1e56582c486d70bb025e40ec527 (diff)
downloadchromium_src-6a68537cb2c5f7458c41829234aafe5bae466892.zip
chromium_src-6a68537cb2c5f7458c41829234aafe5bae466892.tar.gz
chromium_src-6a68537cb2c5f7458c41829234aafe5bae466892.tar.bz2
PPB_HostResolver_Private is switched to the new Pepper proxy.
Blocked on https://chromiumcodereview.appspot.com/11434042. BUG=163861 TEST=browser_tests:*HostResolverPrivate* Review URL: https://chromiumcodereview.appspot.com/11411357 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r--ppapi/proxy/host_resolver_private_resource.cc97
-rw-r--r--ppapi/proxy/host_resolver_private_resource.h73
-rw-r--r--ppapi/proxy/interface_list.cc1
-rw-r--r--ppapi/proxy/ppapi_messages.h26
-rw-r--r--ppapi/proxy/ppb_host_resolver_private_proxy.cc122
-rw-r--r--ppapi/proxy/ppb_host_resolver_private_proxy.h44
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc5
7 files changed, 182 insertions, 186 deletions
diff --git a/ppapi/proxy/host_resolver_private_resource.cc b/ppapi/proxy/host_resolver_private_resource.cc
new file mode 100644
index 0000000..68cf831
--- /dev/null
+++ b/ppapi/proxy/host_resolver_private_resource.cc
@@ -0,0 +1,97 @@
+// 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/host_resolver_private_resource.h"
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/var.h"
+
+namespace ppapi {
+namespace proxy {
+
+HostResolverPrivateResource::HostResolverPrivateResource(Connection connection,
+ PP_Instance instance)
+ : PluginResource(connection, instance) {
+ SendCreate(BROWSER, PpapiHostMsg_HostResolverPrivate_Create());
+}
+
+HostResolverPrivateResource::~HostResolverPrivateResource() {
+}
+
+thunk::PPB_HostResolver_Private_API*
+HostResolverPrivateResource::AsPPB_HostResolver_Private_API() {
+ return this;
+}
+
+int32_t HostResolverPrivateResource::Resolve(
+ const char* host,
+ uint16_t port,
+ const PP_HostResolver_Private_Hint* hint,
+ scoped_refptr<TrackedCallback> callback) {
+ if (!host)
+ return PP_ERROR_BADARGUMENT;
+ if (ResolveInProgress())
+ return PP_ERROR_INPROGRESS;
+
+ resolve_callback_ = callback;
+
+ HostPortPair host_port;
+ host_port.host = host;
+ host_port.port = port;
+
+ SendResolve(host_port, hint);
+ return PP_OK_COMPLETIONPENDING;
+}
+
+PP_Var HostResolverPrivateResource::GetCanonicalName() {
+ return StringVar::StringToPPVar(canonical_name_);
+}
+
+uint32_t HostResolverPrivateResource::GetSize() {
+ if (ResolveInProgress())
+ return 0;
+ return static_cast<uint32_t>(net_address_list_.size());
+}
+
+bool HostResolverPrivateResource::GetNetAddress(
+ uint32 index,
+ PP_NetAddress_Private* address) {
+ if (ResolveInProgress() || index >= GetSize())
+ return false;
+ *address = net_address_list_[index];
+ return true;
+}
+
+void HostResolverPrivateResource::OnPluginMsgResolveReply(
+ const ResourceMessageReplyParams& params,
+ const std::string& canonical_name,
+ const std::vector<PP_NetAddress_Private>& net_address_list) {
+ if (params.result() == PP_OK) {
+ canonical_name_ = canonical_name;
+ net_address_list_ = net_address_list;
+ } else {
+ canonical_name_.clear();
+ net_address_list_.clear();
+ }
+ resolve_callback_->Run(params.result());
+}
+
+void HostResolverPrivateResource::SendResolve(
+ const HostPortPair& host_port,
+ const PP_HostResolver_Private_Hint* hint) {
+ PpapiHostMsg_HostResolverPrivate_Resolve msg(host_port, *hint);
+ Call<PpapiPluginMsg_HostResolverPrivate_ResolveReply>(
+ BROWSER,
+ msg,
+ base::Bind(&HostResolverPrivateResource::OnPluginMsgResolveReply,
+ base::Unretained(this)));
+}
+
+bool HostResolverPrivateResource::ResolveInProgress() const {
+ return TrackedCallback::IsPending(resolve_callback_);
+}
+
+} // namespace proxy
+} // namespace ppapi
diff --git a/ppapi/proxy/host_resolver_private_resource.h b/ppapi/proxy/host_resolver_private_resource.h
new file mode 100644
index 0000000..d751603c8
--- /dev/null
+++ b/ppapi/proxy/host_resolver_private_resource.h
@@ -0,0 +1,73 @@
+// 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_HOST_RESOLVER_PRIVATE_RESOURCE_H_
+#define PPAPI_PROXY_HOST_RESOLVER_PRIVATE_RESOURCE_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "ppapi/proxy/plugin_resource.h"
+#include "ppapi/proxy/ppapi_proxy_export.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/thunk/ppb_host_resolver_private_api.h"
+
+namespace ppapi {
+
+struct HostPortPair {
+ std::string host;
+ uint16_t port;
+};
+
+namespace proxy {
+
+class PPAPI_PROXY_EXPORT HostResolverPrivateResource
+ : public PluginResource,
+ public thunk::PPB_HostResolver_Private_API {
+ public:
+ HostResolverPrivateResource(Connection connection,
+ PP_Instance instance);
+ virtual ~HostResolverPrivateResource();
+
+ // PluginResource overrides.
+ virtual thunk::PPB_HostResolver_Private_API*
+ AsPPB_HostResolver_Private_API() OVERRIDE;
+
+ // PPB_HostResolver_Private_API implementation.
+ virtual int32_t Resolve(const char* host,
+ uint16_t port,
+ const PP_HostResolver_Private_Hint* hint,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual PP_Var GetCanonicalName() OVERRIDE;
+ virtual uint32_t GetSize() OVERRIDE;
+ virtual bool GetNetAddress(uint32_t index,
+ PP_NetAddress_Private* address) OVERRIDE;
+
+ private:
+ // IPC message handlers.
+ void OnPluginMsgResolveReply(
+ const ResourceMessageReplyParams& params,
+ const std::string& canonical_name,
+ const std::vector<PP_NetAddress_Private>& net_address_list);
+
+ void SendResolve(const HostPortPair& host_port,
+ const PP_HostResolver_Private_Hint* hint);
+
+ bool ResolveInProgress() const;
+
+ scoped_refptr<TrackedCallback> resolve_callback_;
+
+ std::string canonical_name_;
+ std::vector<PP_NetAddress_Private> net_address_list_;
+
+ DISALLOW_COPY_AND_ASSIGN(HostResolverPrivateResource);
+};
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_HOST_RESOLVER_PRIVATE_RESOURCE_H_
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index ef3d84a..c934347 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -86,7 +86,6 @@
#include "ppapi/proxy/ppb_file_system_proxy.h"
#include "ppapi/proxy/ppb_flash_message_loop_proxy.h"
#include "ppapi/proxy/ppb_graphics_3d_proxy.h"
-#include "ppapi/proxy/ppb_host_resolver_private_proxy.h"
#include "ppapi/proxy/ppb_image_data_proxy.h"
#include "ppapi/proxy/ppb_instance_proxy.h"
#include "ppapi/proxy/ppb_message_loop_proxy.h"
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index d6faff9..579adde 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -41,6 +41,7 @@
#include "ppapi/c/private/ppb_tcp_socket_private.h"
#include "ppapi/c/private/ppb_udp_socket_private.h"
#include "ppapi/c/private/ppp_flash_browser_operations.h"
+#include "ppapi/proxy/host_resolver_private_resource.h"
#include "ppapi/proxy/ppapi_param_traits.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/proxy/resource_message_params.h"
@@ -56,7 +57,6 @@
#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_host_resolver_shared.h"
#include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h"
#include "ppapi/shared_impl/url_request_info_data.h"
#include "ppapi/shared_impl/url_response_info_data.h"
@@ -700,14 +700,6 @@ IPC_MESSAGE_ROUTED5(PpapiMsg_PPBTCPServerSocket_AcceptACK,
PP_NetAddress_Private /* local_addr */,
PP_NetAddress_Private /* remote_addr */)
-// PPB_HostResolver_Private.
-IPC_MESSAGE_ROUTED5(PpapiMsg_PPBHostResolver_ResolveACK,
- uint32 /* plugin_dispatcher_id */,
- uint32 /* host_resolver_id */,
- bool /* succeeded */,
- std::string /* canonical_name */,
- std::vector<PP_NetAddress_Private> /* net_address_list */)
-
#if !defined(OS_NACL) && !defined(NACL_WIN64)
// PPP_Instance_Private.
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPInstancePrivate_GetInstanceObject,
@@ -1112,14 +1104,6 @@ IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBNetworkMonitor_Start,
IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBNetworkMonitor_Stop,
uint32 /* plugin_dispatcher_id */)
-// PPB_HostResolver_Private.
-IPC_MESSAGE_CONTROL5(PpapiHostMsg_PPBHostResolver_Resolve,
- int32 /* routing_id */,
- uint32 /* plugin_dispatcher_id */,
- uint32 /* host_resolver_id */,
- ppapi::HostPortPair /* host_port */,
- PP_HostResolver_Private_Hint /* hint */)
-
#if !defined(OS_NACL) && !defined(NACL_WIN64)
// PPB_PDF
IPC_SYNC_MESSAGE_ROUTED3_1(
@@ -1412,6 +1396,14 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_Graphics2D_ReadImageData,
PP_Point /* top_left */)
IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Graphics2D_ReadImageDataAck)
+// HostResolverPrivate, plugin -> host -> plugin
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_HostResolverPrivate_Create)
+IPC_MESSAGE_CONTROL2(PpapiHostMsg_HostResolverPrivate_Resolve,
+ ppapi::HostPortPair /* host_port */,
+ PP_HostResolver_Private_Hint /* hint */)
+IPC_MESSAGE_CONTROL2(PpapiPluginMsg_HostResolverPrivate_ResolveReply,
+ std::string /* canonical_name */,
+ std::vector<PP_NetAddress_Private> /* net_address_list */)
// Printing.
IPC_MESSAGE_CONTROL0(PpapiHostMsg_Printing_Create)
diff --git a/ppapi/proxy/ppb_host_resolver_private_proxy.cc b/ppapi/proxy/ppb_host_resolver_private_proxy.cc
deleted file mode 100644
index 20be2c3..0000000
--- a/ppapi/proxy/ppb_host_resolver_private_proxy.cc
+++ /dev/null
@@ -1,122 +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_host_resolver_private_proxy.h"
-
-#include <cstddef>
-#include <map>
-
-#include "base/logging.h"
-#include "ppapi/proxy/plugin_dispatcher.h"
-#include "ppapi/proxy/plugin_globals.h"
-#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/shared_impl/host_resource.h"
-
-namespace ppapi {
-namespace proxy {
-
-namespace {
-
-typedef std::map<uint32, PPB_HostResolver_Shared*> IDToHostResolverMap;
-IDToHostResolverMap* g_id_to_host_resolver = NULL;
-
-class HostResolver : public PPB_HostResolver_Shared {
- public:
- HostResolver(const HostResource& resource,
- uint32 plugin_dispatcher_id);
- virtual ~HostResolver();
-
- virtual void SendResolve(const HostPortPair& host_port,
- const PP_HostResolver_Private_Hint* hint) OVERRIDE;
-
- private:
- void SendToBrowser(IPC::Message* msg);
-
- const uint32 plugin_dispatcher_id_;
-
- DISALLOW_COPY_AND_ASSIGN(HostResolver);
-};
-
-HostResolver::HostResolver(const HostResource& resource,
- uint32 plugin_dispatcher_id)
- : PPB_HostResolver_Shared(resource),
- plugin_dispatcher_id_(plugin_dispatcher_id) {
- if (!g_id_to_host_resolver)
- g_id_to_host_resolver = new IDToHostResolverMap();
- DCHECK(g_id_to_host_resolver->find(host_resolver_id_) ==
- g_id_to_host_resolver->end());
- (*g_id_to_host_resolver)[host_resolver_id_] = this;
-}
-
-HostResolver::~HostResolver() {
- g_id_to_host_resolver->erase(host_resolver_id_);
-}
-
-void HostResolver::SendResolve(const HostPortPair& host_port,
- const PP_HostResolver_Private_Hint* hint) {
- SendToBrowser(new PpapiHostMsg_PPBHostResolver_Resolve(
- API_ID_PPB_HOSTRESOLVER_PRIVATE,
- plugin_dispatcher_id_,
- host_resolver_id_,
- host_port,
- *hint));
-}
-
-void HostResolver::SendToBrowser(IPC::Message* msg) {
- PluginGlobals::Get()->GetBrowserSender()->Send(msg);
-}
-
-} // namespace
-
-//------------------------------------------------------------------------------
-
-PPB_HostResolver_Private_Proxy::PPB_HostResolver_Private_Proxy(
- Dispatcher* dispatcher) : InterfaceProxy(dispatcher) {
-}
-
-PPB_HostResolver_Private_Proxy::~PPB_HostResolver_Private_Proxy() {
-}
-
-// static
-PP_Resource PPB_HostResolver_Private_Proxy::CreateProxyResource(
- PP_Instance instance) {
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return 0;
-
- HostResolver* host_resolver =
- new HostResolver(HostResource::MakeInstanceOnly(instance),
- dispatcher->plugin_dispatcher_id());
- return host_resolver->GetReference();
-}
-
-bool PPB_HostResolver_Private_Proxy::OnMessageReceived(
- const IPC::Message& msg) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(PPB_HostResolver_Private_Proxy, msg)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBHostResolver_ResolveACK, OnMsgResolveACK)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void PPB_HostResolver_Private_Proxy::OnMsgResolveACK(
- uint32 plugin_dispatcher_id,
- uint32 host_resolver_id,
- bool succeeded,
- const std::string& canonical_name,
- const std::vector<PP_NetAddress_Private>& net_address_list) {
- if (!g_id_to_host_resolver) {
- NOTREACHED();
- return;
- }
- IDToHostResolverMap::iterator it =
- g_id_to_host_resolver->find(host_resolver_id);
- if (it == g_id_to_host_resolver->end())
- return;
- it->second->OnResolveCompleted(succeeded, canonical_name, net_address_list);
-}
-
-} // namespace proxy
-} // namespace ppapi
diff --git a/ppapi/proxy/ppb_host_resolver_private_proxy.h b/ppapi/proxy/ppb_host_resolver_private_proxy.h
deleted file mode 100644
index 7e9b719..0000000
--- a/ppapi/proxy/ppb_host_resolver_private_proxy.h
+++ /dev/null
@@ -1,44 +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_HOST_RESOLVER_PRIVATE_PROXY_H_
-#define PPAPI_PROXY_PPB_HOST_RESOLVER_PRIVATE_PROXY_H_
-
-#include "base/basictypes.h"
-#include "ppapi/c/pp_instance.h"
-#include "ppapi/c/pp_resource.h"
-#include "ppapi/proxy/interface_proxy.h"
-#include "ppapi/shared_impl/private/ppb_host_resolver_shared.h"
-
-namespace ppapi {
-namespace proxy {
-
-class PPB_HostResolver_Private_Proxy : public InterfaceProxy {
- public:
- PPB_HostResolver_Private_Proxy(Dispatcher* dispatcher);
- virtual~PPB_HostResolver_Private_Proxy();
-
- static PP_Resource CreateProxyResource(PP_Instance instance);
-
- // InterfaceProxy implementation.
- virtual bool OnMessageReceived(const IPC::Message& msg);
-
- static const ApiID kApiID = API_ID_PPB_HOSTRESOLVER_PRIVATE;
-
- private:
- // Browser->plugin message handlers.
- void OnMsgResolveACK(
- uint32 plugin_dispatcher_id,
- uint32 host_resolver_id,
- bool succeeded,
- const std::string& canonical_name,
- const std::vector<PP_NetAddress_Private>& net_address_list);
-
- DISALLOW_COPY_AND_ASSIGN(PPB_HostResolver_Private_Proxy);
-};
-
-} // namespace proxy
-} // namespace ppapi
-
-#endif // PPAPI_PROXY_PPB_HOST_RESOLVER_PRIVATE_PROXY_H_
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc
index d8d4f7f..0216c8a 100644
--- a/ppapi/proxy/resource_creation_proxy.cc
+++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -16,6 +16,7 @@
#include "ppapi/proxy/flash_font_file_resource.h"
#include "ppapi/proxy/flash_menu_resource.h"
#include "ppapi/proxy/graphics_2d_resource.h"
+#include "ppapi/proxy/host_resolver_private_resource.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/plugin_resource_tracker.h"
@@ -27,7 +28,6 @@
#include "ppapi/proxy/ppb_file_system_proxy.h"
#include "ppapi/proxy/ppb_flash_message_loop_proxy.h"
#include "ppapi/proxy/ppb_graphics_3d_proxy.h"
-#include "ppapi/proxy/ppb_host_resolver_private_proxy.h"
#include "ppapi/proxy/ppb_image_data_proxy.h"
#include "ppapi/proxy/ppb_network_monitor_private_proxy.h"
#include "ppapi/proxy/ppb_tcp_server_socket_private_proxy.h"
@@ -230,7 +230,8 @@ PP_Resource ResourceCreationProxy::CreateGraphics3DRaw(
PP_Resource ResourceCreationProxy::CreateHostResolverPrivate(
PP_Instance instance) {
- return PPB_HostResolver_Private_Proxy::CreateProxyResource(instance);
+ return (new HostResolverPrivateResource(
+ GetConnection(), instance))->GetReference();
}
PP_Resource ResourceCreationProxy::CreateImageData(PP_Instance instance,