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

Side by Side Diff: ppapi/proxy/ppp_instance_proxy.cc

Issue 7189045: Make o.o.p. proxy handle PPP_Instance versions 0.4 and 0.5. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 9 years, 5 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') | ppapi/proxy/ppp_instance_proxy_test.cc » ('j') | 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) 2011 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/dev/ppb_fullscreen_dev.h" 9 #include "ppapi/c/dev/ppb_fullscreen_dev.h"
10 #include "ppapi/c/pp_var.h" 10 #include "ppapi/c/pp_var.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 PP_Var GetInstanceObject(PP_Instance instance) { 115 PP_Var GetInstanceObject(PP_Instance instance) {
116 Dispatcher* dispatcher = HostDispatcher::GetForInstance(instance); 116 Dispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
117 ReceiveSerializedVarReturnValue result; 117 ReceiveSerializedVarReturnValue result;
118 dispatcher->Send(new PpapiMsg_PPPInstance_GetInstanceObject( 118 dispatcher->Send(new PpapiMsg_PPPInstance_GetInstanceObject(
119 INTERFACE_ID_PPP_INSTANCE, instance, &result)); 119 INTERFACE_ID_PPP_INSTANCE, instance, &result));
120 return result.Return(dispatcher); 120 return result.Return(dispatcher);
121 } 121 }
122 122
123 static const PPP_Instance instance_interface = { 123 static const PPP_Instance_0_4 instance_interface_0_4 = {
124 &DidCreate, 124 &DidCreate,
125 &DidDestroy, 125 &DidDestroy,
126 &DidChangeView, 126 &DidChangeView,
127 &DidChangeFocus, 127 &DidChangeFocus,
128 &HandleInputEvent, 128 &HandleInputEvent,
129 &HandleDocumentLoad, 129 &HandleDocumentLoad,
130 &GetInstanceObject 130 &GetInstanceObject
131 }; 131 };
132 132
133 static const PPP_Instance_0_5 instance_interface_0_5 = {
134 &DidCreate,
135 &DidDestroy,
136 &DidChangeView,
137 &DidChangeFocus,
138 &HandleInputEvent,
139 &HandleDocumentLoad
140 };
141
142 template <class PPP_Instance_Type>
133 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher, 143 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher,
134 const void* target_interface) { 144 const void* target_interface) {
135 return new PPP_Instance_Proxy(dispatcher, target_interface); 145 return new PPP_Instance_Proxy(
146 dispatcher,
147 static_cast<const PPP_Instance_Type*>(target_interface));
136 } 148 }
137 149
138 } // namespace 150 } // namespace
139 151
140 PPP_Instance_Proxy::PPP_Instance_Proxy(Dispatcher* dispatcher,
141 const void* target_interface)
142 : InterfaceProxy(dispatcher, target_interface) {
143 }
144
145 PPP_Instance_Proxy::~PPP_Instance_Proxy() { 152 PPP_Instance_Proxy::~PPP_Instance_Proxy() {
146 } 153 }
147 154
148 // static 155 // static
149 const InterfaceProxy::Info* PPP_Instance_Proxy::GetInfo() { 156 const InterfaceProxy::Info* PPP_Instance_Proxy::GetInfo0_4() {
150 static const Info info = { 157 static const Info info = {
151 &instance_interface, 158 &instance_interface_0_4,
152 PPP_INSTANCE_INTERFACE, 159 PPP_INSTANCE_INTERFACE_0_4,
153 INTERFACE_ID_PPP_INSTANCE, 160 INTERFACE_ID_PPP_INSTANCE,
154 false, 161 false,
155 &CreateInstanceProxy, 162 &CreateInstanceProxy<PPP_Instance_0_4>
156 }; 163 };
157 return &info; 164 return &info;
158 } 165 }
166
167 // static
168 const InterfaceProxy::Info* PPP_Instance_Proxy::GetInfo0_5() {
169 static const Info info = {
170 &instance_interface_0_5,
171 PPP_INSTANCE_INTERFACE_0_5,
172 INTERFACE_ID_PPP_INSTANCE,
173 false,
174 &CreateInstanceProxy<PPP_Instance_0_5>,
175 };
176 return &info;
177 }
159 178
160 bool PPP_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { 179 bool PPP_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
161 bool handled = true; 180 bool handled = true;
162 IPC_BEGIN_MESSAGE_MAP(PPP_Instance_Proxy, msg) 181 IPC_BEGIN_MESSAGE_MAP(PPP_Instance_Proxy, msg)
163 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidCreate, 182 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidCreate,
164 OnMsgDidCreate) 183 OnMsgDidCreate)
165 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidDestroy, 184 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidDestroy,
166 OnMsgDidDestroy) 185 OnMsgDidDestroy)
167 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidChangeView, 186 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstance_DidChangeView,
168 OnMsgDidChangeView) 187 OnMsgDidChangeView)
(...skipping 30 matching lines...) Expand all
199 // address below. 218 // address below.
200 std::vector<const char*> argn_array( 219 std::vector<const char*> argn_array(
201 std::max(static_cast<size_t>(1), argn.size())); 220 std::max(static_cast<size_t>(1), argn.size()));
202 std::vector<const char*> argv_array( 221 std::vector<const char*> argv_array(
203 std::max(static_cast<size_t>(1), argn.size())); 222 std::max(static_cast<size_t>(1), argn.size()));
204 for (size_t i = 0; i < argn.size(); i++) { 223 for (size_t i = 0; i < argn.size(); i++) {
205 argn_array[i] = argn[i].c_str(); 224 argn_array[i] = argn[i].c_str();
206 argv_array[i] = argv[i].c_str(); 225 argv_array[i] = argv[i].c_str();
207 } 226 }
208 227
209 DCHECK(ppp_instance_target()); 228 DCHECK(combined_interface_.get());
210 *result = ppp_instance_target()->DidCreate(instance, 229 *result = combined_interface_->DidCreate(instance,
211 static_cast<uint32_t>(argn.size()), 230 static_cast<uint32_t>(argn.size()),
212 &argn_array[0], &argv_array[0]); 231 &argn_array[0], &argv_array[0]);
213 } 232 }
214 233
215 void PPP_Instance_Proxy::OnMsgDidDestroy(PP_Instance instance) { 234 void PPP_Instance_Proxy::OnMsgDidDestroy(PP_Instance instance) {
216 ppp_instance_target()->DidDestroy(instance); 235 combined_interface_->DidDestroy(instance);
217 static_cast<PluginDispatcher*>(dispatcher())->DidDestroyInstance(instance); 236 static_cast<PluginDispatcher*>(dispatcher())->DidDestroyInstance(instance);
218 } 237 }
219 238
220 void PPP_Instance_Proxy::OnMsgDidChangeView(PP_Instance instance, 239 void PPP_Instance_Proxy::OnMsgDidChangeView(PP_Instance instance,
221 const PP_Rect& position, 240 const PP_Rect& position,
222 const PP_Rect& clip, 241 const PP_Rect& clip,
223 PP_Bool fullscreen) { 242 PP_Bool fullscreen) {
224 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 243 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
225 if (!dispatcher) 244 if (!dispatcher)
226 return; 245 return;
227 InstanceData* data = dispatcher->GetInstanceData(instance); 246 InstanceData* data = dispatcher->GetInstanceData(instance);
228 if (!data) 247 if (!data)
229 return; 248 return;
230 data->position = position; 249 data->position = position;
231 data->fullscreen = fullscreen; 250 data->fullscreen = fullscreen;
232 ppp_instance_target()->DidChangeView(instance, &position, &clip); 251 combined_interface_->DidChangeView(instance, &position, &clip);
233 } 252 }
234 253
235 void PPP_Instance_Proxy::OnMsgDidChangeFocus(PP_Instance instance, 254 void PPP_Instance_Proxy::OnMsgDidChangeFocus(PP_Instance instance,
236 PP_Bool has_focus) { 255 PP_Bool has_focus) {
237 ppp_instance_target()->DidChangeFocus(instance, has_focus); 256 combined_interface_->DidChangeFocus(instance, has_focus);
238 } 257 }
239 258
240 void PPP_Instance_Proxy::OnMsgHandleInputEvent(PP_Instance instance, 259 void PPP_Instance_Proxy::OnMsgHandleInputEvent(PP_Instance instance,
241 const PP_InputEvent& event, 260 const PP_InputEvent& event,
242 PP_Bool* result) { 261 PP_Bool* result) {
243 *result = ppp_instance_target()->HandleInputEvent(instance, &event); 262 *result = combined_interface_->HandleInputEvent(instance, &event);
244 } 263 }
245 264
246 void PPP_Instance_Proxy::OnMsgHandleDocumentLoad(PP_Instance instance, 265 void PPP_Instance_Proxy::OnMsgHandleDocumentLoad(PP_Instance instance,
247 const HostResource& url_loader, 266 const HostResource& url_loader,
248 PP_Bool* result) { 267 PP_Bool* result) {
249 PP_Resource plugin_loader = 268 PP_Resource plugin_loader =
250 PPB_URLLoader_Proxy::TrackPluginResource(url_loader); 269 PPB_URLLoader_Proxy::TrackPluginResource(url_loader);
251 *result = ppp_instance_target()->HandleDocumentLoad( 270 *result = combined_interface_->HandleDocumentLoad(instance, plugin_loader);
252 instance, plugin_loader);
253 271
254 // This balances the one reference that TrackPluginResource() initialized it 272 // This balances the one reference that TrackPluginResource() initialized it
255 // with. The plugin will normally take an additional reference which will keep 273 // with. The plugin will normally take an additional reference which will keep
256 // the resource alive in the plugin (and the one reference in the renderer 274 // the resource alive in the plugin (and the one reference in the renderer
257 // representing all plugin references). 275 // representing all plugin references).
258 // Once all references at the plugin side are released, the renderer side will 276 // Once all references at the plugin side are released, the renderer side will
259 // be notified and release the reference added in HandleDocumentLoad() above. 277 // be notified and release the reference added in HandleDocumentLoad() above.
260 PluginResourceTracker::GetInstance()->ReleaseResource(plugin_loader); 278 PluginResourceTracker::GetInstance()->ReleaseResource(plugin_loader);
261 } 279 }
262 280
263 void PPP_Instance_Proxy::OnMsgGetInstanceObject( 281 void PPP_Instance_Proxy::OnMsgGetInstanceObject(
264 PP_Instance instance, 282 PP_Instance instance,
265 SerializedVarReturnValue result) { 283 SerializedVarReturnValue result) {
284 // GetInstanceObject_0_4 can be null if we're talking to version 0.5 or later,
285 // however the host side of the proxy should never call this function on an
286 // 0.5 or later version.
287 DCHECK(combined_interface_->GetInstanceObject_0_4);
266 result.Return(dispatcher(), 288 result.Return(dispatcher(),
267 ppp_instance_target()->GetInstanceObject(instance)); 289 combined_interface_->GetInstanceObject_0_4(instance));
268 } 290 }
269 291
270 } // namespace proxy 292 } // namespace proxy
271 } // namespace pp 293 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppp_instance_proxy.h ('k') | ppapi/proxy/ppp_instance_proxy_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698