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

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

Issue 11416064: Convert URLLoader to the new proxy design (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments, merge Created 8 years 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/resource_creation_proxy.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 9 #include "base/bind.h"
10 #include "ppapi/c/pp_var.h" 10 #include "ppapi/c/pp_var.h"
11 #include "ppapi/c/ppb_core.h" 11 #include "ppapi/c/ppb_core.h"
12 #include "ppapi/c/ppb_fullscreen.h" 12 #include "ppapi/c/ppb_fullscreen.h"
13 #include "ppapi/c/ppp_instance.h" 13 #include "ppapi/c/ppp_instance.h"
14 #include "ppapi/proxy/host_dispatcher.h" 14 #include "ppapi/proxy/host_dispatcher.h"
15 #include "ppapi/proxy/plugin_dispatcher.h" 15 #include "ppapi/proxy/plugin_dispatcher.h"
16 #include "ppapi/proxy/plugin_globals.h"
17 #include "ppapi/proxy/plugin_proxy_delegate.h"
16 #include "ppapi/proxy/plugin_resource_tracker.h" 18 #include "ppapi/proxy/plugin_resource_tracker.h"
17 #include "ppapi/proxy/ppapi_messages.h" 19 #include "ppapi/proxy/ppapi_messages.h"
18 #include "ppapi/proxy/ppb_url_loader_proxy.h" 20 #include "ppapi/proxy/url_loader_resource.h"
19 #include "ppapi/shared_impl/ppapi_globals.h"
20 #include "ppapi/shared_impl/ppb_view_shared.h" 21 #include "ppapi/shared_impl/ppb_view_shared.h"
22 #include "ppapi/shared_impl/resource_tracker.h"
21 #include "ppapi/shared_impl/scoped_pp_resource.h" 23 #include "ppapi/shared_impl/scoped_pp_resource.h"
22 #include "ppapi/thunk/enter.h" 24 #include "ppapi/thunk/enter.h"
23 #include "ppapi/thunk/ppb_flash_fullscreen_api.h" 25 #include "ppapi/thunk/ppb_flash_fullscreen_api.h"
24 #include "ppapi/thunk/ppb_view_api.h" 26 #include "ppapi/thunk/ppb_view_api.h"
25 27
26 namespace ppapi { 28 namespace ppapi {
27 namespace proxy { 29 namespace proxy {
28 30
29 using thunk::EnterInstanceAPINoLock; 31 using thunk::EnterInstanceAPINoLock;
30 using thunk::EnterInstanceNoLock; 32 using thunk::EnterInstanceNoLock;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 API_ID_PPP_INSTANCE, instance, enter_view.object()->GetData(), 78 API_ID_PPP_INSTANCE, instance, enter_view.object()->GetData(),
77 flash_fullscreen)); 79 flash_fullscreen));
78 } 80 }
79 81
80 void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) { 82 void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) {
81 HostDispatcher::GetForInstance(instance)->Send( 83 HostDispatcher::GetForInstance(instance)->Send(
82 new PpapiMsg_PPPInstance_DidChangeFocus(API_ID_PPP_INSTANCE, 84 new PpapiMsg_PPPInstance_DidChangeFocus(API_ID_PPP_INSTANCE,
83 instance, has_focus)); 85 instance, has_focus));
84 } 86 }
85 87
86 PP_Bool HandleDocumentLoad(PP_Instance instance, 88 PP_Bool HandleDocumentLoad(PP_Instance instance, PP_Resource url_loader) {
87 PP_Resource url_loader) { 89 // This should never get called. Out-of-process document loads are handled
88 PP_Bool result = PP_FALSE; 90 // specially.
89 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); 91 NOTREACHED();
90 92 return PP_FALSE;
91 // Set up the URLLoader for proxying.
92
93 PPB_URLLoader_Proxy* url_loader_proxy = static_cast<PPB_URLLoader_Proxy*>(
94 dispatcher->GetInterfaceProxy(API_ID_PPB_URL_LOADER));
95 url_loader_proxy->PrepareURLLoaderForSendingToPlugin(url_loader);
96
97 // PluginResourceTracker in the plugin process assumes that resources that it
98 // tracks have been addrefed on behalf of the plugin at the renderer side. So
99 // we explicitly do it for |url_loader| here.
100 //
101 // Please also see comments in PPP_Instance_Proxy::OnMsgHandleDocumentLoad()
102 // about releasing of this extra reference.
103 const PPB_Core* core = reinterpret_cast<const PPB_Core*>(
104 dispatcher->local_get_interface()(PPB_CORE_INTERFACE));
105 if (!core) {
106 NOTREACHED();
107 return PP_FALSE;
108 }
109 core->AddRefResource(url_loader);
110
111 HostResource serialized_loader;
112 serialized_loader.SetHostResource(instance, url_loader);
113 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad(
114 API_ID_PPP_INSTANCE, instance, serialized_loader, &result));
115 return result;
116 } 93 }
117 94
118 static const PPP_Instance_1_1 instance_interface = { 95 static const PPP_Instance_1_1 instance_interface = {
119 &DidCreate, 96 &DidCreate,
120 &DidDestroy, 97 &DidDestroy,
121 &DidChangeView, 98 &DidChangeView,
122 &DidChangeFocus, 99 &DidChangeFocus,
123 &HandleDocumentLoad 100 &HandleDocumentLoad
124 }; 101 };
125 #endif // !defined(OS_NACL) 102 #endif // !defined(OS_NACL)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 &new_data.clip_rect); 220 &new_data.clip_rect);
244 } 221 }
245 222
246 void PPP_Instance_Proxy::OnPluginMsgDidChangeFocus(PP_Instance instance, 223 void PPP_Instance_Proxy::OnPluginMsgDidChangeFocus(PP_Instance instance,
247 PP_Bool has_focus) { 224 PP_Bool has_focus) {
248 combined_interface_->DidChangeFocus(instance, has_focus); 225 combined_interface_->DidChangeFocus(instance, has_focus);
249 } 226 }
250 227
251 void PPP_Instance_Proxy::OnPluginMsgHandleDocumentLoad( 228 void PPP_Instance_Proxy::OnPluginMsgHandleDocumentLoad(
252 PP_Instance instance, 229 PP_Instance instance,
253 const HostResource& url_loader, 230 int pending_loader_host_id,
254 PP_Bool* result) { 231 const URLResponseInfoData& data) {
255 PP_Resource plugin_loader = 232 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
256 PPB_URLLoader_Proxy::TrackPluginResource(url_loader); 233 if (!dispatcher)
257 *result = combined_interface_->HandleDocumentLoad(instance, plugin_loader); 234 return;
235 Connection connection(PluginGlobals::Get()->GetBrowserSender(),
236 dispatcher);
258 237
259 // This balances the one reference that TrackPluginResource() initialized it 238 scoped_refptr<URLLoaderResource> loader_resource(
260 // with. The plugin will normally take an additional reference which will keep 239 new URLLoaderResource(connection, instance,
261 // the resource alive in the plugin (and the one reference in the renderer 240 pending_loader_host_id, data));
262 // representing all plugin references). 241
263 // Once all references at the plugin side are released, the renderer side will 242 PP_Resource loader_pp_resource = loader_resource->GetReference();
264 // be notified and release the reference added in HandleDocumentLoad() above. 243 if (!combined_interface_->HandleDocumentLoad(instance, loader_pp_resource))
265 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(plugin_loader); 244 loader_resource->Close();
245 // We don't pass a ref into the plugin, if it wants one, it will have taken
246 // an additional one.
247 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(
248 loader_pp_resource);
266 } 249 }
267 250
268 } // namespace proxy 251 } // namespace proxy
269 } // namespace ppapi 252 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppp_instance_proxy.h ('k') | ppapi/proxy/resource_creation_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698