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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp

Issue 2807533003: [WIP2] off-main-thread loading
Patch Set: call set_is_secure_context in EmbeddedSharedWorkerStub::CreateWorkerFetchContext() Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 unsigned long identifier, 308 unsigned long identifier,
309 ResourceRequest& request, 309 ResourceRequest& request,
310 const ResourceResponse& redirect_response, 310 const ResourceResponse& redirect_response,
311 const FetchInitiatorInfo& initiator_info) { 311 const FetchInitiatorInfo& initiator_info) {
312 if (redirect_response.IsNull()) { 312 if (redirect_response.IsNull()) {
313 // Progress doesn't care about redirects, only notify it when an 313 // Progress doesn't care about redirects, only notify it when an
314 // initial request is sent. 314 // initial request is sent.
315 GetFrame()->Loader().Progress().WillStartLoading(identifier, 315 GetFrame()->Loader().Progress().WillStartLoading(identifier,
316 request.Priority()); 316 request.Priority());
317 } 317 }
318 probe::willSendRequest(GetFrame(), identifier, MasterDocumentLoader(), 318 probe::willSendRequest(GetFrame()->GetDocument(), identifier,
319 request, redirect_response, initiator_info); 319 MasterDocumentLoader(), request, redirect_response,
320 initiator_info);
320 if (GetFrame()->FrameScheduler()) 321 if (GetFrame()->FrameScheduler())
321 GetFrame()->FrameScheduler()->DidStartLoading(identifier); 322 GetFrame()->FrameScheduler()->DidStartLoading(identifier);
322 } 323 }
323 324
324 void FrameFetchContext::DispatchDidReceiveResponse( 325 void FrameFetchContext::DispatchDidReceiveResponse(
325 unsigned long identifier, 326 unsigned long identifier,
326 const ResourceResponse& response, 327 const ResourceResponse& response,
327 WebURLRequest::FrameType frame_type, 328 WebURLRequest::FrameType frame_type,
328 WebURLRequest::RequestContext request_context, 329 WebURLRequest::RequestContext request_context,
329 Resource* resource, 330 Resource* resource,
(...skipping 28 matching lines...) Expand all
358 resource_loading_policy, LinkLoader::kLoadAll, nullptr); 359 resource_loading_policy, LinkLoader::kLoadAll, nullptr);
359 360
360 if (response.HasMajorCertificateErrors()) { 361 if (response.HasMajorCertificateErrors()) {
361 MixedContentChecker::HandleCertificateError(GetFrame(), response, 362 MixedContentChecker::HandleCertificateError(GetFrame(), response,
362 frame_type, request_context); 363 frame_type, request_context);
363 } 364 }
364 365
365 GetFrame()->Loader().Progress().IncrementProgress(identifier, response); 366 GetFrame()->Loader().Progress().IncrementProgress(identifier, response);
366 GetLocalFrameClient()->DispatchDidReceiveResponse(response); 367 GetLocalFrameClient()->DispatchDidReceiveResponse(response);
367 DocumentLoader* document_loader = MasterDocumentLoader(); 368 DocumentLoader* document_loader = MasterDocumentLoader();
368 probe::didReceiveResourceResponse(GetFrame(), identifier, document_loader, 369 probe::didReceiveResourceResponse(GetFrame()->GetDocument(), identifier,
369 response, resource); 370 document_loader, response, resource);
370 // It is essential that inspector gets resource response BEFORE console. 371 // It is essential that inspector gets resource response BEFORE console.
371 GetFrame()->Console().ReportResourceResponseReceived(document_loader, 372 GetFrame()->Console().ReportResourceResponseReceived(document_loader,
372 identifier, response); 373 identifier, response);
373 } 374 }
374 375
375 void FrameFetchContext::DispatchDidReceiveData(unsigned long identifier, 376 void FrameFetchContext::DispatchDidReceiveData(unsigned long identifier,
376 const char* data, 377 const char* data,
377 int data_length) { 378 int data_length) {
378 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length); 379 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length);
379 probe::didReceiveData(GetFrame(), identifier, data, data_length); 380 probe::didReceiveData(GetFrame()->GetDocument(), identifier,
381 MasterDocumentLoader(), data, data_length);
380 } 382 }
381 383
382 void FrameFetchContext::DispatchDidReceiveEncodedData(unsigned long identifier, 384 void FrameFetchContext::DispatchDidReceiveEncodedData(unsigned long identifier,
383 int encoded_data_length) { 385 int encoded_data_length) {
384 probe::didReceiveEncodedDataLength(GetFrame(), identifier, 386 probe::didReceiveEncodedDataLength(GetFrame()->GetDocument(), identifier,
385 encoded_data_length); 387 encoded_data_length);
386 } 388 }
387 389
388 void FrameFetchContext::DispatchDidDownloadData(unsigned long identifier, 390 void FrameFetchContext::DispatchDidDownloadData(unsigned long identifier,
389 int data_length, 391 int data_length,
390 int encoded_data_length) { 392 int encoded_data_length) {
391 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length); 393 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length);
392 probe::didReceiveData(GetFrame(), identifier, 0, data_length); 394 probe::didReceiveData(GetFrame()->GetDocument(), identifier,
393 probe::didReceiveEncodedDataLength(GetFrame(), identifier, 395 MasterDocumentLoader(), 0, data_length);
396 probe::didReceiveEncodedDataLength(GetFrame()->GetDocument(), identifier,
394 encoded_data_length); 397 encoded_data_length);
395 } 398 }
396 399
397 void FrameFetchContext::DispatchDidFinishLoading(unsigned long identifier, 400 void FrameFetchContext::DispatchDidFinishLoading(unsigned long identifier,
398 double finish_time, 401 double finish_time,
399 int64_t encoded_data_length, 402 int64_t encoded_data_length,
400 int64_t decoded_body_length) { 403 int64_t decoded_body_length) {
401 GetFrame()->Loader().Progress().CompleteProgress(identifier); 404 GetFrame()->Loader().Progress().CompleteProgress(identifier);
402 probe::didFinishLoading(GetFrame(), identifier, finish_time, 405 probe::didFinishLoading(GetFrame()->GetDocument(), identifier,
406 MasterDocumentLoader(), finish_time,
403 encoded_data_length, decoded_body_length); 407 encoded_data_length, decoded_body_length);
404 if (GetFrame()->FrameScheduler()) 408 if (GetFrame()->FrameScheduler())
405 GetFrame()->FrameScheduler()->DidStopLoading(identifier); 409 GetFrame()->FrameScheduler()->DidStopLoading(identifier);
406 } 410 }
407 411
408 void FrameFetchContext::DispatchDidFail(unsigned long identifier, 412 void FrameFetchContext::DispatchDidFail(unsigned long identifier,
409 const ResourceError& error, 413 const ResourceError& error,
410 int64_t encoded_data_length, 414 int64_t encoded_data_length,
411 bool is_internal_request) { 415 bool is_internal_request) {
412 GetFrame()->Loader().Progress().CompleteProgress(identifier); 416 GetFrame()->Loader().Progress().CompleteProgress(identifier);
413 probe::didFailLoading(GetFrame(), identifier, error); 417 probe::didFailLoading(GetFrame()->GetDocument(), identifier, error);
414 // Notification to FrameConsole should come AFTER InspectorInstrumentation 418 // Notification to FrameConsole should come AFTER InspectorInstrumentation
415 // call, DevTools front-end relies on this. 419 // call, DevTools front-end relies on this.
416 if (!is_internal_request) 420 if (!is_internal_request)
417 GetFrame()->Console().DidFailLoading(identifier, error); 421 GetFrame()->Console().DidFailLoading(identifier, error);
418 if (GetFrame()->FrameScheduler()) 422 if (GetFrame()->FrameScheduler())
419 GetFrame()->FrameScheduler()->DidStopLoading(identifier); 423 GetFrame()->FrameScheduler()->DidStopLoading(identifier);
420 } 424 }
421 425
422 void FrameFetchContext::DispatchDidLoadResourceFromMemoryCache( 426 void FrameFetchContext::DispatchDidLoadResourceFromMemoryCache(
423 unsigned long identifier, 427 unsigned long identifier,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 525
522 int64_t FrameFetchContext::ServiceWorkerID() const { 526 int64_t FrameFetchContext::ServiceWorkerID() const {
523 DCHECK(MasterDocumentLoader()); 527 DCHECK(MasterDocumentLoader());
524 auto* service_worker_network_provider = 528 auto* service_worker_network_provider =
525 MasterDocumentLoader()->GetServiceWorkerNetworkProvider(); 529 MasterDocumentLoader()->GetServiceWorkerNetworkProvider();
526 return service_worker_network_provider 530 return service_worker_network_provider
527 ? service_worker_network_provider->ServiceWorkerID() 531 ? service_worker_network_provider->ServiceWorkerID()
528 : -1; 532 : -1;
529 } 533 }
530 534
535 int FrameFetchContext::ApplicationCacheHostID() const {
536 if (!document_loader_)
537 return 0;
538 return document_loader_->GetApplicationCacheHost()->GetHostID();
539 }
540
531 bool FrameFetchContext::IsMainFrame() const { 541 bool FrameFetchContext::IsMainFrame() const {
532 return GetFrame()->IsMainFrame(); 542 return GetFrame()->IsMainFrame();
533 } 543 }
534 544
535 bool FrameFetchContext::DefersLoading() const { 545 bool FrameFetchContext::DefersLoading() const {
536 return GetFrame()->GetPage()->Suspended(); 546 return GetFrame()->GetPage()->Suspended();
537 } 547 }
538 548
539 bool FrameFetchContext::IsLoadComplete() const { 549 bool FrameFetchContext::IsLoadComplete() const {
540 return GetDocument() && GetDocument()->LoadEventFinished(); 550 return GetDocument() && GetDocument()->LoadEventFinished();
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 return priority; 702 return priority;
693 703
694 // If enabled, drop the priority of all resources in a subframe. 704 // If enabled, drop the priority of all resources in a subframe.
695 if (GetFrame()->GetSettings()->GetLowPriorityIframes() && 705 if (GetFrame()->GetSettings()->GetLowPriorityIframes() &&
696 !GetFrame()->IsMainFrame()) 706 !GetFrame()->IsMainFrame())
697 return kResourceLoadPriorityVeryLow; 707 return kResourceLoadPriorityVeryLow;
698 708
699 return priority; 709 return priority;
700 } 710 }
701 711
712 RefPtr<WebTaskRunner> FrameFetchContext::TimerTaskRunner() const {
713 return GetFrame()->FrameScheduler()->TimerTaskRunner();
714 }
715
702 RefPtr<WebTaskRunner> FrameFetchContext::LoadingTaskRunner() const { 716 RefPtr<WebTaskRunner> FrameFetchContext::LoadingTaskRunner() const {
703 return GetFrame()->FrameScheduler()->LoadingTaskRunner(); 717 return GetFrame()->FrameScheduler()->LoadingTaskRunner();
704 } 718 }
705 719
706 ContentSettingsClient* FrameFetchContext::GetContentSettingsClient() const { 720 ContentSettingsClient* FrameFetchContext::GetContentSettingsClient() const {
707 return GetFrame()->GetContentSettingsClient(); 721 return GetFrame()->GetContentSettingsClient();
708 } 722 }
709 723
710 Settings* FrameFetchContext::GetSettings() const { 724 Settings* FrameFetchContext::GetSettings() const {
711 DCHECK(GetFrame()); 725 DCHECK(GetFrame());
712 return GetFrame()->GetSettings(); 726 return GetFrame()->GetSettings();
713 } 727 }
714 728
715 SubresourceFilter* FrameFetchContext::GetSubresourceFilter() const { 729 SubresourceFilter* FrameFetchContext::GetSubresourceFilter() const {
716 DocumentLoader* document_loader = MasterDocumentLoader(); 730 DocumentLoader* document_loader = MasterDocumentLoader();
717 return document_loader ? document_loader->GetSubresourceFilter() : nullptr; 731 return document_loader ? document_loader->GetSubresourceFilter() : nullptr;
718 } 732 }
719 733
720 SecurityContext* FrameFetchContext::GetMainResourceSecurityContext() const { 734 SecurityContext* FrameFetchContext::GetMainResourceSecurityContext() const {
721 DCHECK(GetFrame()->GetDocument()); 735 DCHECK(GetFrame()->GetDocument());
722 return GetFrame()->GetDocument(); 736 return GetFrame()->GetDocument();
723 } 737 }
724 738
725 bool FrameFetchContext::ShouldBlockRequestByInspector( 739 bool FrameFetchContext::ShouldBlockRequestByInspector(
726 const ResourceRequest& resource_request) const { 740 const ResourceRequest& resource_request) const {
727 bool should_block_request = false; 741 bool should_block_request = false;
728 probe::shouldBlockRequest(GetFrame(), resource_request, 742 probe::shouldBlockRequest(GetDocument(), resource_request,
729 &should_block_request); 743 &should_block_request);
730 return should_block_request; 744 return should_block_request;
731 } 745 }
732 746
733 void FrameFetchContext::DispatchDidBlockRequest( 747 void FrameFetchContext::DispatchDidBlockRequest(
734 const ResourceRequest& resource_request, 748 const ResourceRequest& resource_request,
735 const FetchInitiatorInfo& fetch_initiator_info, 749 const FetchInitiatorInfo& fetch_initiator_info,
736 ResourceRequestBlockedReason blocked_reason) const { 750 ResourceRequestBlockedReason blocked_reason) const {
737 probe::didBlockRequest(GetFrame(), resource_request, MasterDocumentLoader(), 751 probe::didBlockRequest(GetDocument(), resource_request,
738 fetch_initiator_info, blocked_reason); 752 MasterDocumentLoader(), fetch_initiator_info,
753 blocked_reason);
739 } 754 }
740 755
741 void FrameFetchContext::ReportLocalLoadFailed(const KURL& url) const { 756 void FrameFetchContext::ReportLocalLoadFailed(const KURL& url) const {
742 FrameLoader::ReportLocalLoadFailed(GetFrame(), url.ElidedString()); 757 FrameLoader::ReportLocalLoadFailed(GetFrame(), url.ElidedString());
743 } 758 }
744 759
745 bool FrameFetchContext::ShouldBypassMainWorldCSP() const { 760 bool FrameFetchContext::ShouldBypassMainWorldCSP() const {
746 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP(); 761 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP();
747 } 762 }
748 763
(...skipping 20 matching lines...) Expand all
769 std::unique_ptr<WebURLLoader> FrameFetchContext::CreateURLLoader() { 784 std::unique_ptr<WebURLLoader> FrameFetchContext::CreateURLLoader() {
770 return Platform::Current()->CreateURLLoader(); 785 return Platform::Current()->CreateURLLoader();
771 } 786 }
772 787
773 DEFINE_TRACE(FrameFetchContext) { 788 DEFINE_TRACE(FrameFetchContext) {
774 visitor->Trace(document_loader_); 789 visitor->Trace(document_loader_);
775 BaseFetchContext::Trace(visitor); 790 BaseFetchContext::Trace(visitor);
776 } 791 }
777 792
778 } // namespace blink 793 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameFetchContext.h ('k') | third_party/WebKit/Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698