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> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 SyncLoadResponse* sync_load_response); | 378 SyncLoadResponse* sync_load_response); |
379 void SetTaskRunner( | 379 void SetTaskRunner( |
380 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 380 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
381 | 381 |
382 void OnUploadProgress(uint64_t position, uint64_t size); | 382 void OnUploadProgress(uint64_t position, uint64_t size); |
383 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, | 383 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, |
384 const ResourceResponseInfo& info); | 384 const ResourceResponseInfo& info); |
385 void OnReceivedResponse(const ResourceResponseInfo& info); | 385 void OnReceivedResponse(const ResourceResponseInfo& info); |
386 void OnDownloadedData(int len, int encoded_data_length); | 386 void OnDownloadedData(int len, int encoded_data_length); |
387 void OnReceivedData(std::unique_ptr<ReceivedData> data); | 387 void OnReceivedData(std::unique_ptr<ReceivedData> data); |
| 388 void OnTransferSizeUpdated(int transfer_size_diff); |
388 void OnReceivedCachedMetadata(const char* data, int len); | 389 void OnReceivedCachedMetadata(const char* data, int len); |
389 void OnCompletedRequest(int error_code, | 390 void OnCompletedRequest(int error_code, |
390 bool was_ignored_by_handler, | 391 bool was_ignored_by_handler, |
391 bool stale_copy_in_cache, | 392 bool stale_copy_in_cache, |
392 const base::TimeTicks& completion_time, | 393 const base::TimeTicks& completion_time, |
393 int64_t total_transfer_size, | 394 int64_t total_transfer_size, |
394 int64_t encoded_body_size); | 395 int64_t encoded_body_size); |
395 | 396 |
396 private: | 397 private: |
397 friend class base::RefCounted<Context>; | 398 friend class base::RefCounted<Context>; |
(...skipping 29 matching lines...) Expand all Loading... |
427 public: | 428 public: |
428 explicit RequestPeerImpl(Context* context); | 429 explicit RequestPeerImpl(Context* context); |
429 | 430 |
430 // RequestPeer methods: | 431 // RequestPeer methods: |
431 void OnUploadProgress(uint64_t position, uint64_t size) override; | 432 void OnUploadProgress(uint64_t position, uint64_t size) override; |
432 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, | 433 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, |
433 const ResourceResponseInfo& info) override; | 434 const ResourceResponseInfo& info) override; |
434 void OnReceivedResponse(const ResourceResponseInfo& info) override; | 435 void OnReceivedResponse(const ResourceResponseInfo& info) override; |
435 void OnDownloadedData(int len, int encoded_data_length) override; | 436 void OnDownloadedData(int len, int encoded_data_length) override; |
436 void OnReceivedData(std::unique_ptr<ReceivedData> data) override; | 437 void OnReceivedData(std::unique_ptr<ReceivedData> data) override; |
| 438 void OnTransferSizeUpdated(int transfer_size_diff) override; |
437 void OnReceivedCachedMetadata(const char* data, int len) override; | 439 void OnReceivedCachedMetadata(const char* data, int len) override; |
438 void OnCompletedRequest(int error_code, | 440 void OnCompletedRequest(int error_code, |
439 bool was_ignored_by_handler, | 441 bool was_ignored_by_handler, |
440 bool stale_copy_in_cache, | 442 bool stale_copy_in_cache, |
441 const base::TimeTicks& completion_time, | 443 const base::TimeTicks& completion_time, |
442 int64_t total_transfer_size, | 444 int64_t total_transfer_size, |
443 int64_t encoded_body_size) override; | 445 int64_t encoded_body_size) override; |
444 | 446 |
445 private: | 447 private: |
446 scoped_refptr<Context> context_; | 448 scoped_refptr<Context> context_; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 void WebURLLoaderImpl::Context::OnDownloadedData(int len, | 795 void WebURLLoaderImpl::Context::OnDownloadedData(int len, |
794 int encoded_data_length) { | 796 int encoded_data_length) { |
795 if (client_) | 797 if (client_) |
796 client_->didDownloadData(len, encoded_data_length); | 798 client_->didDownloadData(len, encoded_data_length); |
797 } | 799 } |
798 | 800 |
799 void WebURLLoaderImpl::Context::OnReceivedData( | 801 void WebURLLoaderImpl::Context::OnReceivedData( |
800 std::unique_ptr<ReceivedData> data) { | 802 std::unique_ptr<ReceivedData> data) { |
801 const char* payload = data->payload(); | 803 const char* payload = data->payload(); |
802 int data_length = data->length(); | 804 int data_length = data->length(); |
803 int encoded_data_length = data->encoded_data_length(); | |
804 if (!client_) | 805 if (!client_) |
805 return; | 806 return; |
806 | 807 |
807 TRACE_EVENT_WITH_FLOW0( | 808 TRACE_EVENT_WITH_FLOW0( |
808 "loading", "WebURLLoaderImpl::Context::OnReceivedData", | 809 "loading", "WebURLLoaderImpl::Context::OnReceivedData", |
809 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); | 810 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); |
810 | 811 |
811 if (ftp_listing_delegate_) { | 812 if (ftp_listing_delegate_) { |
812 // The FTP listing delegate will make the appropriate calls to | 813 // The FTP listing delegate will make the appropriate calls to |
813 // client_->didReceiveData and client_->didReceiveResponse. | 814 // client_->didReceiveData and client_->didReceiveResponse. |
814 ftp_listing_delegate_->OnReceivedData(payload, data_length); | 815 ftp_listing_delegate_->OnReceivedData(payload, data_length); |
815 } else { | 816 } else { |
816 // We dispatch the data even when |useStreamOnResponse()| is set, in order | 817 // We dispatch the data even when |useStreamOnResponse()| is set, in order |
817 // to make Devtools work. | 818 // to make Devtools work. |
818 client_->didReceiveData(payload, data_length, encoded_data_length); | 819 client_->didReceiveData(payload, data_length); |
819 | 820 |
820 if (request_.useStreamOnResponse()) { | 821 if (request_.useStreamOnResponse()) { |
821 // We don't support ftp_listening_delegate_ for now. | 822 // We don't support ftp_listening_delegate_ for now. |
822 // TODO(yhirano): Support ftp listening. | 823 // TODO(yhirano): Support ftp listening. |
823 body_stream_writer_->AddData(std::move(data)); | 824 body_stream_writer_->AddData(std::move(data)); |
824 } | 825 } |
825 } | 826 } |
826 } | 827 } |
827 | 828 |
| 829 void WebURLLoaderImpl::Context::OnTransferSizeUpdated(int transfer_size_diff) { |
| 830 client_->didReceiveTransferSizeUpdate(transfer_size_diff); |
| 831 } |
| 832 |
828 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( | 833 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( |
829 const char* data, int len) { | 834 const char* data, int len) { |
830 if (!client_) | 835 if (!client_) |
831 return; | 836 return; |
832 TRACE_EVENT_WITH_FLOW0( | 837 TRACE_EVENT_WITH_FLOW0( |
833 "loading", "WebURLLoaderImpl::Context::OnReceivedCachedMetadata", | 838 "loading", "WebURLLoaderImpl::Context::OnReceivedCachedMetadata", |
834 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); | 839 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); |
835 client_->didReceiveCachedMetadata(data, len); | 840 client_->didReceiveCachedMetadata(data, len); |
836 } | 841 } |
837 | 842 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 | 952 |
948 ResourceResponseInfo info; | 953 ResourceResponseInfo info; |
949 std::string data; | 954 std::string data; |
950 | 955 |
951 int error_code = GetInfoFromDataURL(request_.url(), &info, &data); | 956 int error_code = GetInfoFromDataURL(request_.url(), &info, &data); |
952 | 957 |
953 if (error_code == net::OK) { | 958 if (error_code == net::OK) { |
954 OnReceivedResponse(info); | 959 OnReceivedResponse(info); |
955 auto size = data.size(); | 960 auto size = data.size(); |
956 if (size != 0) | 961 if (size != 0) |
957 OnReceivedData(base::MakeUnique<FixedReceivedData>(data.data(), size, 0)); | 962 OnReceivedData(base::MakeUnique<FixedReceivedData>(data.data(), size)); |
958 } | 963 } |
959 | 964 |
960 OnCompletedRequest(error_code, false, false, base::TimeTicks::Now(), 0, | 965 OnCompletedRequest(error_code, false, false, base::TimeTicks::Now(), 0, |
961 data.size()); | 966 data.size()); |
962 } | 967 } |
963 | 968 |
964 // WebURLLoaderImpl::RequestPeerImpl ------------------------------------------ | 969 // WebURLLoaderImpl::RequestPeerImpl ------------------------------------------ |
965 | 970 |
966 WebURLLoaderImpl::RequestPeerImpl::RequestPeerImpl(Context* context) | 971 WebURLLoaderImpl::RequestPeerImpl::RequestPeerImpl(Context* context) |
967 : context_(context) {} | 972 : context_(context) {} |
(...skipping 18 matching lines...) Expand all Loading... |
986 int len, | 991 int len, |
987 int encoded_data_length) { | 992 int encoded_data_length) { |
988 context_->OnDownloadedData(len, encoded_data_length); | 993 context_->OnDownloadedData(len, encoded_data_length); |
989 } | 994 } |
990 | 995 |
991 void WebURLLoaderImpl::RequestPeerImpl::OnReceivedData( | 996 void WebURLLoaderImpl::RequestPeerImpl::OnReceivedData( |
992 std::unique_ptr<ReceivedData> data) { | 997 std::unique_ptr<ReceivedData> data) { |
993 context_->OnReceivedData(std::move(data)); | 998 context_->OnReceivedData(std::move(data)); |
994 } | 999 } |
995 | 1000 |
| 1001 void WebURLLoaderImpl::RequestPeerImpl::OnTransferSizeUpdated( |
| 1002 int transfer_size_diff) { |
| 1003 context_->OnTransferSizeUpdated(transfer_size_diff); |
| 1004 } |
| 1005 |
996 void WebURLLoaderImpl::RequestPeerImpl::OnReceivedCachedMetadata( | 1006 void WebURLLoaderImpl::RequestPeerImpl::OnReceivedCachedMetadata( |
997 const char* data, | 1007 const char* data, |
998 int len) { | 1008 int len) { |
999 context_->OnReceivedCachedMetadata(data, len); | 1009 context_->OnReceivedCachedMetadata(data, len); |
1000 } | 1010 } |
1001 | 1011 |
1002 void WebURLLoaderImpl::RequestPeerImpl::OnCompletedRequest( | 1012 void WebURLLoaderImpl::RequestPeerImpl::OnCompletedRequest( |
1003 int error_code, | 1013 int error_code, |
1004 bool was_ignored_by_handler, | 1014 bool was_ignored_by_handler, |
1005 bool stale_copy_in_cache, | 1015 bool stale_copy_in_cache, |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 int intra_priority_value) { | 1260 int intra_priority_value) { |
1251 context_->DidChangePriority(new_priority, intra_priority_value); | 1261 context_->DidChangePriority(new_priority, intra_priority_value); |
1252 } | 1262 } |
1253 | 1263 |
1254 void WebURLLoaderImpl::setLoadingTaskRunner( | 1264 void WebURLLoaderImpl::setLoadingTaskRunner( |
1255 base::SingleThreadTaskRunner* loading_task_runner) { | 1265 base::SingleThreadTaskRunner* loading_task_runner) { |
1256 context_->SetTaskRunner(loading_task_runner); | 1266 context_->SetTaskRunner(loading_task_runner); |
1257 } | 1267 } |
1258 | 1268 |
1259 } // namespace content | 1269 } // namespace content |
OLD | NEW |