Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Unified Diff: ppapi/proxy/host_dispatcher.cc

Issue 6286070: Remove all uses of the global Dispatcher Get function. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/host_dispatcher.h ('k') | ppapi/proxy/host_dispatcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/host_dispatcher.cc
===================================================================
--- ppapi/proxy/host_dispatcher.cc (revision 74021)
+++ ppapi/proxy/host_dispatcher.cc (working copy)
@@ -30,6 +30,9 @@
static_cast<const PPB_Var_Deprecated*>(
local_get_interface(PPB_VAR_DEPRECATED_INTERFACE));
SetSerializationRules(new HostVarSerializationRules(var_interface, module));
+
+ memset(plugin_interface_support_, 0,
+ sizeof(PluginInterfaceSupport) * INTERFACE_ID_COUNT);
}
HostDispatcher::~HostDispatcher() {
@@ -76,6 +79,68 @@
return false;
}
+bool HostDispatcher::OnMessageReceived(const IPC::Message& msg) {
+ // Handle common control messages.
+ if (Dispatcher::OnMessageReceived(msg))
+ return true;
+
+ if (msg.routing_id() <= 0 && msg.routing_id() >= INTERFACE_ID_COUNT) {
+ NOTREACHED();
+ // TODO(brettw): kill the plugin if it starts sending invalid messages?
+ return true;
+ }
+
+ InterfaceProxy* proxy = target_proxies_[msg.routing_id()].get();
+ if (!proxy) {
+ // Autocreate any proxy objects to handle requests from the plugin. Since
+ // we always support all known PPB_* interfaces (modulo the trusted bit),
+ // there's very little checking necessary.
+ const InterfaceProxy::Info* info = GetPPBInterfaceInfo(
+ static_cast<InterfaceID>(msg.routing_id()));
+ if (!info ||
+ (info->is_trusted && disallow_trusted_interfaces()))
+ return true;
+
+ const void* local_interface = GetLocalInterface(info->name);
+ if (!local_interface) {
+ // This should always succeed since the browser should support the stuff
+ // the proxy does. If this happens, something is out of sync.
+ NOTREACHED();
+ return true;
+ }
+
+ proxy = info->create_proxy(this, local_interface);
+ target_proxies_[info->id].reset(proxy);
+ }
+
+ return proxy->OnMessageReceived(msg);
+}
+
+const void* HostDispatcher::GetProxiedInterface(const std::string& interface) {
+ // First see if we even have a proxy for this interface.
+ const InterfaceProxy::Info* info = GetPPPInterfaceInfo(interface);
+ if (!info)
+ return NULL;
+
+ if (plugin_interface_support_[static_cast<int>(info->id)] !=
+ INTERFACE_UNQUERIED) {
+ // Already queried the plugin if it supports this interface.
+ if (plugin_interface_support_[info->id] == INTERFACE_SUPPORTED)
+ return info->interface;
+ return NULL;
+ }
+
+ // Need to re-query. Cache the result so we only do this once.
+ bool supported = false;
+ Send(new PpapiMsg_SupportsInterface(interface, &supported));
+ plugin_interface_support_[static_cast<int>(info->id)] =
+ supported ? INTERFACE_SUPPORTED : INTERFACE_UNSUPPORTED;
+
+ if (supported)
+ return info->interface;
+ return NULL;
+}
+
} // namespace proxy
} // namespace pp
« no previous file with comments | « ppapi/proxy/host_dispatcher.h ('k') | ppapi/proxy/host_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698