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

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

Issue 7706021: Convert FileRefImpl and URLRequestInfo to shared_impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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_url_loader_proxy.h" 5 #include "ppapi/proxy/ppb_url_loader_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "ppapi/c/pp_completion_callback.h" 13 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/pp_errors.h" 14 #include "ppapi/c/pp_errors.h"
15 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/ppb_url_loader.h" 16 #include "ppapi/c/ppb_url_loader.h"
17 #include "ppapi/c/private/ppb_proxy_private.h" 17 #include "ppapi/c/private/ppb_proxy_private.h"
18 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" 18 #include "ppapi/c/trusted/ppb_url_loader_trusted.h"
19 #include "ppapi/proxy/enter_proxy.h" 19 #include "ppapi/proxy/enter_proxy.h"
20 #include "ppapi/proxy/host_dispatcher.h" 20 #include "ppapi/proxy/host_dispatcher.h"
21 #include "ppapi/proxy/plugin_dispatcher.h" 21 #include "ppapi/proxy/plugin_dispatcher.h"
22 #include "ppapi/proxy/plugin_resource_tracker.h" 22 #include "ppapi/proxy/plugin_resource_tracker.h"
23 #include "ppapi/proxy/ppapi_messages.h" 23 #include "ppapi/proxy/ppapi_messages.h"
24 #include "ppapi/proxy/ppb_url_response_info_proxy.h" 24 #include "ppapi/proxy/ppb_url_response_info_proxy.h"
25 #include "ppapi/shared_impl/scoped_pp_resource.h"
25 #include "ppapi/thunk/enter.h" 26 #include "ppapi/thunk/enter.h"
26 #include "ppapi/thunk/ppb_url_loader_api.h" 27 #include "ppapi/thunk/ppb_url_loader_api.h"
27 #include "ppapi/thunk/resource_creation_api.h" 28 #include "ppapi/thunk/resource_creation_api.h"
28 #include "ppapi/thunk/thunk.h" 29 #include "ppapi/thunk/thunk.h"
29 30
30 #if defined(OS_LINUX) 31 #if defined(OS_LINUX)
31 #include <sys/shm.h> 32 #include <sys/shm.h>
32 #endif 33 #endif
33 34
34 using ppapi::thunk::EnterFunctionNoLock; 35 using ppapi::thunk::EnterFunctionNoLock;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (response_info_) 174 if (response_info_)
174 PluginResourceTracker::GetInstance()->ReleaseResource(response_info_); 175 PluginResourceTracker::GetInstance()->ReleaseResource(response_info_);
175 } 176 }
176 177
177 PPB_URLLoader_API* URLLoader::AsPPB_URLLoader_API() { 178 PPB_URLLoader_API* URLLoader::AsPPB_URLLoader_API() {
178 return this; 179 return this;
179 } 180 }
180 181
181 int32_t URLLoader::Open(PP_Resource request_id, 182 int32_t URLLoader::Open(PP_Resource request_id,
182 PP_CompletionCallback callback) { 183 PP_CompletionCallback callback) {
183 Resource* request_object = 184 EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter(request_id, true);
184 PluginResourceTracker::GetInstance()->GetResource(request_id); 185 if (enter.failed())
185 if (!request_object) 186 return PP_ERROR_BADRESOURCE;
186 return PP_ERROR_BADARGUMENT; 187 //PP_Instance instance = enter.resource()->pp_instance();
187 188
188 // TODO(brettw) http://crbug.com/86279: SendCallback doesn't ensure that 189 // TODO(brettw) http://crbug.com/86279: SendCallback doesn't ensure that
189 // the proper callback semantics happen if the object is deleted. 190 // the proper callback semantics happen if the object is deleted.
190 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_Open( 191 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_Open(
191 INTERFACE_ID_PPB_URL_LOADER, host_resource(), 192 INTERFACE_ID_PPB_URL_LOADER, host_resource(), enter.object()->GetData(),
192 request_object->host_resource(),
193 GetDispatcher()->callback_tracker().SendCallback(callback))); 193 GetDispatcher()->callback_tracker().SendCallback(callback)));
194 return PP_OK_COMPLETIONPENDING; 194 return PP_OK_COMPLETIONPENDING;
195 } 195 }
196 196
197 int32_t URLLoader::FollowRedirect(PP_CompletionCallback callback) { 197 int32_t URLLoader::FollowRedirect(PP_CompletionCallback callback) {
198 // TODO(brettw) http://crbug.com/86279: SendCallback doesn't ensure that 198 // TODO(brettw) http://crbug.com/86279: SendCallback doesn't ensure that
199 // the proper callback semantics happen if the object is deleted. 199 // the proper callback semantics happen if the object is deleted.
200 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_FollowRedirect( 200 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_FollowRedirect(
201 INTERFACE_ID_PPB_URL_LOADER, host_resource(), 201 INTERFACE_ID_PPB_URL_LOADER, host_resource(),
202 GetDispatcher()->callback_tracker().SendCallback(callback))); 202 GetDispatcher()->callback_tracker().SendCallback(callback)));
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 HostResource* result) { 446 HostResource* result) {
447 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); 447 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true);
448 if (enter.succeeded()) { 448 if (enter.succeeded()) {
449 result->SetHostResource(instance, 449 result->SetHostResource(instance,
450 enter.functions()->CreateURLLoader(instance)); 450 enter.functions()->CreateURLLoader(instance));
451 PrepareURLLoaderForSendingToPlugin(result->host_resource()); 451 PrepareURLLoaderForSendingToPlugin(result->host_resource());
452 } 452 }
453 } 453 }
454 454
455 void PPB_URLLoader_Proxy::OnMsgOpen(const HostResource& loader, 455 void PPB_URLLoader_Proxy::OnMsgOpen(const HostResource& loader,
456 const HostResource& request_info, 456 const PPB_URLRequestInfo_Data& data,
457 uint32_t serialized_callback) { 457 uint32_t serialized_callback) {
458 // Have to be careful to always issue the callback, so don't return early.
458 EnterHostFromHostResource<PPB_URLLoader_API> enter(loader); 459 EnterHostFromHostResource<PPB_URLLoader_API> enter(loader);
460 EnterFunctionNoLock<ResourceCreationAPI> enter_creation(
461 loader.instance(), true);
462
459 PP_CompletionCallback callback = ReceiveCallback(serialized_callback); 463 PP_CompletionCallback callback = ReceiveCallback(serialized_callback);
464
460 int32_t result = PP_ERROR_BADRESOURCE; 465 int32_t result = PP_ERROR_BADRESOURCE;
461 if (enter.succeeded()) 466 if (enter.succeeded() && enter_creation.succeeded()) {
462 result = enter.object()->Open(request_info.host_resource(), callback); 467 ScopedPPResource request_resource(
468 ScopedPPResource::PassRef(),
469 enter_creation.functions()->CreateURLRequestInfo(loader.instance(),
470 data));
471 result = enter.object()->Open(request_resource, callback);
472 }
463 if (result != PP_OK_COMPLETIONPENDING) 473 if (result != PP_OK_COMPLETIONPENDING)
464 PP_RunCompletionCallback(&callback, result); 474 PP_RunCompletionCallback(&callback, result);
465 // TODO(brettw) bug 73236 register for the status callbacks. 475 // TODO(brettw) bug 73236 register for the status callbacks.
466 } 476 }
467 477
468 void PPB_URLLoader_Proxy::OnMsgFollowRedirect( 478 void PPB_URLLoader_Proxy::OnMsgFollowRedirect(
469 const HostResource& loader, 479 const HostResource& loader,
470 uint32_t serialized_callback) { 480 uint32_t serialized_callback) {
471 EnterHostFromHostResource<PPB_URLLoader_API> enter(loader); 481 EnterHostFromHostResource<PPB_URLLoader_API> enter(loader);
472 PP_CompletionCallback callback = ReceiveCallback(serialized_callback); 482 PP_CompletionCallback callback = ReceiveCallback(serialized_callback);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 info->read_buffer.resize(bytes_read); 589 info->read_buffer.resize(bytes_read);
580 590
581 dispatcher()->Send(new PpapiMsg_PPBURLLoader_ReadResponseBody_Ack( 591 dispatcher()->Send(new PpapiMsg_PPBURLLoader_ReadResponseBody_Ack(
582 INTERFACE_ID_PPB_URL_LOADER, info->resource, result, info->read_buffer)); 592 INTERFACE_ID_PPB_URL_LOADER, info->resource, result, info->read_buffer));
583 593
584 delete info; 594 delete info;
585 } 595 }
586 596
587 } // namespace proxy 597 } // namespace proxy
588 } // namespace ppapi 598 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698