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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppp_instance_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/ppp_instance_proxy.h" 5 #include "ppapi/proxy/ppp_instance_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ppapi/c/pp_var.h" 9 #include "ppapi/c/pp_var.h"
10 #include "ppapi/c/ppp_instance.h" 10 #include "ppapi/c/ppp_instance.h"
11 #include "ppapi/proxy/host_dispatcher.h" 11 #include "ppapi/proxy/host_dispatcher.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 static const PPP_Instance instance_interface = { 93 static const PPP_Instance instance_interface = {
94 &DidCreate, 94 &DidCreate,
95 &DidDestroy, 95 &DidDestroy,
96 &DidChangeView, 96 &DidChangeView,
97 &DidChangeFocus, 97 &DidChangeFocus,
98 &HandleInputEvent, 98 &HandleInputEvent,
99 &HandleDocumentLoad, 99 &HandleDocumentLoad,
100 &GetInstanceObject 100 &GetInstanceObject
101 }; 101 };
102 102
103 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher,
104 const void* target_interface) {
105 return new PPP_Instance_Proxy(dispatcher, target_interface);
106 }
107
103 } // namespace 108 } // namespace
104 109
105 PPP_Instance_Proxy::PPP_Instance_Proxy(Dispatcher* dispatcher, 110 PPP_Instance_Proxy::PPP_Instance_Proxy(Dispatcher* dispatcher,
106 const void* target_interface) 111 const void* target_interface)
107 : InterfaceProxy(dispatcher, target_interface) { 112 : InterfaceProxy(dispatcher, target_interface) {
108 } 113 }
109 114
110 PPP_Instance_Proxy::~PPP_Instance_Proxy() { 115 PPP_Instance_Proxy::~PPP_Instance_Proxy() {
111 } 116 }
112 117
113 const void* PPP_Instance_Proxy::GetSourceInterface() const { 118 // static
114 return &instance_interface; 119 const InterfaceProxy::Info* PPP_Instance_Proxy::GetInfo() {
115 } 120 static const Info info = {
116 121 &instance_interface,
117 InterfaceID PPP_Instance_Proxy::GetInterfaceId() const { 122 PPP_INSTANCE_INTERFACE,
118 return INTERFACE_ID_PPP_INSTANCE; 123 INTERFACE_ID_PPP_INSTANCE,
124 false,
125 &CreateInstanceProxy,
126 };
127 return &info;
119 } 128 }
120 129
121 bool PPP_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { 130 bool PPP_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
122 bool handled = true; 131 bool handled = true;
123 IPC_BEGIN_MESSAGE_MAP(PPP_Instance_Proxy, msg) 132 IPC_BEGIN_MESSAGE_MAP(PPP_Instance_Proxy, msg)
124 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidCreate, 133 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidCreate,
125 OnMsgDidCreate) 134 OnMsgDidCreate)
126 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidDestroy, 135 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidDestroy,
127 OnMsgDidDestroy) 136 OnMsgDidDestroy)
128 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidChangeView, 137 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidChangeView,
(...skipping 13 matching lines...) Expand all
142 151
143 void PPP_Instance_Proxy::OnMsgDidCreate( 152 void PPP_Instance_Proxy::OnMsgDidCreate(
144 PP_Instance instance, 153 PP_Instance instance,
145 const std::vector<std::string>& argn, 154 const std::vector<std::string>& argn,
146 const std::vector<std::string>& argv, 155 const std::vector<std::string>& argv,
147 PP_Bool* result) { 156 PP_Bool* result) {
148 *result = PP_FALSE; 157 *result = PP_FALSE;
149 if (argn.size() != argv.size()) 158 if (argn.size() != argv.size())
150 return; 159 return;
151 160
152 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 161 // Set up the routing associating this new instance with the dispatcher we
153 if (!dispatcher) 162 // just got the message from. This must be done before calling into the
154 return; 163 // plugin so it can in turn call PPAPI functions.
155 dispatcher->DidCreateInstance(instance); 164 PluginDispatcher* plugin_dispatcher =
165 static_cast<PluginDispatcher*>(dispatcher());
166 plugin_dispatcher->DidCreateInstance(instance);
156 167
157 // Make sure the arrays always have at least one element so we can take the 168 // Make sure the arrays always have at least one element so we can take the
158 // address below. 169 // address below.
159 std::vector<const char*> argn_array( 170 std::vector<const char*> argn_array(
160 std::max(static_cast<size_t>(1), argn.size())); 171 std::max(static_cast<size_t>(1), argn.size()));
161 std::vector<const char*> argv_array( 172 std::vector<const char*> argv_array(
162 std::max(static_cast<size_t>(1), argn.size())); 173 std::max(static_cast<size_t>(1), argn.size()));
163 for (size_t i = 0; i < argn.size(); i++) { 174 for (size_t i = 0; i < argn.size(); i++) {
164 argn_array[i] = argn[i].c_str(); 175 argn_array[i] = argn[i].c_str();
165 argv_array[i] = argv[i].c_str(); 176 argv_array[i] = argv[i].c_str();
166 } 177 }
167 178
168 DCHECK(ppp_instance_target()); 179 DCHECK(ppp_instance_target());
169 *result = ppp_instance_target()->DidCreate(instance, 180 *result = ppp_instance_target()->DidCreate(instance,
170 static_cast<uint32_t>(argn.size()), 181 static_cast<uint32_t>(argn.size()),
171 &argn_array[0], &argv_array[0]); 182 &argn_array[0], &argv_array[0]);
172 DCHECK(*result); 183 if (!*result) {
184 // In the failure to create case, this plugin instance will be torn down
185 // without further notification, so we also need to undo the routing.
186 plugin_dispatcher->DidDestroyInstance(instance);
187 }
173 } 188 }
174 189
175 void PPP_Instance_Proxy::OnMsgDidDestroy(PP_Instance instance) { 190 void PPP_Instance_Proxy::OnMsgDidDestroy(PP_Instance instance) {
176 ppp_instance_target()->DidDestroy(instance); 191 ppp_instance_target()->DidDestroy(instance);
177 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 192 static_cast<PluginDispatcher*>(dispatcher())->DidDestroyInstance(instance);
178 if (!dispatcher)
179 return;
180
181 dispatcher->DidDestroyInstance(instance);
182 } 193 }
183 194
184 void PPP_Instance_Proxy::OnMsgDidChangeView(PP_Instance instance, 195 void PPP_Instance_Proxy::OnMsgDidChangeView(PP_Instance instance,
185 const PP_Rect& position, 196 const PP_Rect& position,
186 const PP_Rect& clip) { 197 const PP_Rect& clip) {
187 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 198 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
188 if (!dispatcher) 199 if (!dispatcher)
189 return; 200 return;
190 InstanceData* data = dispatcher->GetInstanceData(instance); 201 InstanceData* data = dispatcher->GetInstanceData(instance);
191 if (!data) 202 if (!data)
(...skipping 24 matching lines...) Expand all
216 227
217 void PPP_Instance_Proxy::OnMsgGetInstanceObject( 228 void PPP_Instance_Proxy::OnMsgGetInstanceObject(
218 PP_Instance instance, 229 PP_Instance instance,
219 SerializedVarReturnValue result) { 230 SerializedVarReturnValue result) {
220 result.Return(dispatcher(), 231 result.Return(dispatcher(),
221 ppp_instance_target()->GetInstanceObject(instance)); 232 ppp_instance_target()->GetInstanceObject(instance));
222 } 233 }
223 234
224 } // namespace proxy 235 } // namespace proxy
225 } // namespace pp 236 } // namespace pp
OLDNEW
« 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