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

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

Issue 2701753003: [WIP] off-main-thread loading
Patch Set: small fix 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/weborigin/SecurityPolicy.h" 81 #include "platform/weborigin/SecurityPolicy.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 #include "wtf/Vector.h" 87 #include "wtf/Vector.h"
87 88
88 namespace blink { 89 namespace blink {
89 90
90 namespace { 91 namespace {
91 92
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 FrameFetchContext::FrameFetchContext(DocumentLoader* loader, Document* document) 314 FrameFetchContext::FrameFetchContext(DocumentLoader* loader, Document* document)
314 : m_document(document), m_documentLoader(loader) { 315 : m_document(document), m_documentLoader(loader) {
315 DCHECK(frame()); 316 DCHECK(frame());
316 } 317 }
317 318
318 FrameFetchContext::~FrameFetchContext() { 319 FrameFetchContext::~FrameFetchContext() {
319 m_document = nullptr; 320 m_document = nullptr;
320 m_documentLoader = nullptr; 321 m_documentLoader = nullptr;
321 } 322 }
322 323
324 WebURLLoader* FrameFetchContext::createURLLoader() {
325 return Platform::current()->createURLLoader();
326 }
327
323 LocalFrame* FrameFetchContext::frameOfImportsController() const { 328 LocalFrame* FrameFetchContext::frameOfImportsController() const {
324 DCHECK(m_document); 329 DCHECK(m_document);
325 HTMLImportsController* importsController = m_document->importsController(); 330 HTMLImportsController* importsController = m_document->importsController();
326 DCHECK(importsController); 331 DCHECK(importsController);
327 LocalFrame* frame = importsController->master()->frame(); 332 LocalFrame* frame = importsController->master()->frame();
328 DCHECK(frame); 333 DCHECK(frame);
329 return frame; 334 return frame;
330 } 335 }
331 336
337 int FrameFetchContext::applicationCacheHostID() const {
338 if (!m_documentLoader)
339 return 0;
340 return m_documentLoader->applicationCacheHost()->getHostID();
341 }
342
332 LocalFrame* FrameFetchContext::frame() const { 343 LocalFrame* FrameFetchContext::frame() const {
333 if (!m_documentLoader) 344 if (!m_documentLoader)
334 return frameOfImportsController(); 345 return frameOfImportsController();
335 346
336 LocalFrame* frame = m_documentLoader->frame(); 347 LocalFrame* frame = m_documentLoader->frame();
337 DCHECK(frame); 348 DCHECK(frame);
338 return frame; 349 return frame;
339 } 350 }
340 351
341 LocalFrameClient* FrameFetchContext::localFrameClient() const { 352 LocalFrameClient* FrameFetchContext::localFrameClient() const {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 unsigned long identifier, 484 unsigned long identifier,
474 ResourceRequest& request, 485 ResourceRequest& request,
475 const ResourceResponse& redirectResponse, 486 const ResourceResponse& redirectResponse,
476 const FetchInitiatorInfo& initiatorInfo) { 487 const FetchInitiatorInfo& initiatorInfo) {
477 if (redirectResponse.isNull()) { 488 if (redirectResponse.isNull()) {
478 // Progress doesn't care about redirects, only notify it when an 489 // Progress doesn't care about redirects, only notify it when an
479 // initial request is sent. 490 // initial request is sent.
480 frame()->loader().progress().willStartLoading(identifier, 491 frame()->loader().progress().willStartLoading(identifier,
481 request.priority()); 492 request.priority());
482 } 493 }
483 probe::willSendRequest(frame(), identifier, masterDocumentLoader(), request, 494 probe::willSendRequest(frame()->document(), identifier,
484 redirectResponse, initiatorInfo); 495 masterDocumentLoader(), request, redirectResponse,
496 initiatorInfo);
485 if (frame()->frameScheduler()) 497 if (frame()->frameScheduler())
486 frame()->frameScheduler()->didStartLoading(identifier); 498 frame()->frameScheduler()->didStartLoading(identifier);
487 } 499 }
488 500
489 void FrameFetchContext::dispatchDidReceiveResponse( 501 void FrameFetchContext::dispatchDidReceiveResponse(
490 unsigned long identifier, 502 unsigned long identifier,
491 const ResourceResponse& response, 503 const ResourceResponse& response,
492 WebURLRequest::FrameType frameType, 504 WebURLRequest::FrameType frameType,
493 WebURLRequest::RequestContext requestContext, 505 WebURLRequest::RequestContext requestContext,
494 Resource* resource, 506 Resource* resource,
(...skipping 28 matching lines...) Expand all
523 LinkLoader::LoadAll, nullptr); 535 LinkLoader::LoadAll, nullptr);
524 536
525 if (response.hasMajorCertificateErrors()) { 537 if (response.hasMajorCertificateErrors()) {
526 MixedContentChecker::handleCertificateError(frame(), response, frameType, 538 MixedContentChecker::handleCertificateError(frame(), response, frameType,
527 requestContext); 539 requestContext);
528 } 540 }
529 541
530 frame()->loader().progress().incrementProgress(identifier, response); 542 frame()->loader().progress().incrementProgress(identifier, response);
531 localFrameClient()->dispatchDidReceiveResponse(response); 543 localFrameClient()->dispatchDidReceiveResponse(response);
532 DocumentLoader* documentLoader = masterDocumentLoader(); 544 DocumentLoader* documentLoader = masterDocumentLoader();
533 probe::didReceiveResourceResponse(frame(), identifier, documentLoader, 545 probe::didReceiveResourceResponse(frame()->document(), identifier,
534 response, resource); 546 documentLoader, response, resource);
535 // It is essential that inspector gets resource response BEFORE console. 547 // It is essential that inspector gets resource response BEFORE console.
536 frame()->console().reportResourceResponseReceived(documentLoader, identifier, 548 frame()->console().reportResourceResponseReceived(documentLoader, identifier,
537 response); 549 response);
538 } 550 }
539 551
540 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, 552 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier,
541 const char* data, 553 const char* data,
542 int dataLength) { 554 int dataLength) {
543 frame()->loader().progress().incrementProgress(identifier, dataLength); 555 frame()->loader().progress().incrementProgress(identifier, dataLength);
544 probe::didReceiveData(frame(), identifier, data, dataLength); 556 probe::didReceiveData(frame()->document(), identifier, masterDocumentLoader(),
557 data, dataLength);
545 } 558 }
546 559
547 void FrameFetchContext::dispatchDidReceiveEncodedData(unsigned long identifier, 560 void FrameFetchContext::dispatchDidReceiveEncodedData(unsigned long identifier,
548 int encodedDataLength) { 561 int encodedDataLength) {
549 probe::didReceiveEncodedDataLength(frame(), identifier, encodedDataLength); 562 probe::didReceiveEncodedDataLength(frame()->document(), identifier,
563 encodedDataLength);
550 } 564 }
551 565
552 void FrameFetchContext::dispatchDidDownloadData(unsigned long identifier, 566 void FrameFetchContext::dispatchDidDownloadData(unsigned long identifier,
553 int dataLength, 567 int dataLength,
554 int encodedDataLength) { 568 int encodedDataLength) {
555 frame()->loader().progress().incrementProgress(identifier, dataLength); 569 frame()->loader().progress().incrementProgress(identifier, dataLength);
556 probe::didReceiveData(frame(), identifier, 0, dataLength); 570 probe::didReceiveData(frame()->document(), identifier, masterDocumentLoader(),
557 probe::didReceiveEncodedDataLength(frame(), identifier, encodedDataLength); 571 0, dataLength);
572 probe::didReceiveEncodedDataLength(frame()->document(), identifier,
573 encodedDataLength);
558 } 574 }
559 575
560 void FrameFetchContext::dispatchDidFinishLoading(unsigned long identifier, 576 void FrameFetchContext::dispatchDidFinishLoading(unsigned long identifier,
561 double finishTime, 577 double finishTime,
562 int64_t encodedDataLength, 578 int64_t encodedDataLength,
563 int64_t decodedBodyLength) { 579 int64_t decodedBodyLength) {
564 frame()->loader().progress().completeProgress(identifier); 580 frame()->loader().progress().completeProgress(identifier);
565 probe::didFinishLoading(frame(), identifier, finishTime, encodedDataLength, 581 probe::didFinishLoading(frame()->document(), identifier,
582 masterDocumentLoader(), finishTime, encodedDataLength,
566 decodedBodyLength); 583 decodedBodyLength);
567 if (frame()->frameScheduler()) 584 if (frame()->frameScheduler())
568 frame()->frameScheduler()->didStopLoading(identifier); 585 frame()->frameScheduler()->didStopLoading(identifier);
569 } 586 }
570 587
571 void FrameFetchContext::dispatchDidFail(unsigned long identifier, 588 void FrameFetchContext::dispatchDidFail(unsigned long identifier,
572 const ResourceError& error, 589 const ResourceError& error,
573 int64_t encodedDataLength, 590 int64_t encodedDataLength,
574 bool isInternalRequest) { 591 bool isInternalRequest) {
575 frame()->loader().progress().completeProgress(identifier); 592 frame()->loader().progress().completeProgress(identifier);
576 probe::didFailLoading(frame(), identifier, error); 593 probe::didFailLoading(frame()->document(), identifier, error);
577 // Notification to FrameConsole should come AFTER InspectorInstrumentation 594 // Notification to FrameConsole should come AFTER InspectorInstrumentation
578 // call, DevTools front-end relies on this. 595 // call, DevTools front-end relies on this.
579 if (!isInternalRequest) 596 if (!isInternalRequest)
580 frame()->console().didFailLoading(identifier, error); 597 frame()->console().didFailLoading(identifier, error);
581 if (frame()->frameScheduler()) 598 if (frame()->frameScheduler())
582 frame()->frameScheduler()->didStopLoading(identifier); 599 frame()->frameScheduler()->didStopLoading(identifier);
583 } 600 }
584 601
585 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache( 602 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(
586 unsigned long identifier, 603 unsigned long identifier,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 const ResourceRequest& resourceRequest, 702 const ResourceRequest& resourceRequest,
686 const KURL& url, 703 const KURL& url,
687 const ResourceLoaderOptions& options, 704 const ResourceLoaderOptions& options,
688 SecurityViolationReportingPolicy reportingPolicy, 705 SecurityViolationReportingPolicy reportingPolicy,
689 FetchRequest::OriginRestriction originRestriction) const { 706 FetchRequest::OriginRestriction originRestriction) const {
690 ResourceRequestBlockedReason blockedReason = 707 ResourceRequestBlockedReason blockedReason =
691 canRequestInternal(type, resourceRequest, url, options, reportingPolicy, 708 canRequestInternal(type, resourceRequest, url, options, reportingPolicy,
692 originRestriction, resourceRequest.redirectStatus()); 709 originRestriction, resourceRequest.redirectStatus());
693 if (blockedReason != ResourceRequestBlockedReason::None && 710 if (blockedReason != ResourceRequestBlockedReason::None &&
694 reportingPolicy == SecurityViolationReportingPolicy::Report) { 711 reportingPolicy == SecurityViolationReportingPolicy::Report) {
695 probe::didBlockRequest(frame(), resourceRequest, masterDocumentLoader(), 712 probe::didBlockRequest(m_document, resourceRequest, masterDocumentLoader(),
696 options.initiatorInfo, blockedReason); 713 options.initiatorInfo, blockedReason);
697 } 714 }
698 return blockedReason; 715 return blockedReason;
699 } 716 }
700 717
701 ResourceRequestBlockedReason FrameFetchContext::allowResponse( 718 ResourceRequestBlockedReason FrameFetchContext::allowResponse(
702 Resource::Type type, 719 Resource::Type type,
703 const ResourceRequest& resourceRequest, 720 const ResourceRequest& resourceRequest,
704 const KURL& url, 721 const KURL& url,
705 const ResourceLoaderOptions& options) const { 722 const ResourceLoaderOptions& options) const {
706 ResourceRequestBlockedReason blockedReason = 723 ResourceRequestBlockedReason blockedReason =
707 canRequestInternal(type, resourceRequest, url, options, 724 canRequestInternal(type, resourceRequest, url, options,
708 SecurityViolationReportingPolicy::Report, 725 SecurityViolationReportingPolicy::Report,
709 FetchRequest::UseDefaultOriginRestrictionForType, 726 FetchRequest::UseDefaultOriginRestrictionForType,
710 RedirectStatus::FollowedRedirect); 727 RedirectStatus::FollowedRedirect);
711 if (blockedReason != ResourceRequestBlockedReason::None) { 728 if (blockedReason != ResourceRequestBlockedReason::None) {
712 probe::didBlockRequest(frame(), resourceRequest, masterDocumentLoader(), 729 probe::didBlockRequest(m_document, resourceRequest, masterDocumentLoader(),
713 options.initiatorInfo, blockedReason); 730 options.initiatorInfo, blockedReason);
714 } 731 }
715 return blockedReason; 732 return blockedReason;
716 } 733 }
717 734
718 ResourceRequestBlockedReason FrameFetchContext::canRequestInternal( 735 ResourceRequestBlockedReason FrameFetchContext::canRequestInternal(
719 Resource::Type type, 736 Resource::Type type,
720 const ResourceRequest& resourceRequest, 737 const ResourceRequest& resourceRequest,
721 const KURL& url, 738 const KURL& url,
722 const ResourceLoaderOptions& options, 739 const ResourceLoaderOptions& options,
723 SecurityViolationReportingPolicy reportingPolicy, 740 SecurityViolationReportingPolicy reportingPolicy,
724 FetchRequest::OriginRestriction originRestriction, 741 FetchRequest::OriginRestriction originRestriction,
725 ResourceRequest::RedirectStatus redirectStatus) const { 742 ResourceRequest::RedirectStatus redirectStatus) const {
726 bool shouldBlockRequest = false; 743 bool shouldBlockRequest = false;
727 probe::shouldBlockRequest(frame(), resourceRequest, &shouldBlockRequest); 744 probe::shouldBlockRequest(m_document, resourceRequest, &shouldBlockRequest);
728 if (shouldBlockRequest) 745 if (shouldBlockRequest)
729 return ResourceRequestBlockedReason::Inspector; 746 return ResourceRequestBlockedReason::Inspector;
730 747
731 SecurityOrigin* securityOrigin = options.securityOrigin.get(); 748 SecurityOrigin* securityOrigin = options.securityOrigin.get();
732 if (!securityOrigin && m_document) 749 if (!securityOrigin && m_document)
733 securityOrigin = m_document->getSecurityOrigin(); 750 securityOrigin = m_document->getSecurityOrigin();
734 751
735 if (originRestriction != FetchRequest::NoOriginRestriction && 752 if (originRestriction != FetchRequest::NoOriginRestriction &&
736 securityOrigin && !securityOrigin->canDisplay(url)) { 753 securityOrigin && !securityOrigin->canDisplay(url)) {
737 if (reportingPolicy == SecurityViolationReportingPolicy::Report) 754 if (reportingPolicy == SecurityViolationReportingPolicy::Report)
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 if (!frame()->settings()) 1071 if (!frame()->settings())
1055 return priority; 1072 return priority;
1056 1073
1057 // If enabled, drop the priority of all resources in a subframe. 1074 // If enabled, drop the priority of all resources in a subframe.
1058 if (frame()->settings()->getLowPriorityIframes() && !frame()->isMainFrame()) 1075 if (frame()->settings()->getLowPriorityIframes() && !frame()->isMainFrame())
1059 return ResourceLoadPriorityVeryLow; 1076 return ResourceLoadPriorityVeryLow;
1060 1077
1061 return priority; 1078 return priority;
1062 } 1079 }
1063 1080
1081 RefPtr<WebTaskRunner> FrameFetchContext::timerTaskRunner() const {
1082 return frame()->frameScheduler()->timerTaskRunner();
1083 }
1084
1064 RefPtr<WebTaskRunner> FrameFetchContext::loadingTaskRunner() const { 1085 RefPtr<WebTaskRunner> FrameFetchContext::loadingTaskRunner() const {
1065 return frame()->frameScheduler()->loadingTaskRunner(); 1086 return frame()->frameScheduler()->loadingTaskRunner();
1066 } 1087 }
1067 1088
1068 DEFINE_TRACE(FrameFetchContext) { 1089 DEFINE_TRACE(FrameFetchContext) {
1069 visitor->trace(m_document); 1090 visitor->trace(m_document);
1070 visitor->trace(m_documentLoader); 1091 visitor->trace(m_documentLoader);
1071 FetchContext::trace(visitor); 1092 FetchContext::trace(visitor);
1072 } 1093 }
1073 1094
1074 } // namespace blink 1095 } // 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