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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "components/mime_util/mime_util.h" | 18 #include "components/mime_util/mime_util.h" |
19 #include "components/scheduler/child/web_task_runner_impl.h" | |
19 #include "content/child/child_thread_impl.h" | 20 #include "content/child/child_thread_impl.h" |
20 #include "content/child/ftp_directory_listing_response_delegate.h" | 21 #include "content/child/ftp_directory_listing_response_delegate.h" |
21 #include "content/child/multipart_response_delegate.h" | 22 #include "content/child/multipart_response_delegate.h" |
22 #include "content/child/request_extra_data.h" | 23 #include "content/child/request_extra_data.h" |
23 #include "content/child/request_info.h" | 24 #include "content/child/request_info.h" |
24 #include "content/child/resource_dispatcher.h" | 25 #include "content/child/resource_dispatcher.h" |
25 #include "content/child/shared_memory_data_consumer_handle.h" | 26 #include "content/child/shared_memory_data_consumer_handle.h" |
26 #include "content/child/sync_load_response.h" | 27 #include "content/child/sync_load_response.h" |
27 #include "content/child/web_url_request_util.h" | 28 #include "content/child/web_url_request_util.h" |
28 #include "content/child/weburlresponse_extradata_impl.h" | 29 #include "content/child/weburlresponse_extradata_impl.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 void set_client(WebURLLoaderClient* client) { client_ = client; } | 261 void set_client(WebURLLoaderClient* client) { client_ = client; } |
261 | 262 |
262 void Cancel(); | 263 void Cancel(); |
263 void SetDefersLoading(bool value); | 264 void SetDefersLoading(bool value); |
264 void DidChangePriority(WebURLRequest::Priority new_priority, | 265 void DidChangePriority(WebURLRequest::Priority new_priority, |
265 int intra_priority_value); | 266 int intra_priority_value); |
266 bool AttachThreadedDataReceiver( | 267 bool AttachThreadedDataReceiver( |
267 blink::WebThreadedDataReceiver* threaded_data_receiver); | 268 blink::WebThreadedDataReceiver* threaded_data_receiver); |
268 void Start(const WebURLRequest& request, | 269 void Start(const WebURLRequest& request, |
269 SyncLoadResponse* sync_load_response); | 270 SyncLoadResponse* sync_load_response); |
271 void SetTaskRunner(scoped_refptr<base::SingleThreadTaskRunner> task_runner); | |
270 | 272 |
271 // RequestPeer methods: | 273 // RequestPeer methods: |
272 void OnUploadProgress(uint64 position, uint64 size) override; | 274 void OnUploadProgress(uint64 position, uint64 size) override; |
273 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, | 275 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, |
274 const ResourceResponseInfo& info) override; | 276 const ResourceResponseInfo& info) override; |
275 void OnReceivedResponse(const ResourceResponseInfo& info) override; | 277 void OnReceivedResponse(const ResourceResponseInfo& info) override; |
276 void OnDownloadedData(int len, int encoded_data_length) override; | 278 void OnDownloadedData(int len, int encoded_data_length) override; |
277 void OnReceivedData(scoped_ptr<ReceivedData> data) override; | 279 void OnReceivedData(scoped_ptr<ReceivedData> data) override; |
278 void OnReceivedCachedMetadata(const char* data, int len) override; | 280 void OnReceivedCachedMetadata(const char* data, int len) override; |
279 void OnCompletedRequest(int error_code, | 281 void OnCompletedRequest(int error_code, |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
475 request_info.fetch_credentials_mode = | 477 request_info.fetch_credentials_mode = |
476 GetFetchCredentialsModeForWebURLRequest(request); | 478 GetFetchCredentialsModeForWebURLRequest(request); |
477 request_info.fetch_redirect_mode = | 479 request_info.fetch_redirect_mode = |
478 GetFetchRedirectModeForWebURLRequest(request); | 480 GetFetchRedirectModeForWebURLRequest(request); |
479 request_info.fetch_request_context_type = | 481 request_info.fetch_request_context_type = |
480 GetRequestContextTypeForWebURLRequest(request); | 482 GetRequestContextTypeForWebURLRequest(request); |
481 request_info.fetch_frame_type = | 483 request_info.fetch_frame_type = |
482 GetRequestContextFrameTypeForWebURLRequest(request); | 484 GetRequestContextFrameTypeForWebURLRequest(request); |
483 request_info.extra_data = request.extraData(); | 485 request_info.extra_data = request.extraData(); |
484 request_info.report_raw_headers = request.reportRawHeaders(); | 486 request_info.report_raw_headers = request.reportRawHeaders(); |
487 request_info.loading_task_queue = task_runner_; | |
485 | 488 |
486 scoped_refptr<ResourceRequestBody> request_body = | 489 scoped_refptr<ResourceRequestBody> request_body = |
487 GetRequestBodyForWebURLRequest(request).get(); | 490 GetRequestBodyForWebURLRequest(request).get(); |
488 | 491 |
489 if (sync_load_response) { | 492 if (sync_load_response) { |
490 resource_dispatcher_->StartSync( | 493 resource_dispatcher_->StartSync( |
491 request_info, request_body.get(), sync_load_response); | 494 request_info, request_body.get(), sync_load_response); |
492 return; | 495 return; |
493 } | 496 } |
494 | 497 |
495 request_id_ = resource_dispatcher_->StartAsync( | 498 request_id_ = resource_dispatcher_->StartAsync( |
496 request_info, request_body.get(), this); | 499 request_info, request_body.get(), this); |
497 } | 500 } |
498 | 501 |
502 void WebURLLoaderImpl::Context::SetTaskRunner( | |
503 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | |
504 task_runner_ = task_runner; | |
505 } | |
506 | |
499 void WebURLLoaderImpl::Context::OnUploadProgress(uint64 position, uint64 size) { | 507 void WebURLLoaderImpl::Context::OnUploadProgress(uint64 position, uint64 size) { |
500 if (client_) | 508 if (client_) |
501 client_->didSendData(loader_, position, size); | 509 client_->didSendData(loader_, position, size); |
502 } | 510 } |
503 | 511 |
504 bool WebURLLoaderImpl::Context::OnReceivedRedirect( | 512 bool WebURLLoaderImpl::Context::OnReceivedRedirect( |
505 const net::RedirectInfo& redirect_info, | 513 const net::RedirectInfo& redirect_info, |
506 const ResourceResponseInfo& info) { | 514 const ResourceResponseInfo& info) { |
507 if (!client_) | 515 if (!client_) |
508 return false; | 516 return false; |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1052 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority, | 1060 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority, |
1053 int intra_priority_value) { | 1061 int intra_priority_value) { |
1054 context_->DidChangePriority(new_priority, intra_priority_value); | 1062 context_->DidChangePriority(new_priority, intra_priority_value); |
1055 } | 1063 } |
1056 | 1064 |
1057 bool WebURLLoaderImpl::attachThreadedDataReceiver( | 1065 bool WebURLLoaderImpl::attachThreadedDataReceiver( |
1058 blink::WebThreadedDataReceiver* threaded_data_receiver) { | 1066 blink::WebThreadedDataReceiver* threaded_data_receiver) { |
1059 return context_->AttachThreadedDataReceiver(threaded_data_receiver); | 1067 return context_->AttachThreadedDataReceiver(threaded_data_receiver); |
1060 } | 1068 } |
1061 | 1069 |
1070 void WebURLLoaderImpl::setLoadingTaskRunner( | |
1071 blink::WebTaskRunner* loading_task_runner) { | |
1072 scheduler::WebTaskRunnerImpl* web_task_runner_impl = | |
Sami
2015/09/25 13:31:27
Is this downcast safe? I think anyone could call t
| |
1073 static_cast<scheduler::WebTaskRunnerImpl*>(loading_task_runner); | |
1074 context_->SetTaskRunner(web_task_runner_impl->task_runner()); | |
1075 } | |
1076 | |
1062 } // namespace content | 1077 } // namespace content |
OLD | NEW |