OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/url_loader_resource.h" | 5 #include "ppapi/proxy/url_loader_resource.h" |
6 | 6 |
| 7 #include <algorithm> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
9 #include "ppapi/c/pp_completion_callback.h" | 11 #include "ppapi/c/pp_completion_callback.h" |
10 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
11 #include "ppapi/c/ppb_url_loader.h" | 13 #include "ppapi/c/ppb_url_loader.h" |
12 #include "ppapi/proxy/dispatch_reply_message.h" | 14 #include "ppapi/proxy/dispatch_reply_message.h" |
13 #include "ppapi/proxy/file_ref_resource.h" | 15 #include "ppapi/proxy/file_ref_resource.h" |
14 #include "ppapi/proxy/ppapi_messages.h" | 16 #include "ppapi/proxy/ppapi_messages.h" |
15 #include "ppapi/proxy/url_request_info_resource.h" | 17 #include "ppapi/proxy/url_request_info_resource.h" |
16 #include "ppapi/proxy/url_response_info_resource.h" | 18 #include "ppapi/proxy/url_response_info_resource.h" |
17 #include "ppapi/shared_impl/ppapi_globals.h" | 19 #include "ppapi/shared_impl/ppapi_globals.h" |
18 #include "ppapi/shared_impl/url_response_info_data.h" | 20 #include "ppapi/shared_impl/url_response_info_data.h" |
19 #include "ppapi/thunk/enter.h" | 21 #include "ppapi/thunk/enter.h" |
20 #include "ppapi/thunk/resource_creation_api.h" | 22 #include "ppapi/thunk/resource_creation_api.h" |
21 | 23 |
22 using ppapi::thunk::EnterResourceNoLock; | 24 using ppapi::thunk::EnterResourceNoLock; |
23 using ppapi::thunk::PPB_URLLoader_API; | 25 using ppapi::thunk::PPB_URLLoader_API; |
24 using ppapi::thunk::PPB_URLRequestInfo_API; | 26 using ppapi::thunk::PPB_URLRequestInfo_API; |
25 | 27 |
26 #ifdef _MSC_VER | |
27 // Do not warn about use of std::copy with raw pointers. | |
28 #pragma warning(disable : 4996) | |
29 #endif | |
30 | |
31 namespace ppapi { | 28 namespace ppapi { |
32 namespace proxy { | 29 namespace proxy { |
33 | 30 |
34 URLLoaderResource::URLLoaderResource(Connection connection, | 31 URLLoaderResource::URLLoaderResource(Connection connection, |
35 PP_Instance instance) | 32 PP_Instance instance) |
36 : PluginResource(connection, instance), | 33 : PluginResource(connection, instance), |
37 mode_(MODE_WAITING_TO_OPEN), | 34 mode_(MODE_WAITING_TO_OPEN), |
38 status_callback_(NULL), | 35 status_callback_(NULL), |
39 bytes_sent_(0), | 36 bytes_sent_(0), |
40 total_bytes_to_be_sent_(-1), | 37 total_bytes_to_be_sent_(-1), |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 const ResourceMessageReplyParams& params, | 312 const ResourceMessageReplyParams& params, |
316 int64_t bytes_sent, | 313 int64_t bytes_sent, |
317 int64_t total_bytes_to_be_sent, | 314 int64_t total_bytes_to_be_sent, |
318 int64_t bytes_received, | 315 int64_t bytes_received, |
319 int64_t total_bytes_to_be_received) { | 316 int64_t total_bytes_to_be_received) { |
320 bytes_sent_ = bytes_sent; | 317 bytes_sent_ = bytes_sent; |
321 total_bytes_to_be_sent_ = total_bytes_to_be_sent; | 318 total_bytes_to_be_sent_ = total_bytes_to_be_sent; |
322 bytes_received_ = bytes_received; | 319 bytes_received_ = bytes_received; |
323 total_bytes_to_be_received_ = total_bytes_to_be_received; | 320 total_bytes_to_be_received_ = total_bytes_to_be_received; |
324 | 321 |
325 if (status_callback_) | 322 if (status_callback_) { |
326 status_callback_(pp_instance(), pp_resource(), | 323 status_callback_(pp_instance(), pp_resource(), |
327 bytes_sent_, total_bytes_to_be_sent_, | 324 bytes_sent_, total_bytes_to_be_sent_, |
328 bytes_received_, total_bytes_to_be_received_); | 325 bytes_received_, total_bytes_to_be_received_); |
| 326 } |
329 } | 327 } |
330 | 328 |
331 void URLLoaderResource::SetDefersLoading(bool defers_loading) { | 329 void URLLoaderResource::SetDefersLoading(bool defers_loading) { |
| 330 is_asynchronous_load_suspended_ = defers_loading; |
332 Post(RENDERER, PpapiHostMsg_URLLoader_SetDeferLoading(defers_loading)); | 331 Post(RENDERER, PpapiHostMsg_URLLoader_SetDeferLoading(defers_loading)); |
333 } | 332 } |
334 | 333 |
335 int32_t URLLoaderResource::ValidateCallback( | 334 int32_t URLLoaderResource::ValidateCallback( |
336 scoped_refptr<TrackedCallback> callback) { | 335 scoped_refptr<TrackedCallback> callback) { |
337 DCHECK(callback.get()); | 336 DCHECK(callback.get()); |
338 if (TrackedCallback::IsPending(pending_callback_)) | 337 if (TrackedCallback::IsPending(pending_callback_)) |
339 return PP_ERROR_INPROGRESS; | 338 return PP_ERROR_INPROGRESS; |
340 return PP_OK; | 339 return PP_OK; |
341 } | 340 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 391 } |
393 | 392 |
394 // Reset for next time. | 393 // Reset for next time. |
395 user_buffer_ = NULL; | 394 user_buffer_ = NULL; |
396 user_buffer_size_ = 0; | 395 user_buffer_size_ = 0; |
397 return base::checked_cast<int32_t>(bytes_to_copy); | 396 return base::checked_cast<int32_t>(bytes_to_copy); |
398 } | 397 } |
399 | 398 |
400 } // namespace proxy | 399 } // namespace proxy |
401 } // namespace ppapi | 400 } // namespace ppapi |
OLD | NEW |