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

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

Issue 2807533003: [WIP2] off-main-thread loading
Patch Set: rebase 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 unsigned long identifier, 313 unsigned long identifier,
314 ResourceRequest& request, 314 ResourceRequest& request,
315 const ResourceResponse& redirect_response, 315 const ResourceResponse& redirect_response,
316 const FetchInitiatorInfo& initiator_info) { 316 const FetchInitiatorInfo& initiator_info) {
317 if (redirect_response.IsNull()) { 317 if (redirect_response.IsNull()) {
318 // Progress doesn't care about redirects, only notify it when an 318 // Progress doesn't care about redirects, only notify it when an
319 // initial request is sent. 319 // initial request is sent.
320 GetFrame()->Loader().Progress().WillStartLoading(identifier, 320 GetFrame()->Loader().Progress().WillStartLoading(identifier,
321 request.Priority()); 321 request.Priority());
322 } 322 }
323 probe::willSendRequest(GetFrame(), identifier, MasterDocumentLoader(), 323 probe::willSendRequest(GetFrame()->GetDocument(), identifier,
324 request, redirect_response, initiator_info); 324 MasterDocumentLoader(), request, redirect_response,
325 initiator_info);
325 if (GetFrame()->FrameScheduler()) 326 if (GetFrame()->FrameScheduler())
326 GetFrame()->FrameScheduler()->DidStartLoading(identifier); 327 GetFrame()->FrameScheduler()->DidStartLoading(identifier);
327 } 328 }
328 329
329 void FrameFetchContext::DispatchDidReceiveResponse( 330 void FrameFetchContext::DispatchDidReceiveResponse(
330 unsigned long identifier, 331 unsigned long identifier,
331 const ResourceResponse& response, 332 const ResourceResponse& response,
332 WebURLRequest::FrameType frame_type, 333 WebURLRequest::FrameType frame_type,
333 WebURLRequest::RequestContext request_context, 334 WebURLRequest::RequestContext request_context,
334 Resource* resource, 335 Resource* resource,
(...skipping 28 matching lines...) Expand all
363 LinkLoader::kLoadAll, nullptr); 364 LinkLoader::kLoadAll, nullptr);
364 365
365 if (response.HasMajorCertificateErrors()) { 366 if (response.HasMajorCertificateErrors()) {
366 MixedContentChecker::HandleCertificateError(GetFrame(), response, 367 MixedContentChecker::HandleCertificateError(GetFrame(), response,
367 frame_type, request_context); 368 frame_type, request_context);
368 } 369 }
369 370
370 GetFrame()->Loader().Progress().IncrementProgress(identifier, response); 371 GetFrame()->Loader().Progress().IncrementProgress(identifier, response);
371 GetLocalFrameClient()->DispatchDidReceiveResponse(response); 372 GetLocalFrameClient()->DispatchDidReceiveResponse(response);
372 DocumentLoader* document_loader = MasterDocumentLoader(); 373 DocumentLoader* document_loader = MasterDocumentLoader();
373 probe::didReceiveResourceResponse(GetFrame(), identifier, document_loader, 374 probe::didReceiveResourceResponse(GetFrame()->GetDocument(), identifier,
374 response, resource); 375 document_loader, response, resource);
375 // It is essential that inspector gets resource response BEFORE console. 376 // It is essential that inspector gets resource response BEFORE console.
376 GetFrame()->Console().ReportResourceResponseReceived(document_loader, 377 GetFrame()->Console().ReportResourceResponseReceived(document_loader,
377 identifier, response); 378 identifier, response);
378 379
379 // MainResource responses were already added, skip them here. 380 // MainResource responses were already added, skip them here.
380 if (RuntimeEnabledFeatures::serverTimingEnabled() && 381 if (RuntimeEnabledFeatures::serverTimingEnabled() &&
381 resource->GetType() != Resource::kMainResource && 382 resource->GetType() != Resource::kMainResource &&
382 GetFrame()->GetDocument() && GetFrame()->GetDocument()->domWindow()) { 383 GetFrame()->GetDocument() && GetFrame()->GetDocument()->domWindow()) {
383 LocalDOMWindow* localDOMWindow = GetFrame()->GetDocument()->domWindow(); 384 LocalDOMWindow* localDOMWindow = GetFrame()->GetDocument()->domWindow();
384 DOMWindowPerformance::performance(*localDOMWindow) 385 DOMWindowPerformance::performance(*localDOMWindow)
385 ->AddServerTiming(response, 386 ->AddServerTiming(response,
386 localDOMWindow->HasLoadEventFired() 387 localDOMWindow->HasLoadEventFired()
387 ? PerformanceBase::ShouldAddToBuffer::Never 388 ? PerformanceBase::ShouldAddToBuffer::Never
388 : PerformanceBase::ShouldAddToBuffer::Always); 389 : PerformanceBase::ShouldAddToBuffer::Always);
389 } 390 }
390 } 391 }
391 392
392 void FrameFetchContext::DispatchDidReceiveData(unsigned long identifier, 393 void FrameFetchContext::DispatchDidReceiveData(unsigned long identifier,
393 const char* data, 394 const char* data,
394 int data_length) { 395 int data_length) {
395 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length); 396 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length);
396 probe::didReceiveData(GetFrame(), identifier, data, data_length); 397 probe::didReceiveData(GetFrame()->GetDocument(), identifier,
398 MasterDocumentLoader(), data, data_length);
397 } 399 }
398 400
399 void FrameFetchContext::DispatchDidReceiveEncodedData(unsigned long identifier, 401 void FrameFetchContext::DispatchDidReceiveEncodedData(unsigned long identifier,
400 int encoded_data_length) { 402 int encoded_data_length) {
401 probe::didReceiveEncodedDataLength(GetFrame(), identifier, 403 probe::didReceiveEncodedDataLength(GetFrame()->GetDocument(), identifier,
402 encoded_data_length); 404 encoded_data_length);
403 } 405 }
404 406
405 void FrameFetchContext::DispatchDidDownloadData(unsigned long identifier, 407 void FrameFetchContext::DispatchDidDownloadData(unsigned long identifier,
406 int data_length, 408 int data_length,
407 int encoded_data_length) { 409 int encoded_data_length) {
408 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length); 410 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length);
409 probe::didReceiveData(GetFrame(), identifier, 0, data_length); 411 probe::didReceiveData(GetFrame()->GetDocument(), identifier,
410 probe::didReceiveEncodedDataLength(GetFrame(), identifier, 412 MasterDocumentLoader(), 0, data_length);
413 probe::didReceiveEncodedDataLength(GetFrame()->GetDocument(), identifier,
411 encoded_data_length); 414 encoded_data_length);
412 } 415 }
413 416
414 void FrameFetchContext::DispatchDidFinishLoading(unsigned long identifier, 417 void FrameFetchContext::DispatchDidFinishLoading(unsigned long identifier,
415 double finish_time, 418 double finish_time,
416 int64_t encoded_data_length, 419 int64_t encoded_data_length,
417 int64_t decoded_body_length) { 420 int64_t decoded_body_length) {
418 GetFrame()->Loader().Progress().CompleteProgress(identifier); 421 GetFrame()->Loader().Progress().CompleteProgress(identifier);
419 probe::didFinishLoading(GetFrame(), identifier, finish_time, 422 probe::didFinishLoading(GetFrame()->GetDocument(), identifier,
423 MasterDocumentLoader(), finish_time,
420 encoded_data_length, decoded_body_length); 424 encoded_data_length, decoded_body_length);
421 if (GetFrame()->FrameScheduler()) 425 if (GetFrame()->FrameScheduler())
422 GetFrame()->FrameScheduler()->DidStopLoading(identifier); 426 GetFrame()->FrameScheduler()->DidStopLoading(identifier);
423 } 427 }
424 428
425 void FrameFetchContext::DispatchDidFail(unsigned long identifier, 429 void FrameFetchContext::DispatchDidFail(unsigned long identifier,
426 const ResourceError& error, 430 const ResourceError& error,
427 int64_t encoded_data_length, 431 int64_t encoded_data_length,
428 bool is_internal_request) { 432 bool is_internal_request) {
429 GetFrame()->Loader().Progress().CompleteProgress(identifier); 433 GetFrame()->Loader().Progress().CompleteProgress(identifier);
430 probe::didFailLoading(GetFrame(), identifier, error); 434 probe::didFailLoading(GetFrame()->GetDocument(), identifier, error);
431 // Notification to FrameConsole should come AFTER InspectorInstrumentation 435 // Notification to FrameConsole should come AFTER InspectorInstrumentation
432 // call, DevTools front-end relies on this. 436 // call, DevTools front-end relies on this.
433 if (!is_internal_request) 437 if (!is_internal_request)
434 GetFrame()->Console().DidFailLoading(identifier, error); 438 GetFrame()->Console().DidFailLoading(identifier, error);
435 if (GetFrame()->FrameScheduler()) 439 if (GetFrame()->FrameScheduler())
436 GetFrame()->FrameScheduler()->DidStopLoading(identifier); 440 GetFrame()->FrameScheduler()->DidStopLoading(identifier);
437 } 441 }
438 442
439 void FrameFetchContext::DispatchDidLoadResourceFromMemoryCache( 443 void FrameFetchContext::DispatchDidLoadResourceFromMemoryCache(
440 unsigned long identifier, 444 unsigned long identifier,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 543
540 int64_t FrameFetchContext::ServiceWorkerID() const { 544 int64_t FrameFetchContext::ServiceWorkerID() const {
541 DCHECK(MasterDocumentLoader()); 545 DCHECK(MasterDocumentLoader());
542 auto* service_worker_network_provider = 546 auto* service_worker_network_provider =
543 MasterDocumentLoader()->GetServiceWorkerNetworkProvider(); 547 MasterDocumentLoader()->GetServiceWorkerNetworkProvider();
544 return service_worker_network_provider 548 return service_worker_network_provider
545 ? service_worker_network_provider->ServiceWorkerID() 549 ? service_worker_network_provider->ServiceWorkerID()
546 : -1; 550 : -1;
547 } 551 }
548 552
553 int FrameFetchContext::ApplicationCacheHostID() const {
554 if (!document_loader_)
555 return 0;
556 return document_loader_->GetApplicationCacheHost()->GetHostID();
557 }
558
549 bool FrameFetchContext::IsMainFrame() const { 559 bool FrameFetchContext::IsMainFrame() const {
550 return GetFrame()->IsMainFrame(); 560 return GetFrame()->IsMainFrame();
551 } 561 }
552 562
553 bool FrameFetchContext::DefersLoading() const { 563 bool FrameFetchContext::DefersLoading() const {
554 return GetFrame()->GetPage()->Suspended(); 564 return GetFrame()->GetPage()->Suspended();
555 } 565 }
556 566
557 bool FrameFetchContext::IsLoadComplete() const { 567 bool FrameFetchContext::IsLoadComplete() const {
558 return GetDocument() && GetDocument()->LoadEventFinished(); 568 return GetDocument() && GetDocument()->LoadEventFinished();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 738
729 SecurityContext* FrameFetchContext::GetParentSecurityContext() const { 739 SecurityContext* FrameFetchContext::GetParentSecurityContext() const {
730 if (Frame* parent = GetFrame()->Tree().Parent()) 740 if (Frame* parent = GetFrame()->Tree().Parent())
731 return parent->GetSecurityContext(); 741 return parent->GetSecurityContext();
732 return nullptr; 742 return nullptr;
733 } 743 }
734 744
735 bool FrameFetchContext::ShouldBlockRequestByInspector( 745 bool FrameFetchContext::ShouldBlockRequestByInspector(
736 const ResourceRequest& resource_request) const { 746 const ResourceRequest& resource_request) const {
737 bool should_block_request = false; 747 bool should_block_request = false;
738 probe::shouldBlockRequest(GetFrame(), resource_request, 748 probe::shouldBlockRequest(GetDocument(), resource_request,
739 &should_block_request); 749 &should_block_request);
740 return should_block_request; 750 return should_block_request;
741 } 751 }
742 752
743 void FrameFetchContext::DispatchDidBlockRequest( 753 void FrameFetchContext::DispatchDidBlockRequest(
744 const ResourceRequest& resource_request, 754 const ResourceRequest& resource_request,
745 const FetchInitiatorInfo& fetch_initiator_info, 755 const FetchInitiatorInfo& fetch_initiator_info,
746 ResourceRequestBlockedReason blocked_reason) const { 756 ResourceRequestBlockedReason blocked_reason) const {
747 probe::didBlockRequest(GetFrame(), resource_request, MasterDocumentLoader(), 757 probe::didBlockRequest(GetDocument(), resource_request,
748 fetch_initiator_info, blocked_reason); 758 MasterDocumentLoader(), fetch_initiator_info,
759 blocked_reason);
749 } 760 }
750 761
751 void FrameFetchContext::ReportLocalLoadFailed(const KURL& url) const { 762 void FrameFetchContext::ReportLocalLoadFailed(const KURL& url) const {
752 FrameLoader::ReportLocalLoadFailed(GetFrame(), url.ElidedString()); 763 FrameLoader::ReportLocalLoadFailed(GetFrame(), url.ElidedString());
753 } 764 }
754 765
755 bool FrameFetchContext::ShouldBypassMainWorldCSP() const { 766 bool FrameFetchContext::ShouldBypassMainWorldCSP() const {
756 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP(); 767 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP();
757 } 768 }
758 769
(...skipping 20 matching lines...) Expand all
779 std::unique_ptr<WebURLLoader> FrameFetchContext::CreateURLLoader() { 790 std::unique_ptr<WebURLLoader> FrameFetchContext::CreateURLLoader() {
780 return GetFrame()->CreateURLLoader(); 791 return GetFrame()->CreateURLLoader();
781 } 792 }
782 793
783 DEFINE_TRACE(FrameFetchContext) { 794 DEFINE_TRACE(FrameFetchContext) {
784 visitor->Trace(document_loader_); 795 visitor->Trace(document_loader_);
785 BaseFetchContext::Trace(visitor); 796 BaseFetchContext::Trace(visitor);
786 } 797 }
787 798
788 } // namespace blink 799 } // 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