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

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

Issue 2816403002: test all
Patch Set: fix sharedworker Created 3 years, 8 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "platform/loader/fetch/Resource.h" 72 #include "platform/loader/fetch/Resource.h"
73 #include "platform/loader/fetch/ResourceLoadPriority.h" 73 #include "platform/loader/fetch/ResourceLoadPriority.h"
74 #include "platform/loader/fetch/ResourceLoadingLog.h" 74 #include "platform/loader/fetch/ResourceLoadingLog.h"
75 #include "platform/loader/fetch/ResourceTimingInfo.h" 75 #include "platform/loader/fetch/ResourceTimingInfo.h"
76 #include "platform/loader/fetch/UniqueIdentifier.h" 76 #include "platform/loader/fetch/UniqueIdentifier.h"
77 #include "platform/mhtml/MHTMLArchive.h" 77 #include "platform/mhtml/MHTMLArchive.h"
78 #include "platform/network/NetworkStateNotifier.h" 78 #include "platform/network/NetworkStateNotifier.h"
79 #include "platform/network/NetworkUtils.h" 79 #include "platform/network/NetworkUtils.h"
80 #include "platform/weborigin/SchemeRegistry.h" 80 #include "platform/weborigin/SchemeRegistry.h"
81 #include "platform/wtf/Vector.h" 81 #include "platform/wtf/Vector.h"
82 #include "public/platform/Platform.h"
82 #include "public/platform/WebCachePolicy.h" 83 #include "public/platform/WebCachePolicy.h"
83 #include "public/platform/WebInsecureRequestPolicy.h" 84 #include "public/platform/WebInsecureRequestPolicy.h"
84 #include "public/platform/WebViewScheduler.h" 85 #include "public/platform/WebViewScheduler.h"
85 #include "public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider. h" 86 #include "public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider. h"
86 87
87 namespace blink { 88 namespace blink {
88 89
89 namespace { 90 namespace {
90 91
91 void EmitWarningForDocWriteScripts(const String& url, Document& document) { 92 void EmitWarningForDocWriteScripts(const String& url, Document& document) {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 unsigned long identifier, 449 unsigned long identifier,
449 ResourceRequest& request, 450 ResourceRequest& request,
450 const ResourceResponse& redirect_response, 451 const ResourceResponse& redirect_response,
451 const FetchInitiatorInfo& initiator_info) { 452 const FetchInitiatorInfo& initiator_info) {
452 if (redirect_response.IsNull()) { 453 if (redirect_response.IsNull()) {
453 // Progress doesn't care about redirects, only notify it when an 454 // Progress doesn't care about redirects, only notify it when an
454 // initial request is sent. 455 // initial request is sent.
455 GetFrame()->Loader().Progress().WillStartLoading(identifier, 456 GetFrame()->Loader().Progress().WillStartLoading(identifier,
456 request.Priority()); 457 request.Priority());
457 } 458 }
458 probe::willSendRequest(GetFrame(), identifier, MasterDocumentLoader(), 459 probe::willSendRequest(GetFrame()->GetDocument(), identifier,
459 request, redirect_response, initiator_info); 460 MasterDocumentLoader(), request, redirect_response,
461 initiator_info);
460 if (GetFrame()->FrameScheduler()) 462 if (GetFrame()->FrameScheduler())
461 GetFrame()->FrameScheduler()->DidStartLoading(identifier); 463 GetFrame()->FrameScheduler()->DidStartLoading(identifier);
462 } 464 }
463 465
464 void FrameFetchContext::DispatchDidReceiveResponse( 466 void FrameFetchContext::DispatchDidReceiveResponse(
465 unsigned long identifier, 467 unsigned long identifier,
466 const ResourceResponse& response, 468 const ResourceResponse& response,
467 WebURLRequest::FrameType frame_type, 469 WebURLRequest::FrameType frame_type,
468 WebURLRequest::RequestContext request_context, 470 WebURLRequest::RequestContext request_context,
469 Resource* resource, 471 Resource* resource,
(...skipping 28 matching lines...) Expand all
498 resource_loading_policy, LinkLoader::kLoadAll, nullptr); 500 resource_loading_policy, LinkLoader::kLoadAll, nullptr);
499 501
500 if (response.HasMajorCertificateErrors()) { 502 if (response.HasMajorCertificateErrors()) {
501 MixedContentChecker::HandleCertificateError(GetFrame(), response, 503 MixedContentChecker::HandleCertificateError(GetFrame(), response,
502 frame_type, request_context); 504 frame_type, request_context);
503 } 505 }
504 506
505 GetFrame()->Loader().Progress().IncrementProgress(identifier, response); 507 GetFrame()->Loader().Progress().IncrementProgress(identifier, response);
506 GetLocalFrameClient()->DispatchDidReceiveResponse(response); 508 GetLocalFrameClient()->DispatchDidReceiveResponse(response);
507 DocumentLoader* document_loader = MasterDocumentLoader(); 509 DocumentLoader* document_loader = MasterDocumentLoader();
508 probe::didReceiveResourceResponse(GetFrame(), identifier, document_loader, 510 probe::didReceiveResourceResponse(GetFrame()->GetDocument(), identifier,
509 response, resource); 511 document_loader, response, resource);
510 // It is essential that inspector gets resource response BEFORE console. 512 // It is essential that inspector gets resource response BEFORE console.
511 GetFrame()->Console().ReportResourceResponseReceived(document_loader, 513 GetFrame()->Console().ReportResourceResponseReceived(document_loader,
512 identifier, response); 514 identifier, response);
513 } 515 }
514 516
515 void FrameFetchContext::DispatchDidReceiveData(unsigned long identifier, 517 void FrameFetchContext::DispatchDidReceiveData(unsigned long identifier,
516 const char* data, 518 const char* data,
517 int data_length) { 519 int data_length) {
518 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length); 520 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length);
519 probe::didReceiveData(GetFrame(), identifier, data, data_length); 521 probe::didReceiveData(GetFrame()->GetDocument(), identifier,
522 MasterDocumentLoader(), data, data_length);
520 } 523 }
521 524
522 void FrameFetchContext::DispatchDidReceiveEncodedData(unsigned long identifier, 525 void FrameFetchContext::DispatchDidReceiveEncodedData(unsigned long identifier,
523 int encoded_data_length) { 526 int encoded_data_length) {
524 probe::didReceiveEncodedDataLength(GetFrame(), identifier, 527 probe::didReceiveEncodedDataLength(GetFrame()->GetDocument(), identifier,
525 encoded_data_length); 528 encoded_data_length);
526 } 529 }
527 530
528 void FrameFetchContext::DispatchDidDownloadData(unsigned long identifier, 531 void FrameFetchContext::DispatchDidDownloadData(unsigned long identifier,
529 int data_length, 532 int data_length,
530 int encoded_data_length) { 533 int encoded_data_length) {
531 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length); 534 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length);
532 probe::didReceiveData(GetFrame(), identifier, 0, data_length); 535 probe::didReceiveData(GetFrame()->GetDocument(), identifier,
533 probe::didReceiveEncodedDataLength(GetFrame(), identifier, 536 MasterDocumentLoader(), 0, data_length);
537 probe::didReceiveEncodedDataLength(GetFrame()->GetDocument(), identifier,
534 encoded_data_length); 538 encoded_data_length);
535 } 539 }
536 540
537 void FrameFetchContext::DispatchDidFinishLoading(unsigned long identifier, 541 void FrameFetchContext::DispatchDidFinishLoading(unsigned long identifier,
538 double finish_time, 542 double finish_time,
539 int64_t encoded_data_length, 543 int64_t encoded_data_length,
540 int64_t decoded_body_length) { 544 int64_t decoded_body_length) {
541 GetFrame()->Loader().Progress().CompleteProgress(identifier); 545 GetFrame()->Loader().Progress().CompleteProgress(identifier);
542 probe::didFinishLoading(GetFrame(), identifier, finish_time, 546 probe::didFinishLoading(GetFrame()->GetDocument(), identifier,
547 MasterDocumentLoader(), finish_time,
543 encoded_data_length, decoded_body_length); 548 encoded_data_length, decoded_body_length);
544 if (GetFrame()->FrameScheduler()) 549 if (GetFrame()->FrameScheduler())
545 GetFrame()->FrameScheduler()->DidStopLoading(identifier); 550 GetFrame()->FrameScheduler()->DidStopLoading(identifier);
546 } 551 }
547 552
548 void FrameFetchContext::DispatchDidFail(unsigned long identifier, 553 void FrameFetchContext::DispatchDidFail(unsigned long identifier,
549 const ResourceError& error, 554 const ResourceError& error,
550 int64_t encoded_data_length, 555 int64_t encoded_data_length,
551 bool is_internal_request) { 556 bool is_internal_request) {
552 GetFrame()->Loader().Progress().CompleteProgress(identifier); 557 GetFrame()->Loader().Progress().CompleteProgress(identifier);
553 probe::didFailLoading(GetFrame(), identifier, error); 558 probe::didFailLoading(GetFrame()->GetDocument(), identifier, error);
554 // Notification to FrameConsole should come AFTER InspectorInstrumentation 559 // Notification to FrameConsole should come AFTER InspectorInstrumentation
555 // call, DevTools front-end relies on this. 560 // call, DevTools front-end relies on this.
556 if (!is_internal_request) 561 if (!is_internal_request)
557 GetFrame()->Console().DidFailLoading(identifier, error); 562 GetFrame()->Console().DidFailLoading(identifier, error);
558 if (GetFrame()->FrameScheduler()) 563 if (GetFrame()->FrameScheduler())
559 GetFrame()->FrameScheduler()->DidStopLoading(identifier); 564 GetFrame()->FrameScheduler()->DidStopLoading(identifier);
560 } 565 }
561 566
562 void FrameFetchContext::DispatchDidLoadResourceFromMemoryCache( 567 void FrameFetchContext::DispatchDidLoadResourceFromMemoryCache(
563 unsigned long identifier, 568 unsigned long identifier,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 const ResourceRequest& resource_request, 646 const ResourceRequest& resource_request,
642 const KURL& url, 647 const KURL& url,
643 const ResourceLoaderOptions& options, 648 const ResourceLoaderOptions& options,
644 SecurityViolationReportingPolicy reporting_policy, 649 SecurityViolationReportingPolicy reporting_policy,
645 FetchParameters::OriginRestriction origin_restriction) const { 650 FetchParameters::OriginRestriction origin_restriction) const {
646 ResourceRequestBlockedReason blocked_reason = CanRequestInternal( 651 ResourceRequestBlockedReason blocked_reason = CanRequestInternal(
647 type, resource_request, url, options, reporting_policy, 652 type, resource_request, url, options, reporting_policy,
648 origin_restriction, resource_request.GetRedirectStatus()); 653 origin_restriction, resource_request.GetRedirectStatus());
649 if (blocked_reason != ResourceRequestBlockedReason::kNone && 654 if (blocked_reason != ResourceRequestBlockedReason::kNone &&
650 reporting_policy == SecurityViolationReportingPolicy::kReport) { 655 reporting_policy == SecurityViolationReportingPolicy::kReport) {
651 probe::didBlockRequest(GetFrame(), resource_request, MasterDocumentLoader(), 656 probe::didBlockRequest(GetDocument(), resource_request,
652 options.initiator_info, blocked_reason); 657 MasterDocumentLoader(), options.initiator_info,
658 blocked_reason);
653 } 659 }
654 return blocked_reason; 660 return blocked_reason;
655 } 661 }
656 662
657 ResourceRequestBlockedReason FrameFetchContext::AllowResponse( 663 ResourceRequestBlockedReason FrameFetchContext::AllowResponse(
658 Resource::Type type, 664 Resource::Type type,
659 const ResourceRequest& resource_request, 665 const ResourceRequest& resource_request,
660 const KURL& url, 666 const KURL& url,
661 const ResourceLoaderOptions& options) const { 667 const ResourceLoaderOptions& options) const {
662 ResourceRequestBlockedReason blocked_reason = 668 ResourceRequestBlockedReason blocked_reason =
663 CanRequestInternal(type, resource_request, url, options, 669 CanRequestInternal(type, resource_request, url, options,
664 SecurityViolationReportingPolicy::kReport, 670 SecurityViolationReportingPolicy::kReport,
665 FetchParameters::kUseDefaultOriginRestrictionForType, 671 FetchParameters::kUseDefaultOriginRestrictionForType,
666 RedirectStatus::kFollowedRedirect); 672 RedirectStatus::kFollowedRedirect);
667 if (blocked_reason != ResourceRequestBlockedReason::kNone) { 673 if (blocked_reason != ResourceRequestBlockedReason::kNone) {
668 probe::didBlockRequest(GetFrame(), resource_request, MasterDocumentLoader(), 674 probe::didBlockRequest(GetDocument(), resource_request,
669 options.initiator_info, blocked_reason); 675 MasterDocumentLoader(), options.initiator_info,
676 blocked_reason);
670 } 677 }
671 return blocked_reason; 678 return blocked_reason;
672 } 679 }
673 680
674 ResourceRequestBlockedReason FrameFetchContext::CanRequestInternal( 681 ResourceRequestBlockedReason FrameFetchContext::CanRequestInternal(
675 Resource::Type type, 682 Resource::Type type,
676 const ResourceRequest& resource_request, 683 const ResourceRequest& resource_request,
677 const KURL& url, 684 const KURL& url,
678 const ResourceLoaderOptions& options, 685 const ResourceLoaderOptions& options,
679 SecurityViolationReportingPolicy reporting_policy, 686 SecurityViolationReportingPolicy reporting_policy,
680 FetchParameters::OriginRestriction origin_restriction, 687 FetchParameters::OriginRestriction origin_restriction,
681 ResourceRequest::RedirectStatus redirect_status) const { 688 ResourceRequest::RedirectStatus redirect_status) const {
682 bool should_block_request = false; 689 bool should_block_request = false;
683 probe::shouldBlockRequest(GetFrame(), resource_request, 690 probe::shouldBlockRequest(GetDocument(), resource_request,
684 &should_block_request); 691 &should_block_request);
685 if (should_block_request) 692 if (should_block_request)
686 return ResourceRequestBlockedReason::kInspector; 693 return ResourceRequestBlockedReason::kInspector;
687 694
688 SecurityOrigin* security_origin = options.security_origin.Get(); 695 SecurityOrigin* security_origin = options.security_origin.Get();
689 if (!security_origin && execution_context_) 696 if (!security_origin && execution_context_)
690 security_origin = execution_context_->GetSecurityOrigin(); 697 security_origin = execution_context_->GetSecurityOrigin();
691 698
692 if (origin_restriction != FetchParameters::kNoOriginRestriction && 699 if (origin_restriction != FetchParameters::kNoOriginRestriction &&
693 security_origin && !security_origin->CanDisplay(url)) { 700 security_origin && !security_origin->CanDisplay(url)) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 866
860 int64_t FrameFetchContext::ServiceWorkerID() const { 867 int64_t FrameFetchContext::ServiceWorkerID() const {
861 DCHECK(MasterDocumentLoader()); 868 DCHECK(MasterDocumentLoader());
862 auto* service_worker_network_provider = 869 auto* service_worker_network_provider =
863 MasterDocumentLoader()->GetServiceWorkerNetworkProvider(); 870 MasterDocumentLoader()->GetServiceWorkerNetworkProvider();
864 return service_worker_network_provider 871 return service_worker_network_provider
865 ? service_worker_network_provider->ServiceWorkerID() 872 ? service_worker_network_provider->ServiceWorkerID()
866 : -1; 873 : -1;
867 } 874 }
868 875
876 int FrameFetchContext::ApplicationCacheHostID() const {
877 if (!document_loader_)
878 return 0;
879 return document_loader_->GetApplicationCacheHost()->GetHostID();
880 }
881
869 bool FrameFetchContext::IsMainFrame() const { 882 bool FrameFetchContext::IsMainFrame() const {
870 return GetFrame()->IsMainFrame(); 883 return GetFrame()->IsMainFrame();
871 } 884 }
872 885
873 bool FrameFetchContext::DefersLoading() const { 886 bool FrameFetchContext::DefersLoading() const {
874 return GetFrame()->GetPage()->Suspended(); 887 return GetFrame()->GetPage()->Suspended();
875 } 888 }
876 889
877 bool FrameFetchContext::IsLoadComplete() const { 890 bool FrameFetchContext::IsLoadComplete() const {
878 return GetDocument() && GetDocument()->LoadEventFinished(); 891 return GetDocument() && GetDocument()->LoadEventFinished();
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 return priority; 1032 return priority;
1020 1033
1021 // If enabled, drop the priority of all resources in a subframe. 1034 // If enabled, drop the priority of all resources in a subframe.
1022 if (GetFrame()->GetSettings()->GetLowPriorityIframes() && 1035 if (GetFrame()->GetSettings()->GetLowPriorityIframes() &&
1023 !GetFrame()->IsMainFrame()) 1036 !GetFrame()->IsMainFrame())
1024 return kResourceLoadPriorityVeryLow; 1037 return kResourceLoadPriorityVeryLow;
1025 1038
1026 return priority; 1039 return priority;
1027 } 1040 }
1028 1041
1042 RefPtr<WebTaskRunner> FrameFetchContext::TimerTaskRunner() const {
1043 return GetFrame()->FrameScheduler()->TimerTaskRunner();
1044 }
1045
1029 RefPtr<WebTaskRunner> FrameFetchContext::LoadingTaskRunner() const { 1046 RefPtr<WebTaskRunner> FrameFetchContext::LoadingTaskRunner() const {
1030 return GetFrame()->FrameScheduler()->LoadingTaskRunner(); 1047 return GetFrame()->FrameScheduler()->LoadingTaskRunner();
1031 } 1048 }
1032 1049
1050 WebURLLoader* FrameFetchContext::CreateURLLoader() {
1051 return Platform::Current()->CreateURLLoader();
1052 }
1053
1033 DEFINE_TRACE(FrameFetchContext) { 1054 DEFINE_TRACE(FrameFetchContext) {
1034 visitor->Trace(document_loader_); 1055 visitor->Trace(document_loader_);
1035 BaseFetchContext::Trace(visitor); 1056 BaseFetchContext::Trace(visitor);
1036 } 1057 }
1037 1058
1038 } // namespace blink 1059 } // 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