Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: content/child/web_url_loader_impl.cc

Issue 2118903002: scheduler: Move the Blink scheduler into Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/child/web_url_loader_impl.h ('k') | content/child/web_url_loader_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/time/time.h" 22 #include "base/time/time.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "components/mime_util/mime_util.h" 24 #include "components/mime_util/mime_util.h"
25 #include "components/scheduler/child/web_task_runner_impl.h"
26 #include "content/child/child_thread_impl.h" 25 #include "content/child/child_thread_impl.h"
27 #include "content/child/ftp_directory_listing_response_delegate.h" 26 #include "content/child/ftp_directory_listing_response_delegate.h"
28 #include "content/child/request_extra_data.h" 27 #include "content/child/request_extra_data.h"
29 #include "content/child/request_info.h" 28 #include "content/child/request_info.h"
30 #include "content/child/resource_dispatcher.h" 29 #include "content/child/resource_dispatcher.h"
31 #include "content/child/shared_memory_data_consumer_handle.h" 30 #include "content/child/shared_memory_data_consumer_handle.h"
32 #include "content/child/sync_load_response.h" 31 #include "content/child/sync_load_response.h"
33 #include "content/child/web_url_request_util.h" 32 #include "content/child/web_url_request_util.h"
34 #include "content/child/weburlresponse_extradata_impl.h" 33 #include "content/child/weburlresponse_extradata_impl.h"
35 #include "content/common/resource_messages.h" 34 #include "content/common/resource_messages.h"
36 #include "content/common/resource_request_body_impl.h" 35 #include "content/common/resource_request_body_impl.h"
37 #include "content/common/service_worker/service_worker_types.h" 36 #include "content/common/service_worker/service_worker_types.h"
38 #include "content/common/ssl_status_serialization.h" 37 #include "content/common/ssl_status_serialization.h"
39 #include "content/public/child/fixed_received_data.h" 38 #include "content/public/child/fixed_received_data.h"
40 #include "content/public/child/request_peer.h" 39 #include "content/public/child/request_peer.h"
41 #include "content/public/common/browser_side_navigation_policy.h" 40 #include "content/public/common/browser_side_navigation_policy.h"
42 #include "content/public/common/ssl_status.h" 41 #include "content/public/common/ssl_status.h"
43 #include "net/base/data_url.h" 42 #include "net/base/data_url.h"
44 #include "net/base/filename_util.h" 43 #include "net/base/filename_util.h"
45 #include "net/base/net_errors.h" 44 #include "net/base/net_errors.h"
46 #include "net/cert/cert_status_flags.h" 45 #include "net/cert/cert_status_flags.h"
47 #include "net/cert/ct_sct_to_string.h" 46 #include "net/cert/ct_sct_to_string.h"
48 #include "net/http/http_response_headers.h" 47 #include "net/http/http_response_headers.h"
49 #include "net/http/http_util.h" 48 #include "net/http/http_util.h"
50 #include "net/ssl/ssl_cipher_suite_names.h" 49 #include "net/ssl/ssl_cipher_suite_names.h"
51 #include "net/ssl/ssl_connection_status_flags.h" 50 #include "net/ssl/ssl_connection_status_flags.h"
52 #include "net/url_request/url_request_data_job.h" 51 #include "net/url_request/url_request_data_job.h"
53 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h" 52 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h"
54 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 53 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
55 #include "third_party/WebKit/public/platform/WebTraceLocation.h" 54 #include "third_party/WebKit/public/platform/WebTaskRunner.h"
56 #include "third_party/WebKit/public/platform/WebURL.h" 55 #include "third_party/WebKit/public/platform/WebURL.h"
57 #include "third_party/WebKit/public/platform/WebURLError.h" 56 #include "third_party/WebKit/public/platform/WebURLError.h"
58 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h" 57 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h"
59 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 58 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
60 #include "third_party/WebKit/public/platform/WebURLRequest.h" 59 #include "third_party/WebKit/public/platform/WebURLRequest.h"
61 #include "third_party/WebKit/public/platform/WebURLResponse.h" 60 #include "third_party/WebKit/public/platform/WebURLResponse.h"
62 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 61 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
63 62
64 using base::Time; 63 using base::Time;
65 using base::TimeTicks; 64 using base::TimeTicks;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 293
295 } // namespace 294 } // namespace
296 295
297 // This inner class exists since the WebURLLoader may be deleted while inside a 296 // This inner class exists since the WebURLLoader may be deleted while inside a
298 // call to WebURLLoaderClient. Refcounting is to keep the context from being 297 // call to WebURLLoaderClient. Refcounting is to keep the context from being
299 // deleted if it may have work to do after calling into the client. 298 // deleted if it may have work to do after calling into the client.
300 class WebURLLoaderImpl::Context : public base::RefCounted<Context> { 299 class WebURLLoaderImpl::Context : public base::RefCounted<Context> {
301 public: 300 public:
302 using ReceivedData = RequestPeer::ReceivedData; 301 using ReceivedData = RequestPeer::ReceivedData;
303 302
304 Context(WebURLLoaderImpl* loader, 303 Context(WebURLLoaderImpl* loader, ResourceDispatcher* resource_dispatcher);
305 ResourceDispatcher* resource_dispatcher,
306 std::unique_ptr<blink::WebTaskRunner> task_runner);
307 304
308 WebURLLoaderClient* client() const { return client_; } 305 WebURLLoaderClient* client() const { return client_; }
309 void set_client(WebURLLoaderClient* client) { client_ = client; } 306 void set_client(WebURLLoaderClient* client) { client_ = client; }
310 307
311 void Cancel(); 308 void Cancel();
312 void SetDefersLoading(bool value); 309 void SetDefersLoading(bool value);
313 void DidChangePriority(WebURLRequest::Priority new_priority, 310 void DidChangePriority(WebURLRequest::Priority new_priority,
314 int intra_priority_value); 311 int intra_priority_value);
315 void Start(const WebURLRequest& request, 312 void Start(const WebURLRequest& request,
316 SyncLoadResponse* sync_load_response); 313 SyncLoadResponse* sync_load_response);
317 void SetWebTaskRunner(std::unique_ptr<blink::WebTaskRunner> task_runner); 314 void SetTaskRunner(
315 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
318 316
319 void OnUploadProgress(uint64_t position, uint64_t size); 317 void OnUploadProgress(uint64_t position, uint64_t size);
320 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, 318 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info,
321 const ResourceResponseInfo& info); 319 const ResourceResponseInfo& info);
322 void OnReceivedResponse(const ResourceResponseInfo& info); 320 void OnReceivedResponse(const ResourceResponseInfo& info);
323 void OnDownloadedData(int len, int encoded_data_length); 321 void OnDownloadedData(int len, int encoded_data_length);
324 void OnReceivedData(std::unique_ptr<ReceivedData> data); 322 void OnReceivedData(std::unique_ptr<ReceivedData> data);
325 void OnReceivedCachedMetadata(const char* data, int len); 323 void OnReceivedCachedMetadata(const char* data, int len);
326 void OnCompletedRequest(int error_code, 324 void OnCompletedRequest(int error_code,
327 bool was_ignored_by_handler, 325 bool was_ignored_by_handler,
328 bool stale_copy_in_cache, 326 bool stale_copy_in_cache,
329 const std::string& security_info, 327 const std::string& security_info,
330 const base::TimeTicks& completion_time, 328 const base::TimeTicks& completion_time,
331 int64_t total_transfer_size); 329 int64_t total_transfer_size);
332 330
333 private: 331 private:
334 friend class base::RefCounted<Context>; 332 friend class base::RefCounted<Context>;
335 ~Context(); 333 ~Context();
336 334
337 class HandleDataURLTask : public blink::WebTaskRunner::Task {
338 public:
339 explicit HandleDataURLTask(scoped_refptr<Context> context)
340 : context_(context) {}
341
342 void run() override {
343 context_->HandleDataURL();
344 }
345
346 private:
347 scoped_refptr<Context> context_;
348 };
349
350 // Called when the body data stream is detached from the reader side. 335 // Called when the body data stream is detached from the reader side.
351 void CancelBodyStreaming(); 336 void CancelBodyStreaming();
352 // We can optimize the handling of data URLs in most cases. 337 // We can optimize the handling of data URLs in most cases.
353 bool CanHandleDataURLRequestLocally() const; 338 bool CanHandleDataURLRequestLocally() const;
354 void HandleDataURL(); 339 void HandleDataURL();
355 340
356 WebURLLoaderImpl* loader_; 341 WebURLLoaderImpl* loader_;
357 WebURLRequest request_; 342 WebURLRequest request_;
358 WebURLLoaderClient* client_; 343 WebURLLoaderClient* client_;
359 ResourceDispatcher* resource_dispatcher_; 344 ResourceDispatcher* resource_dispatcher_;
360 std::unique_ptr<blink::WebTaskRunner> web_task_runner_; 345 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
361 WebReferrerPolicy referrer_policy_; 346 WebReferrerPolicy referrer_policy_;
362 std::unique_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_; 347 std::unique_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_;
363 std::unique_ptr<StreamOverrideParameters> stream_override_; 348 std::unique_ptr<StreamOverrideParameters> stream_override_;
364 std::unique_ptr<SharedMemoryDataConsumerHandle::Writer> body_stream_writer_; 349 std::unique_ptr<SharedMemoryDataConsumerHandle::Writer> body_stream_writer_;
365 enum DeferState {NOT_DEFERRING, SHOULD_DEFER, DEFERRED_DATA}; 350 enum DeferState {NOT_DEFERRING, SHOULD_DEFER, DEFERRED_DATA};
366 DeferState defers_loading_; 351 DeferState defers_loading_;
367 int request_id_; 352 int request_id_;
368 }; 353 };
369 354
370 // A thin wrapper class for Context to ensure its lifetime while it is 355 // A thin wrapper class for Context to ensure its lifetime while it is
(...skipping 18 matching lines...) Expand all
389 const base::TimeTicks& completion_time, 374 const base::TimeTicks& completion_time,
390 int64_t total_transfer_size) override; 375 int64_t total_transfer_size) override;
391 376
392 private: 377 private:
393 scoped_refptr<Context> context_; 378 scoped_refptr<Context> context_;
394 DISALLOW_COPY_AND_ASSIGN(RequestPeerImpl); 379 DISALLOW_COPY_AND_ASSIGN(RequestPeerImpl);
395 }; 380 };
396 381
397 // WebURLLoaderImpl::Context -------------------------------------------------- 382 // WebURLLoaderImpl::Context --------------------------------------------------
398 383
399 WebURLLoaderImpl::Context::Context( 384 WebURLLoaderImpl::Context::Context(WebURLLoaderImpl* loader,
400 WebURLLoaderImpl* loader, 385 ResourceDispatcher* resource_dispatcher)
401 ResourceDispatcher* resource_dispatcher,
402 std::unique_ptr<blink::WebTaskRunner> web_task_runner)
403 : loader_(loader), 386 : loader_(loader),
404 client_(NULL), 387 client_(NULL),
405 resource_dispatcher_(resource_dispatcher), 388 resource_dispatcher_(resource_dispatcher),
406 web_task_runner_(std::move(web_task_runner)), 389 task_runner_(base::ThreadTaskRunnerHandle::Get()),
407 referrer_policy_(blink::WebReferrerPolicyDefault), 390 referrer_policy_(blink::WebReferrerPolicyDefault),
408 defers_loading_(NOT_DEFERRING), 391 defers_loading_(NOT_DEFERRING),
409 request_id_(-1) {} 392 request_id_(-1) {}
410 393
411 void WebURLLoaderImpl::Context::Cancel() { 394 void WebURLLoaderImpl::Context::Cancel() {
412 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Cancel", this, 395 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Cancel", this,
413 TRACE_EVENT_FLAG_FLOW_IN); 396 TRACE_EVENT_FLAG_FLOW_IN);
414 if (resource_dispatcher_ && // NULL in unittest. 397 if (resource_dispatcher_ && // NULL in unittest.
415 request_id_ != -1) { 398 request_id_ != -1) {
416 resource_dispatcher_->Cancel(request_id_); 399 resource_dispatcher_->Cancel(request_id_);
(...skipping 13 matching lines...) Expand all
430 loader_ = NULL; 413 loader_ = NULL;
431 } 414 }
432 415
433 void WebURLLoaderImpl::Context::SetDefersLoading(bool value) { 416 void WebURLLoaderImpl::Context::SetDefersLoading(bool value) {
434 if (request_id_ != -1) 417 if (request_id_ != -1)
435 resource_dispatcher_->SetDefersLoading(request_id_, value); 418 resource_dispatcher_->SetDefersLoading(request_id_, value);
436 if (value && defers_loading_ == NOT_DEFERRING) { 419 if (value && defers_loading_ == NOT_DEFERRING) {
437 defers_loading_ = SHOULD_DEFER; 420 defers_loading_ = SHOULD_DEFER;
438 } else if (!value && defers_loading_ != NOT_DEFERRING) { 421 } else if (!value && defers_loading_ != NOT_DEFERRING) {
439 if (defers_loading_ == DEFERRED_DATA) { 422 if (defers_loading_ == DEFERRED_DATA) {
440 // TODO(alexclarke): Find a way to let blink and chromium FROM_HERE 423 task_runner_->PostTask(FROM_HERE,
441 // coexist. 424 base::Bind(&Context::HandleDataURL, this));
442 web_task_runner_->postTask(
443 BLINK_FROM_HERE,
444 new HandleDataURLTask(this));
445 } 425 }
446 defers_loading_ = NOT_DEFERRING; 426 defers_loading_ = NOT_DEFERRING;
447 } 427 }
448 } 428 }
449 429
450 void WebURLLoaderImpl::Context::DidChangePriority( 430 void WebURLLoaderImpl::Context::DidChangePriority(
451 WebURLRequest::Priority new_priority, int intra_priority_value) { 431 WebURLRequest::Priority new_priority, int intra_priority_value) {
452 if (request_id_ != -1) { 432 if (request_id_ != -1) {
453 resource_dispatcher_->DidChangePriority( 433 resource_dispatcher_->DidChangePriority(
454 request_id_, 434 request_id_,
455 ConvertWebKitPriorityToNetPriority(new_priority), 435 ConvertWebKitPriorityToNetPriority(new_priority),
456 intra_priority_value); 436 intra_priority_value);
457 } 437 }
458 } 438 }
459 439
460 void WebURLLoaderImpl::Context::Start(const WebURLRequest& request, 440 void WebURLLoaderImpl::Context::Start(const WebURLRequest& request,
461 SyncLoadResponse* sync_load_response) { 441 SyncLoadResponse* sync_load_response) {
462 DCHECK(request_id_ == -1); 442 DCHECK(request_id_ == -1);
463 request_ = request; // Save the request. 443 request_ = request; // Save the request.
464 GURL url = request.url(); 444 GURL url = request.url();
465 445
466 if (CanHandleDataURLRequestLocally()) { 446 if (CanHandleDataURLRequestLocally()) {
467 if (sync_load_response) { 447 if (sync_load_response) {
468 // This is a sync load. Do the work now. 448 // This is a sync load. Do the work now.
469 sync_load_response->url = url; 449 sync_load_response->url = url;
470 sync_load_response->error_code = 450 sync_load_response->error_code =
471 GetInfoFromDataURL(sync_load_response->url, sync_load_response, 451 GetInfoFromDataURL(sync_load_response->url, sync_load_response,
472 &sync_load_response->data); 452 &sync_load_response->data);
473 } else { 453 } else {
474 // TODO(alexclarke): Find a way to let blink and chromium FROM_HERE 454 task_runner_->PostTask(FROM_HERE,
475 // coexist. 455 base::Bind(&Context::HandleDataURL, this));
476 web_task_runner_->postTask(
477 BLINK_FROM_HERE,
478 new HandleDataURLTask(this));
479 } 456 }
480 return; 457 return;
481 } 458 }
482 459
483 if (request.getExtraData()) { 460 if (request.getExtraData()) {
484 RequestExtraData* extra_data = 461 RequestExtraData* extra_data =
485 static_cast<RequestExtraData*>(request.getExtraData()); 462 static_cast<RequestExtraData*>(request.getExtraData());
486 stream_override_ = extra_data->TakeStreamOverrideOwnership(); 463 stream_override_ = extra_data->TakeStreamOverrideOwnership();
487 } 464 }
488 465
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 request_info.fetch_credentials_mode = 516 request_info.fetch_credentials_mode =
540 GetFetchCredentialsModeForWebURLRequest(request); 517 GetFetchCredentialsModeForWebURLRequest(request);
541 request_info.fetch_redirect_mode = 518 request_info.fetch_redirect_mode =
542 GetFetchRedirectModeForWebURLRequest(request); 519 GetFetchRedirectModeForWebURLRequest(request);
543 request_info.fetch_request_context_type = 520 request_info.fetch_request_context_type =
544 GetRequestContextTypeForWebURLRequest(request); 521 GetRequestContextTypeForWebURLRequest(request);
545 request_info.fetch_frame_type = 522 request_info.fetch_frame_type =
546 GetRequestContextFrameTypeForWebURLRequest(request); 523 GetRequestContextFrameTypeForWebURLRequest(request);
547 request_info.extra_data = request.getExtraData(); 524 request_info.extra_data = request.getExtraData();
548 request_info.report_raw_headers = request.reportRawHeaders(); 525 request_info.report_raw_headers = request.reportRawHeaders();
549 request_info.loading_web_task_runner = web_task_runner_->clone(); 526 request_info.loading_task_runner = task_runner_;
550 request_info.lofi_state = static_cast<LoFiState>(request.getLoFiState()); 527 request_info.lofi_state = static_cast<LoFiState>(request.getLoFiState());
551 528
552 scoped_refptr<ResourceRequestBodyImpl> request_body = 529 scoped_refptr<ResourceRequestBodyImpl> request_body =
553 GetRequestBodyForWebURLRequest(request).get(); 530 GetRequestBodyForWebURLRequest(request).get();
554 531
555 // PlzNavigate: during navigation, the renderer should request a stream which 532 // PlzNavigate: during navigation, the renderer should request a stream which
556 // contains the body of the response. The network request has already been 533 // contains the body of the response. The network request has already been
557 // made by the browser. 534 // made by the browser.
558 if (stream_override_.get()) { 535 if (stream_override_.get()) {
559 CHECK(IsBrowserSideNavigationEnabled()); 536 CHECK(IsBrowserSideNavigationEnabled());
(...skipping 12 matching lines...) Expand all
572 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Start", this, 549 TRACE_EVENT_WITH_FLOW0("loading", "WebURLLoaderImpl::Context::Start", this,
573 TRACE_EVENT_FLAG_FLOW_OUT); 550 TRACE_EVENT_FLAG_FLOW_OUT);
574 request_id_ = resource_dispatcher_->StartAsync( 551 request_id_ = resource_dispatcher_->StartAsync(
575 request_info, request_body.get(), 552 request_info, request_body.get(),
576 base::WrapUnique(new WebURLLoaderImpl::RequestPeerImpl(this))); 553 base::WrapUnique(new WebURLLoaderImpl::RequestPeerImpl(this)));
577 554
578 if (defers_loading_ != NOT_DEFERRING) 555 if (defers_loading_ != NOT_DEFERRING)
579 resource_dispatcher_->SetDefersLoading(request_id_, true); 556 resource_dispatcher_->SetDefersLoading(request_id_, true);
580 } 557 }
581 558
582 void WebURLLoaderImpl::Context::SetWebTaskRunner( 559 void WebURLLoaderImpl::Context::SetTaskRunner(
583 std::unique_ptr<blink::WebTaskRunner> web_task_runner) { 560 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
584 web_task_runner_ = std::move(web_task_runner); 561 task_runner_ = task_runner;
585 } 562 }
586 563
587 void WebURLLoaderImpl::Context::OnUploadProgress(uint64_t position, 564 void WebURLLoaderImpl::Context::OnUploadProgress(uint64_t position,
588 uint64_t size) { 565 uint64_t size) {
589 if (client_) 566 if (client_)
590 client_->didSendData(loader_, position, size); 567 client_->didSendData(loader_, position, size);
591 } 568 }
592 569
593 bool WebURLLoaderImpl::Context::OnReceivedRedirect( 570 bool WebURLLoaderImpl::Context::OnReceivedRedirect(
594 const net::RedirectInfo& redirect_info, 571 const net::RedirectInfo& redirect_info,
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 const std::string& security_info, 914 const std::string& security_info,
938 const base::TimeTicks& completion_time, 915 const base::TimeTicks& completion_time,
939 int64_t total_transfer_size) { 916 int64_t total_transfer_size) {
940 context_->OnCompletedRequest(error_code, was_ignored_by_handler, 917 context_->OnCompletedRequest(error_code, was_ignored_by_handler,
941 stale_copy_in_cache, security_info, 918 stale_copy_in_cache, security_info,
942 completion_time, total_transfer_size); 919 completion_time, total_transfer_size);
943 } 920 }
944 921
945 // WebURLLoaderImpl ----------------------------------------------------------- 922 // WebURLLoaderImpl -----------------------------------------------------------
946 923
947 WebURLLoaderImpl::WebURLLoaderImpl( 924 WebURLLoaderImpl::WebURLLoaderImpl(ResourceDispatcher* resource_dispatcher)
948 ResourceDispatcher* resource_dispatcher, 925 : context_(new Context(this, resource_dispatcher)) {}
949 std::unique_ptr<blink::WebTaskRunner> web_task_runner)
950 : context_(
951 new Context(this, resource_dispatcher, std::move(web_task_runner))) {}
952 926
953 WebURLLoaderImpl::~WebURLLoaderImpl() { 927 WebURLLoaderImpl::~WebURLLoaderImpl() {
954 cancel(); 928 cancel();
955 } 929 }
956 930
957 void WebURLLoaderImpl::PopulateURLResponse(const GURL& url, 931 void WebURLLoaderImpl::PopulateURLResponse(const GURL& url,
958 const ResourceResponseInfo& info, 932 const ResourceResponseInfo& info,
959 WebURLResponse* response, 933 WebURLResponse* response,
960 bool report_security_info) { 934 bool report_security_info) {
961 response->setURL(url); 935 response->setURL(url);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 context_->SetDefersLoading(value); 1150 context_->SetDefersLoading(value);
1177 } 1151 }
1178 1152
1179 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority, 1153 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority,
1180 int intra_priority_value) { 1154 int intra_priority_value) {
1181 context_->DidChangePriority(new_priority, intra_priority_value); 1155 context_->DidChangePriority(new_priority, intra_priority_value);
1182 } 1156 }
1183 1157
1184 void WebURLLoaderImpl::setLoadingTaskRunner( 1158 void WebURLLoaderImpl::setLoadingTaskRunner(
1185 blink::WebTaskRunner* loading_task_runner) { 1159 blink::WebTaskRunner* loading_task_runner) {
1186 // There's no guarantee on the lifetime of |loading_task_runner| so we take a 1160 context_->SetTaskRunner(loading_task_runner->taskRunner());
1187 // copy.
1188 context_->SetWebTaskRunner(loading_task_runner->clone());
1189 } 1161 }
1190 1162
1191 // This function is implemented here because it uses net functions. it is 1163 // This function is implemented here because it uses net functions. it is
1192 // tested in 1164 // tested in
1193 // third_party/WebKit/Source/core/fetch/MultipartImageResourceParserTest.cpp. 1165 // third_party/WebKit/Source/core/fetch/MultipartImageResourceParserTest.cpp.
1194 bool WebURLLoaderImpl::ParseMultipartHeadersFromBody( 1166 bool WebURLLoaderImpl::ParseMultipartHeadersFromBody(
1195 const char* bytes, 1167 const char* bytes,
1196 size_t size, 1168 size_t size,
1197 blink::WebURLResponse* response, 1169 blink::WebURLResponse* response,
1198 size_t* end) { 1170 size_t* end) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 response->clearHTTPHeaderField(webStringName); 1202 response->clearHTTPHeaderField(webStringName);
1231 while (response_headers->EnumerateHeader(&iterator, name, &value)) { 1203 while (response_headers->EnumerateHeader(&iterator, name, &value)) {
1232 response->addHTTPHeaderField(webStringName, 1204 response->addHTTPHeaderField(webStringName,
1233 WebString::fromLatin1(value)); 1205 WebString::fromLatin1(value));
1234 } 1206 }
1235 } 1207 }
1236 return true; 1208 return true;
1237 } 1209 }
1238 1210
1239 } // namespace content 1211 } // namespace content
OLDNEW
« no previous file with comments | « content/child/web_url_loader_impl.h ('k') | content/child/web_url_loader_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698