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

Unified Diff: ppapi/proxy/ppp_instance_proxy.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/ppp_instance_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/ppp_instance_proxy.cc
===================================================================
--- ppapi/proxy/ppp_instance_proxy.cc (revision 74021)
+++ ppapi/proxy/ppp_instance_proxy.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -100,6 +100,11 @@
&GetInstanceObject
};
+InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher,
+ const void* target_interface) {
+ return new PPP_Instance_Proxy(dispatcher, target_interface);
+}
+
} // namespace
PPP_Instance_Proxy::PPP_Instance_Proxy(Dispatcher* dispatcher,
@@ -110,14 +115,18 @@
PPP_Instance_Proxy::~PPP_Instance_Proxy() {
}
-const void* PPP_Instance_Proxy::GetSourceInterface() const {
- return &instance_interface;
+// static
+const InterfaceProxy::Info* PPP_Instance_Proxy::GetInfo() {
+ static const Info info = {
+ &instance_interface,
+ PPP_INSTANCE_INTERFACE,
+ INTERFACE_ID_PPP_INSTANCE,
+ false,
+ &CreateInstanceProxy,
+ };
+ return &info;
}
-InterfaceID PPP_Instance_Proxy::GetInterfaceId() const {
- return INTERFACE_ID_PPP_INSTANCE;
-}
-
bool PPP_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PPP_Instance_Proxy, msg)
@@ -149,10 +158,12 @@
if (argn.size() != argv.size())
return;
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return;
- dispatcher->DidCreateInstance(instance);
+ // Set up the routing associating this new instance with the dispatcher we
+ // just got the message from. This must be done before calling into the
+ // plugin so it can in turn call PPAPI functions.
+ PluginDispatcher* plugin_dispatcher =
+ static_cast<PluginDispatcher*>(dispatcher());
+ plugin_dispatcher->DidCreateInstance(instance);
// Make sure the arrays always have at least one element so we can take the
// address below.
@@ -169,16 +180,16 @@
*result = ppp_instance_target()->DidCreate(instance,
static_cast<uint32_t>(argn.size()),
&argn_array[0], &argv_array[0]);
- DCHECK(*result);
+ if (!*result) {
+ // In the failure to create case, this plugin instance will be torn down
+ // without further notification, so we also need to undo the routing.
+ plugin_dispatcher->DidDestroyInstance(instance);
+ }
}
void PPP_Instance_Proxy::OnMsgDidDestroy(PP_Instance instance) {
ppp_instance_target()->DidDestroy(instance);
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return;
-
- dispatcher->DidDestroyInstance(instance);
+ static_cast<PluginDispatcher*>(dispatcher())->DidDestroyInstance(instance);
}
void PPP_Instance_Proxy::OnMsgDidChangeView(PP_Instance instance,
« no previous file with comments | « ppapi/proxy/ppp_instance_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698