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

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

Issue 10913257: Convert url request info to new proxy API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 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
« no previous file with comments | « ppapi/proxy/ppb_url_loader_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/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/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "ppapi/c/pp_completion_callback.h" 14 #include "ppapi/c/pp_completion_callback.h"
15 #include "ppapi/c/pp_errors.h" 15 #include "ppapi/c/pp_errors.h"
16 #include "ppapi/c/pp_resource.h" 16 #include "ppapi/c/pp_resource.h"
17 #include "ppapi/c/ppb_url_loader.h" 17 #include "ppapi/c/ppb_url_loader.h"
18 #include "ppapi/c/private/ppb_proxy_private.h" 18 #include "ppapi/c/private/ppb_proxy_private.h"
19 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" 19 #include "ppapi/c/trusted/ppb_url_loader_trusted.h"
20 #include "ppapi/proxy/enter_proxy.h" 20 #include "ppapi/proxy/enter_proxy.h"
21 #include "ppapi/proxy/host_dispatcher.h" 21 #include "ppapi/proxy/host_dispatcher.h"
22 #include "ppapi/proxy/plugin_dispatcher.h" 22 #include "ppapi/proxy/plugin_dispatcher.h"
23 #include "ppapi/proxy/plugin_resource_tracker.h" 23 #include "ppapi/proxy/plugin_resource_tracker.h"
24 #include "ppapi/proxy/ppapi_messages.h" 24 #include "ppapi/proxy/ppapi_messages.h"
25 #include "ppapi/proxy/ppb_url_response_info_proxy.h" 25 #include "ppapi/proxy/ppb_url_response_info_proxy.h"
26 #include "ppapi/shared_impl/scoped_pp_resource.h" 26 #include "ppapi/shared_impl/scoped_pp_resource.h"
27 #include "ppapi/shared_impl/tracked_callback.h" 27 #include "ppapi/shared_impl/tracked_callback.h"
28 #include "ppapi/thunk/enter.h" 28 #include "ppapi/thunk/enter.h"
29 #include "ppapi/thunk/ppb_url_loader_api.h" 29 #include "ppapi/thunk/ppb_url_loader_api.h"
30 #include "ppapi/thunk/ppb_url_request_info_api.h"
30 #include "ppapi/thunk/resource_creation_api.h" 31 #include "ppapi/thunk/resource_creation_api.h"
31 #include "ppapi/thunk/thunk.h" 32 #include "ppapi/thunk/thunk.h"
32 33
33 #if defined(OS_LINUX) 34 #if defined(OS_LINUX)
34 #include <sys/shm.h> 35 #include <sys/shm.h>
35 #endif 36 #endif
36 37
37 using ppapi::thunk::EnterResourceNoLock; 38 using ppapi::thunk::EnterResourceNoLock;
38 using ppapi::thunk::PPB_URLLoader_API; 39 using ppapi::thunk::PPB_URLLoader_API;
39 using ppapi::thunk::ResourceCreationAPI; 40 using ppapi::thunk::ResourceCreationAPI;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 public: 86 public:
86 URLLoader(const HostResource& resource); 87 URLLoader(const HostResource& resource);
87 virtual ~URLLoader(); 88 virtual ~URLLoader();
88 89
89 // Resource overrides. 90 // Resource overrides.
90 virtual PPB_URLLoader_API* AsPPB_URLLoader_API() OVERRIDE; 91 virtual PPB_URLLoader_API* AsPPB_URLLoader_API() OVERRIDE;
91 92
92 // PPB_URLLoader_API implementation. 93 // PPB_URLLoader_API implementation.
93 virtual int32_t Open(PP_Resource request_id, 94 virtual int32_t Open(PP_Resource request_id,
94 scoped_refptr<TrackedCallback> callback) OVERRIDE; 95 scoped_refptr<TrackedCallback> callback) OVERRIDE;
96 virtual int32_t Open(const URLRequestInfoData& data,
97 scoped_refptr<TrackedCallback> callback) OVERRIDE;
95 virtual int32_t FollowRedirect( 98 virtual int32_t FollowRedirect(
96 scoped_refptr<TrackedCallback> callback) OVERRIDE; 99 scoped_refptr<TrackedCallback> callback) OVERRIDE;
97 virtual PP_Bool GetUploadProgress(int64_t* bytes_sent, 100 virtual PP_Bool GetUploadProgress(int64_t* bytes_sent,
98 int64_t* total_bytes_to_be_sent) OVERRIDE; 101 int64_t* total_bytes_to_be_sent) OVERRIDE;
99 virtual PP_Bool GetDownloadProgress( 102 virtual PP_Bool GetDownloadProgress(
100 int64_t* bytes_received, 103 int64_t* bytes_received,
101 int64_t* total_bytes_to_be_received) OVERRIDE; 104 int64_t* total_bytes_to_be_received) OVERRIDE;
102 virtual PP_Resource GetResponseInfo() OVERRIDE; 105 virtual PP_Resource GetResponseInfo() OVERRIDE;
103 virtual int32_t ReadResponseBody( 106 virtual int32_t ReadResponseBody(
104 void* buffer, 107 void* buffer,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 int32_t URLLoader::Open(PP_Resource request_id, 185 int32_t URLLoader::Open(PP_Resource request_id,
183 scoped_refptr<TrackedCallback> callback) { 186 scoped_refptr<TrackedCallback> callback) {
184 EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter(request_id, true); 187 EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter(request_id, true);
185 if (enter.failed()) { 188 if (enter.failed()) {
186 Log(PP_LOGLEVEL_ERROR, "PPB_URLLoader.Open: The URL you're requesting is " 189 Log(PP_LOGLEVEL_ERROR, "PPB_URLLoader.Open: The URL you're requesting is "
187 " on a different security origin than your plugin. To request " 190 " on a different security origin than your plugin. To request "
188 " cross-origin resources, see " 191 " cross-origin resources, see "
189 " PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS."); 192 " PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS.");
190 return PP_ERROR_BADRESOURCE; 193 return PP_ERROR_BADRESOURCE;
191 } 194 }
195 return Open(enter.object()->GetData(), callback);
196 }
192 197
198 int32_t URLLoader::Open(const URLRequestInfoData& data,
199 scoped_refptr<TrackedCallback> callback) {
193 if (TrackedCallback::IsPending(current_callback_)) 200 if (TrackedCallback::IsPending(current_callback_))
194 return PP_ERROR_INPROGRESS; 201 return PP_ERROR_INPROGRESS;
195 202
196 current_callback_ = callback; 203 current_callback_ = callback;
197 204
198 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_Open( 205 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_Open(
199 API_ID_PPB_URL_LOADER, host_resource(), enter.object()->GetData())); 206 API_ID_PPB_URL_LOADER, host_resource(), data));
200 return PP_OK_COMPLETIONPENDING; 207 return PP_OK_COMPLETIONPENDING;
201 } 208 }
202 209
203 int32_t URLLoader::FollowRedirect(scoped_refptr<TrackedCallback> callback) { 210 int32_t URLLoader::FollowRedirect(scoped_refptr<TrackedCallback> callback) {
204 if (TrackedCallback::IsPending(current_callback_)) 211 if (TrackedCallback::IsPending(current_callback_))
205 return PP_ERROR_INPROGRESS; 212 return PP_ERROR_INPROGRESS;
206 213
207 current_callback_ = callback; 214 current_callback_ = callback;
208 215
209 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_FollowRedirect( 216 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_FollowRedirect(
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 HostResource* result) { 453 HostResource* result) {
447 thunk::EnterResourceCreation enter(instance); 454 thunk::EnterResourceCreation enter(instance);
448 if (enter.succeeded()) { 455 if (enter.succeeded()) {
449 result->SetHostResource(instance, 456 result->SetHostResource(instance,
450 enter.functions()->CreateURLLoader(instance)); 457 enter.functions()->CreateURLLoader(instance));
451 PrepareURLLoaderForSendingToPlugin(result->host_resource()); 458 PrepareURLLoaderForSendingToPlugin(result->host_resource());
452 } 459 }
453 } 460 }
454 461
455 void PPB_URLLoader_Proxy::OnMsgOpen(const HostResource& loader, 462 void PPB_URLLoader_Proxy::OnMsgOpen(const HostResource& loader,
456 const PPB_URLRequestInfo_Data& data) { 463 const URLRequestInfoData& data) {
457 EnterHostFromHostResourceForceCallback<PPB_URLLoader_API> enter( 464 EnterHostFromHostResourceForceCallback<PPB_URLLoader_API> enter(
458 loader, callback_factory_, &PPB_URLLoader_Proxy::OnCallback, loader); 465 loader, callback_factory_, &PPB_URLLoader_Proxy::OnCallback, loader);
459 thunk::EnterResourceCreation enter_creation(loader.instance()); 466 enter.SetResult(enter.object()->Open(data, enter.callback()));
460 if (enter.failed() || enter_creation.failed())
461 return;
462
463 ScopedPPResource request_resource(
464 ScopedPPResource::PassRef(),
465 enter_creation.functions()->CreateURLRequestInfo(loader.instance(),
466 data));
467 enter.SetResult(enter.object()->Open(request_resource, enter.callback()));
468 // TODO(brettw) bug 73236 register for the status callbacks. 467 // TODO(brettw) bug 73236 register for the status callbacks.
469 } 468 }
470 469
471 void PPB_URLLoader_Proxy::OnMsgFollowRedirect( 470 void PPB_URLLoader_Proxy::OnMsgFollowRedirect(
472 const HostResource& loader) { 471 const HostResource& loader) {
473 EnterHostFromHostResourceForceCallback<PPB_URLLoader_API> enter( 472 EnterHostFromHostResourceForceCallback<PPB_URLLoader_API> enter(
474 loader, callback_factory_, &PPB_URLLoader_Proxy::OnCallback, loader); 473 loader, callback_factory_, &PPB_URLLoader_Proxy::OnCallback, loader);
475 if (enter.succeeded()) 474 if (enter.succeeded())
476 enter.SetResult(enter.object()->FollowRedirect(enter.callback())); 475 enter.SetResult(enter.object()->FollowRedirect(enter.callback()));
477 } 476 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 611 }
613 612
614 void PPB_URLLoader_Proxy::OnCallback(int32_t result, 613 void PPB_URLLoader_Proxy::OnCallback(int32_t result,
615 const HostResource& resource) { 614 const HostResource& resource) {
616 dispatcher()->Send(new PpapiMsg_PPBURLLoader_CallbackComplete( 615 dispatcher()->Send(new PpapiMsg_PPBURLLoader_CallbackComplete(
617 API_ID_PPB_URL_LOADER, resource, result)); 616 API_ID_PPB_URL_LOADER, resource, result));
618 } 617 }
619 618
620 } // namespace proxy 619 } // namespace proxy
621 } // namespace ppapi 620 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_url_loader_proxy.h ('k') | ppapi/proxy/resource_creation_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698