OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/web_url_loader_impl.h" | 5 #include "content/child/web_url_loader_impl.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/bind.h" | 12 #include "base/bind.h" |
11 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 14 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
14 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
15 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
16 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "build/build_config.h" |
17 #include "components/mime_util/mime_util.h" | 20 #include "components/mime_util/mime_util.h" |
18 #include "components/scheduler/child/web_task_runner_impl.h" | 21 #include "components/scheduler/child/web_task_runner_impl.h" |
19 #include "content/child/child_thread_impl.h" | 22 #include "content/child/child_thread_impl.h" |
20 #include "content/child/ftp_directory_listing_response_delegate.h" | 23 #include "content/child/ftp_directory_listing_response_delegate.h" |
21 #include "content/child/multipart_response_delegate.h" | 24 #include "content/child/multipart_response_delegate.h" |
22 #include "content/child/request_extra_data.h" | 25 #include "content/child/request_extra_data.h" |
23 #include "content/child/request_info.h" | 26 #include "content/child/request_info.h" |
24 #include "content/child/resource_dispatcher.h" | 27 #include "content/child/resource_dispatcher.h" |
25 #include "content/child/shared_memory_data_consumer_handle.h" | 28 #include "content/child/shared_memory_data_consumer_handle.h" |
26 #include "content/child/sync_load_response.h" | 29 #include "content/child/sync_load_response.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 void SetDefersLoading(bool value); | 267 void SetDefersLoading(bool value); |
265 void DidChangePriority(WebURLRequest::Priority new_priority, | 268 void DidChangePriority(WebURLRequest::Priority new_priority, |
266 int intra_priority_value); | 269 int intra_priority_value); |
267 bool AttachThreadedDataReceiver( | 270 bool AttachThreadedDataReceiver( |
268 blink::WebThreadedDataReceiver* threaded_data_receiver); | 271 blink::WebThreadedDataReceiver* threaded_data_receiver); |
269 void Start(const WebURLRequest& request, | 272 void Start(const WebURLRequest& request, |
270 SyncLoadResponse* sync_load_response); | 273 SyncLoadResponse* sync_load_response); |
271 void SetWebTaskRunner(scoped_ptr<blink::WebTaskRunner> task_runner); | 274 void SetWebTaskRunner(scoped_ptr<blink::WebTaskRunner> task_runner); |
272 | 275 |
273 // RequestPeer methods: | 276 // RequestPeer methods: |
274 void OnUploadProgress(uint64 position, uint64 size) override; | 277 void OnUploadProgress(uint64_t position, uint64_t size) override; |
275 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, | 278 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, |
276 const ResourceResponseInfo& info) override; | 279 const ResourceResponseInfo& info) override; |
277 void OnReceivedResponse(const ResourceResponseInfo& info) override; | 280 void OnReceivedResponse(const ResourceResponseInfo& info) override; |
278 void OnDownloadedData(int len, int encoded_data_length) override; | 281 void OnDownloadedData(int len, int encoded_data_length) override; |
279 void OnReceivedData(scoped_ptr<ReceivedData> data) override; | 282 void OnReceivedData(scoped_ptr<ReceivedData> data) override; |
280 void OnReceivedCachedMetadata(const char* data, int len) override; | 283 void OnReceivedCachedMetadata(const char* data, int len) override; |
281 void OnCompletedRequest(int error_code, | 284 void OnCompletedRequest(int error_code, |
282 bool was_ignored_by_handler, | 285 bool was_ignored_by_handler, |
283 bool stale_copy_in_cache, | 286 bool stale_copy_in_cache, |
284 const std::string& security_info, | 287 const std::string& security_info, |
285 const base::TimeTicks& completion_time, | 288 const base::TimeTicks& completion_time, |
286 int64 total_transfer_size) override; | 289 int64_t total_transfer_size) override; |
287 void OnReceivedCompletedResponse(const ResourceResponseInfo& info, | 290 void OnReceivedCompletedResponse(const ResourceResponseInfo& info, |
288 scoped_ptr<ReceivedData> data, | 291 scoped_ptr<ReceivedData> data, |
289 int error_code, | 292 int error_code, |
290 bool was_ignored_by_handler, | 293 bool was_ignored_by_handler, |
291 bool stale_copy_in_cache, | 294 bool stale_copy_in_cache, |
292 const std::string& security_info, | 295 const std::string& security_info, |
293 const base::TimeTicks& completion_time, | 296 const base::TimeTicks& completion_time, |
294 int64 total_transfer_size) override; | 297 int64_t total_transfer_size) override; |
295 | 298 |
296 private: | 299 private: |
297 friend class base::RefCounted<Context>; | 300 friend class base::RefCounted<Context>; |
298 ~Context() override; | 301 ~Context() override; |
299 | 302 |
300 class HandleDataURLTask : public blink::WebTaskRunner::Task { | 303 class HandleDataURLTask : public blink::WebTaskRunner::Task { |
301 public: | 304 public: |
302 explicit HandleDataURLTask(scoped_refptr<Context> context) | 305 explicit HandleDataURLTask(scoped_refptr<Context> context) |
303 : context_(context) {} | 306 : context_(context) {} |
304 | 307 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 516 |
514 request_id_ = resource_dispatcher_->StartAsync( | 517 request_id_ = resource_dispatcher_->StartAsync( |
515 request_info, request_body.get(), this); | 518 request_info, request_body.get(), this); |
516 } | 519 } |
517 | 520 |
518 void WebURLLoaderImpl::Context::SetWebTaskRunner( | 521 void WebURLLoaderImpl::Context::SetWebTaskRunner( |
519 scoped_ptr<blink::WebTaskRunner> web_task_runner) { | 522 scoped_ptr<blink::WebTaskRunner> web_task_runner) { |
520 web_task_runner_ = web_task_runner.Pass(); | 523 web_task_runner_ = web_task_runner.Pass(); |
521 } | 524 } |
522 | 525 |
523 void WebURLLoaderImpl::Context::OnUploadProgress(uint64 position, uint64 size) { | 526 void WebURLLoaderImpl::Context::OnUploadProgress(uint64_t position, |
| 527 uint64_t size) { |
524 if (client_) | 528 if (client_) |
525 client_->didSendData(loader_, position, size); | 529 client_->didSendData(loader_, position, size); |
526 } | 530 } |
527 | 531 |
528 bool WebURLLoaderImpl::Context::OnReceivedRedirect( | 532 bool WebURLLoaderImpl::Context::OnReceivedRedirect( |
529 const net::RedirectInfo& redirect_info, | 533 const net::RedirectInfo& redirect_info, |
530 const ResourceResponseInfo& info) { | 534 const ResourceResponseInfo& info) { |
531 if (!client_) | 535 if (!client_) |
532 return false; | 536 return false; |
533 | 537 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 if (client_) | 710 if (client_) |
707 client_->didReceiveCachedMetadata(loader_, data, len); | 711 client_->didReceiveCachedMetadata(loader_, data, len); |
708 } | 712 } |
709 | 713 |
710 void WebURLLoaderImpl::Context::OnCompletedRequest( | 714 void WebURLLoaderImpl::Context::OnCompletedRequest( |
711 int error_code, | 715 int error_code, |
712 bool was_ignored_by_handler, | 716 bool was_ignored_by_handler, |
713 bool stale_copy_in_cache, | 717 bool stale_copy_in_cache, |
714 const std::string& security_info, | 718 const std::string& security_info, |
715 const base::TimeTicks& completion_time, | 719 const base::TimeTicks& completion_time, |
716 int64 total_transfer_size) { | 720 int64_t total_transfer_size) { |
717 // The WebURLLoaderImpl may be deleted in any of the calls to the client or | 721 // The WebURLLoaderImpl may be deleted in any of the calls to the client or |
718 // the delegates below (As they also may call in to the client). Keep |this| | 722 // the delegates below (As they also may call in to the client). Keep |this| |
719 // alive in that case, to avoid a crash. If that happens, the request will be | 723 // alive in that case, to avoid a crash. If that happens, the request will be |
720 // cancelled and |client_| will be set to NULL. | 724 // cancelled and |client_| will be set to NULL. |
721 scoped_refptr<Context> protect(this); | 725 scoped_refptr<Context> protect(this); |
722 | 726 |
723 if (ftp_listing_delegate_) { | 727 if (ftp_listing_delegate_) { |
724 ftp_listing_delegate_->OnCompletedRequest(); | 728 ftp_listing_delegate_->OnCompletedRequest(); |
725 ftp_listing_delegate_.reset(NULL); | 729 ftp_listing_delegate_.reset(NULL); |
726 } else if (multipart_delegate_) { | 730 } else if (multipart_delegate_) { |
(...skipping 20 matching lines...) Expand all Loading... |
747 } | 751 } |
748 | 752 |
749 void WebURLLoaderImpl::Context::OnReceivedCompletedResponse( | 753 void WebURLLoaderImpl::Context::OnReceivedCompletedResponse( |
750 const ResourceResponseInfo& info, | 754 const ResourceResponseInfo& info, |
751 scoped_ptr<ReceivedData> data, | 755 scoped_ptr<ReceivedData> data, |
752 int error_code, | 756 int error_code, |
753 bool was_ignored_by_handler, | 757 bool was_ignored_by_handler, |
754 bool stale_copy_in_cache, | 758 bool stale_copy_in_cache, |
755 const std::string& security_info, | 759 const std::string& security_info, |
756 const base::TimeTicks& completion_time, | 760 const base::TimeTicks& completion_time, |
757 int64 total_transfer_size) { | 761 int64_t total_transfer_size) { |
758 scoped_refptr<Context> protect(this); | 762 scoped_refptr<Context> protect(this); |
759 | 763 |
760 OnReceivedResponse(info); | 764 OnReceivedResponse(info); |
761 if (data) | 765 if (data) |
762 OnReceivedData(data.Pass()); | 766 OnReceivedData(data.Pass()); |
763 OnCompletedRequest(error_code, was_ignored_by_handler, stale_copy_in_cache, | 767 OnCompletedRequest(error_code, was_ignored_by_handler, stale_copy_in_cache, |
764 security_info, completion_time, total_transfer_size); | 768 security_info, completion_time, total_transfer_size); |
765 } | 769 } |
766 | 770 |
767 WebURLLoaderImpl::Context::~Context() { | 771 WebURLLoaderImpl::Context::~Context() { |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 } | 1091 } |
1088 | 1092 |
1089 void WebURLLoaderImpl::setLoadingTaskRunner( | 1093 void WebURLLoaderImpl::setLoadingTaskRunner( |
1090 blink::WebTaskRunner* loading_task_runner) { | 1094 blink::WebTaskRunner* loading_task_runner) { |
1091 // There's no guarantee on the lifetime of |loading_task_runner| so we take a | 1095 // There's no guarantee on the lifetime of |loading_task_runner| so we take a |
1092 // copy. | 1096 // copy. |
1093 context_->SetWebTaskRunner(make_scoped_ptr(loading_task_runner->clone())); | 1097 context_->SetWebTaskRunner(make_scoped_ptr(loading_task_runner->clone())); |
1094 } | 1098 } |
1095 | 1099 |
1096 } // namespace content | 1100 } // namespace content |
OLD | NEW |