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

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

Issue 7706021: Convert FileRefImpl and URLRequestInfo to shared_impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tests fixed Created 9 years, 3 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
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/ppb_flash_proxy.h" 5 #include "ppapi/proxy/ppb_flash_proxy.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "ppapi/c/dev/ppb_font_dev.h" 10 #include "ppapi/c/dev/ppb_font_dev.h"
11 #include "ppapi/c/dev/ppb_var_deprecated.h" 11 #include "ppapi/c/dev/ppb_var_deprecated.h"
12 #include "ppapi/c/pp_errors.h" 12 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/c/pp_resource.h" 13 #include "ppapi/c/pp_resource.h"
14 #include "ppapi/c/private/ppb_flash.h" 14 #include "ppapi/c/private/ppb_flash.h"
15 #include "ppapi/proxy/host_dispatcher.h" 15 #include "ppapi/proxy/host_dispatcher.h"
16 #include "ppapi/proxy/plugin_dispatcher.h" 16 #include "ppapi/proxy/plugin_dispatcher.h"
17 #include "ppapi/proxy/plugin_resource_tracker.h" 17 #include "ppapi/proxy/plugin_resource_tracker.h"
18 #include "ppapi/proxy/ppapi_messages.h" 18 #include "ppapi/proxy/ppapi_messages.h"
19 #include "ppapi/proxy/proxy_module.h" 19 #include "ppapi/proxy/proxy_module.h"
20 #include "ppapi/proxy/serialized_var.h" 20 #include "ppapi/proxy/serialized_var.h"
21 #include "ppapi/shared_impl/resource.h" 21 #include "ppapi/shared_impl/resource.h"
22 #include "ppapi/shared_impl/scoped_pp_resource.h"
23 #include "ppapi/thunk/enter.h"
24 #include "ppapi/thunk/ppb_url_request_info_api.h"
25 #include "ppapi/thunk/resource_creation_api.h"
22 26
23 namespace ppapi { 27 namespace ppapi {
24 namespace proxy { 28 namespace proxy {
25 29
26 namespace { 30 namespace {
27 31
28 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { 32 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) {
29 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance); 33 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance);
30 if (dispatcher) { 34 if (dispatcher) {
31 dispatcher->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( 35 dispatcher->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 92
89 ReceiveSerializedVarReturnValue result; 93 ReceiveSerializedVarReturnValue result;
90 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( 94 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL(
91 INTERFACE_ID_PPB_FLASH, instance, url, &result)); 95 INTERFACE_ID_PPB_FLASH, instance, url, &result));
92 return result.Return(dispatcher); 96 return result.Return(dispatcher);
93 } 97 }
94 98
95 int32_t Navigate(PP_Resource request_id, 99 int32_t Navigate(PP_Resource request_id,
96 const char* target, 100 const char* target,
97 bool from_user_action) { 101 bool from_user_action) {
98 Resource* request_object = 102 thunk::EnterResource<thunk::PPB_URLRequestInfo_API> enter(request_id, true);
99 PluginResourceTracker::GetInstance()->GetResource(request_id); 103 if (enter.failed())
100 if (!request_object)
101 return PP_ERROR_BADRESOURCE; 104 return PP_ERROR_BADRESOURCE;
105 PP_Instance instance = enter.resource()->pp_instance();
102 106
103 PluginDispatcher* dispatcher = 107 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
104 PluginDispatcher::GetForInstance(request_object->pp_instance());
105 if (!dispatcher) 108 if (!dispatcher)
106 return PP_ERROR_FAILED; 109 return PP_ERROR_FAILED;
107 110
108 int32_t result = PP_ERROR_FAILED; 111 int32_t result = PP_ERROR_FAILED;
109 dispatcher->Send(new PpapiHostMsg_PPBFlash_Navigate( 112 dispatcher->Send(new PpapiHostMsg_PPBFlash_Navigate(
110 INTERFACE_ID_PPB_FLASH, 113 INTERFACE_ID_PPB_FLASH,
111 request_object->host_resource(), target, from_user_action, 114 instance, enter.object()->GetData(), target, from_user_action,
112 &result)); 115 &result));
113 return result; 116 return result;
114 } 117 }
115 118
116 void RunMessageLoop(PP_Instance instance) { 119 void RunMessageLoop(PP_Instance instance) {
117 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 120 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
118 if (!dispatcher) 121 if (!dispatcher)
119 return; 122 return;
120 IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop( 123 IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop(
121 INTERFACE_ID_PPB_FLASH, instance); 124 INTERFACE_ID_PPB_FLASH, instance);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 const_cast<PP_Point*>(&params.glyph_advances[0])); 252 const_cast<PP_Point*>(&params.glyph_advances[0]));
250 } 253 }
251 254
252 void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Instance instance, 255 void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Instance instance,
253 const std::string& url, 256 const std::string& url,
254 SerializedVarReturnValue result) { 257 SerializedVarReturnValue result) {
255 result.Return(dispatcher(), ppb_flash_target()->GetProxyForURL( 258 result.Return(dispatcher(), ppb_flash_target()->GetProxyForURL(
256 instance, url.c_str())); 259 instance, url.c_str()));
257 } 260 }
258 261
259 void PPB_Flash_Proxy::OnMsgNavigate(const HostResource& request_info, 262 void PPB_Flash_Proxy::OnMsgNavigate(PP_Instance instance,
263 const PPB_URLRequestInfo_Data& data,
260 const std::string& target, 264 const std::string& target,
261 bool from_user_action, 265 bool from_user_action,
262 int32_t* result) { 266 int32_t* result) {
263 DCHECK(!dispatcher()->IsPlugin()); 267 DCHECK(!dispatcher()->IsPlugin());
268
269 // Validate the PP_Instance since we'll be constructing resources on its
270 // behalf.
271 HostDispatcher* host_dispatcher = static_cast<HostDispatcher*>(dispatcher());
272 if (HostDispatcher::GetForInstance(instance) != host_dispatcher) {
273 NOTREACHED();
274 *result = PP_ERROR_BADARGUMENT;
275 return;
276 }
277
264 // We need to allow re-entrancy here, because this may call into Javascript 278 // We need to allow re-entrancy here, because this may call into Javascript
265 // (e.g. with a "javascript:" URL), or do things like navigate away from the 279 // (e.g. with a "javascript:" URL), or do things like navigate away from the
266 // page, either one of which will need to re-enter into the plugin. 280 // page, either one of which will need to re-enter into the plugin.
267 // It is safe, because it is essentially equivalent to NPN_GetURL, where Flash 281 // It is safe, because it is essentially equivalent to NPN_GetURL, where Flash
268 // would expect re-entrancy. When running in-process, it does re-enter here. 282 // would expect re-entrancy. When running in-process, it does re-enter here.
269 static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy(); 283 host_dispatcher->set_allow_plugin_reentrancy();
270 *result = ppb_flash_target()->Navigate(request_info.host_resource(), 284
285 // Make a temporary request resource.
286 thunk::EnterFunctionNoLock<thunk::ResourceCreationAPI> enter(instance, true);
287 if (enter.failed()) {
288 *result = PP_ERROR_FAILED;
289 return;
290 }
291 ScopedPPResource request_resource(
292 ScopedPPResource::PassRef(),
293 enter.functions()->CreateURLRequestInfo(instance, data));
294
295 *result = ppb_flash_target()->Navigate(request_resource,
271 target.c_str(), 296 target.c_str(),
272 from_user_action); 297 from_user_action);
273 } 298 }
274 299
275 void PPB_Flash_Proxy::OnMsgRunMessageLoop(PP_Instance instance) { 300 void PPB_Flash_Proxy::OnMsgRunMessageLoop(PP_Instance instance) {
276 ppb_flash_target()->RunMessageLoop(instance); 301 ppb_flash_target()->RunMessageLoop(instance);
277 } 302 }
278 303
279 void PPB_Flash_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { 304 void PPB_Flash_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) {
280 ppb_flash_target()->QuitMessageLoop(instance); 305 ppb_flash_target()->QuitMessageLoop(instance);
281 } 306 }
282 307
283 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance, 308 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance,
284 PP_Time t, 309 PP_Time t,
285 double* result) { 310 double* result) {
286 *result = ppb_flash_target()->GetLocalTimeZoneOffset(instance, t); 311 *result = ppb_flash_target()->GetLocalTimeZoneOffset(instance, t);
287 } 312 }
288 313
289 } // namespace proxy 314 } // namespace proxy
290 } // namespace ppapi 315 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698