OLD | NEW |
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 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 int64_t* total_bytes_to_be_received) OVERRIDE; | 105 int64_t* total_bytes_to_be_received) OVERRIDE; |
106 virtual PP_Resource GetResponseInfo() OVERRIDE; | 106 virtual PP_Resource GetResponseInfo() OVERRIDE; |
107 virtual int32_t ReadResponseBody( | 107 virtual int32_t ReadResponseBody( |
108 void* buffer, | 108 void* buffer, |
109 int32_t bytes_to_read, | 109 int32_t bytes_to_read, |
110 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 110 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
111 virtual int32_t FinishStreamingToFile( | 111 virtual int32_t FinishStreamingToFile( |
112 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 112 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
113 virtual void Close() OVERRIDE; | 113 virtual void Close() OVERRIDE; |
114 virtual void GrantUniversalAccess() OVERRIDE; | 114 virtual void GrantUniversalAccess() OVERRIDE; |
115 virtual void SetStatusCallback( | 115 virtual void RegisterStatusCallback( |
116 PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE; | 116 PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE; |
117 virtual bool GetResponseInfoData(URLResponseInfoData* data) OVERRIDE; | 117 virtual bool GetResponseInfoData(URLResponseInfoData* data) OVERRIDE; |
118 | 118 |
119 // Called when the browser has new up/download progress to report. | 119 // Called when the browser has new up/download progress to report. |
120 void UpdateProgress(const PPBURLLoader_UpdateProgress_Params& params); | 120 void UpdateProgress(const PPBURLLoader_UpdateProgress_Params& params); |
121 | 121 |
122 // Called when the browser responds to our ReadResponseBody request. | 122 // Called when the browser responds to our ReadResponseBody request. |
123 void ReadResponseBodyAck(int32_t result, const char* data); | 123 void ReadResponseBodyAck(int32_t result, const char* data); |
124 | 124 |
125 // Called when any callback other than the read callback has been executed. | 125 // Called when any callback other than the read callback has been executed. |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_Close( | 317 GetDispatcher()->Send(new PpapiHostMsg_PPBURLLoader_Close( |
318 API_ID_PPB_URL_LOADER, host_resource())); | 318 API_ID_PPB_URL_LOADER, host_resource())); |
319 } | 319 } |
320 | 320 |
321 void URLLoader::GrantUniversalAccess() { | 321 void URLLoader::GrantUniversalAccess() { |
322 GetDispatcher()->Send( | 322 GetDispatcher()->Send( |
323 new PpapiHostMsg_PPBURLLoader_GrantUniversalAccess( | 323 new PpapiHostMsg_PPBURLLoader_GrantUniversalAccess( |
324 API_ID_PPB_URL_LOADER, host_resource())); | 324 API_ID_PPB_URL_LOADER, host_resource())); |
325 } | 325 } |
326 | 326 |
327 void URLLoader::SetStatusCallback( | 327 void URLLoader::RegisterStatusCallback( |
328 PP_URLLoaderTrusted_StatusCallback cb) { | 328 PP_URLLoaderTrusted_StatusCallback cb) { |
329 // Not implemented in the proxied version, this is for implementing the | 329 // Not implemented in the proxied version, this is for implementing the |
330 // proxy itself in the host. | 330 // proxy itself in the host. |
331 } | 331 } |
332 | 332 |
333 bool URLLoader::GetResponseInfoData(URLResponseInfoData* data) { | 333 bool URLLoader::GetResponseInfoData(URLResponseInfoData* data) { |
334 // Not implemented in the proxied version, this is for implementing the | 334 // Not implemented in the proxied version, this is for implementing the |
335 // proxy itself in the host. | 335 // proxy itself in the host. |
336 return false; | 336 return false; |
337 } | 337 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 return handled; | 460 return handled; |
461 } | 461 } |
462 | 462 |
463 #if !defined(OS_NACL) | 463 #if !defined(OS_NACL) |
464 void PPB_URLLoader_Proxy::PrepareURLLoaderForSendingToPlugin( | 464 void PPB_URLLoader_Proxy::PrepareURLLoaderForSendingToPlugin( |
465 PP_Resource resource) { | 465 PP_Resource resource) { |
466 // So the plugin can query load status, we need to register our status | 466 // So the plugin can query load status, we need to register our status |
467 // callback before sending any URLLoader to the plugin. | 467 // callback before sending any URLLoader to the plugin. |
468 EnterResourceNoLock<PPB_URLLoader_API> enter(resource, false); | 468 EnterResourceNoLock<PPB_URLLoader_API> enter(resource, false); |
469 if (enter.succeeded()) | 469 if (enter.succeeded()) |
470 enter.object()->SetStatusCallback(&UpdateResourceLoadStatus); | 470 enter.object()->RegisterStatusCallback(&UpdateResourceLoadStatus); |
471 else | 471 else |
472 NOTREACHED(); // Only called internally, resource should be valid. | 472 NOTREACHED(); // Only called internally, resource should be valid. |
473 } | 473 } |
474 | 474 |
475 void PPB_URLLoader_Proxy::OnMsgCreate(PP_Instance instance, | 475 void PPB_URLLoader_Proxy::OnMsgCreate(PP_Instance instance, |
476 HostResource* result) { | 476 HostResource* result) { |
477 thunk::EnterResourceCreation enter(instance); | 477 thunk::EnterResourceCreation enter(instance); |
478 if (enter.succeeded()) { | 478 if (enter.succeeded()) { |
479 result->SetHostResource(instance, | 479 result->SetHostResource(instance, |
480 enter.functions()->CreateURLLoader(instance)); | 480 enter.functions()->CreateURLLoader(instance)); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 | 643 |
644 void PPB_URLLoader_Proxy::OnCallback(int32_t result, | 644 void PPB_URLLoader_Proxy::OnCallback(int32_t result, |
645 const HostResource& resource) { | 645 const HostResource& resource) { |
646 dispatcher()->Send(new PpapiMsg_PPBURLLoader_CallbackComplete( | 646 dispatcher()->Send(new PpapiMsg_PPBURLLoader_CallbackComplete( |
647 API_ID_PPB_URL_LOADER, resource, result)); | 647 API_ID_PPB_URL_LOADER, resource, result)); |
648 } | 648 } |
649 #endif // !defined(OS_NACL) | 649 #endif // !defined(OS_NACL) |
650 | 650 |
651 } // namespace proxy | 651 } // namespace proxy |
652 } // namespace ppapi | 652 } // namespace ppapi |
OLD | NEW |