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

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

Issue 2900613002: Support DevTools for off-main-thread-fetch (Closed)
Patch Set: rebase Created 3 years, 5 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 const FetchInitiatorInfo& initiator_info) { 391 const FetchInitiatorInfo& initiator_info) {
392 if (IsDetached()) 392 if (IsDetached())
393 return; 393 return;
394 394
395 if (redirect_response.IsNull()) { 395 if (redirect_response.IsNull()) {
396 // Progress doesn't care about redirects, only notify it when an 396 // Progress doesn't care about redirects, only notify it when an
397 // initial request is sent. 397 // initial request is sent.
398 GetFrame()->Loader().Progress().WillStartLoading(identifier, 398 GetFrame()->Loader().Progress().WillStartLoading(identifier,
399 request.Priority()); 399 request.Priority());
400 } 400 }
401 probe::willSendRequest(GetFrame(), identifier, MasterDocumentLoader(), 401 probe::willSendRequest(GetFrame()->GetDocument(), identifier,
402 request, redirect_response, initiator_info); 402 MasterDocumentLoader(), request, redirect_response,
403 initiator_info);
403 if (GetFrame()->FrameScheduler()) 404 if (GetFrame()->FrameScheduler())
404 GetFrame()->FrameScheduler()->DidStartLoading(identifier); 405 GetFrame()->FrameScheduler()->DidStartLoading(identifier);
405 } 406 }
406 407
407 void FrameFetchContext::DispatchDidReceiveResponse( 408 void FrameFetchContext::DispatchDidReceiveResponse(
408 unsigned long identifier, 409 unsigned long identifier,
409 const ResourceResponse& response, 410 const ResourceResponse& response,
410 WebURLRequest::FrameType frame_type, 411 WebURLRequest::FrameType frame_type,
411 WebURLRequest::RequestContext request_context, 412 WebURLRequest::RequestContext request_context,
412 Resource* resource, 413 Resource* resource,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 LinkLoader::kLoadAll, nullptr); 445 LinkLoader::kLoadAll, nullptr);
445 446
446 if (response.HasMajorCertificateErrors()) { 447 if (response.HasMajorCertificateErrors()) {
447 MixedContentChecker::HandleCertificateError(GetFrame(), response, 448 MixedContentChecker::HandleCertificateError(GetFrame(), response,
448 frame_type, request_context); 449 frame_type, request_context);
449 } 450 }
450 451
451 GetFrame()->Loader().Progress().IncrementProgress(identifier, response); 452 GetFrame()->Loader().Progress().IncrementProgress(identifier, response);
452 GetLocalFrameClient()->DispatchDidReceiveResponse(response); 453 GetLocalFrameClient()->DispatchDidReceiveResponse(response);
453 DocumentLoader* document_loader = MasterDocumentLoader(); 454 DocumentLoader* document_loader = MasterDocumentLoader();
454 probe::didReceiveResourceResponse(GetFrame(), identifier, document_loader, 455 probe::didReceiveResourceResponse(GetFrame()->GetDocument(), identifier,
455 response, resource); 456 document_loader, response, resource);
456 // It is essential that inspector gets resource response BEFORE console. 457 // It is essential that inspector gets resource response BEFORE console.
457 GetFrame()->Console().ReportResourceResponseReceived(document_loader, 458 GetFrame()->Console().ReportResourceResponseReceived(document_loader,
458 identifier, response); 459 identifier, response);
459 460
460 // MainResource responses were already added, skip them here. 461 // MainResource responses were already added, skip them here.
461 if (RuntimeEnabledFeatures::ServerTimingEnabled() && 462 if (RuntimeEnabledFeatures::ServerTimingEnabled() &&
462 resource->GetType() != Resource::kMainResource && 463 resource->GetType() != Resource::kMainResource &&
463 GetFrame()->GetDocument() && GetFrame()->GetDocument()->domWindow()) { 464 GetFrame()->GetDocument() && GetFrame()->GetDocument()->domWindow()) {
464 LocalDOMWindow* localDOMWindow = GetFrame()->GetDocument()->domWindow(); 465 LocalDOMWindow* localDOMWindow = GetFrame()->GetDocument()->domWindow();
465 DOMWindowPerformance::performance(*localDOMWindow) 466 DOMWindowPerformance::performance(*localDOMWindow)
466 ->AddServerTiming(response, 467 ->AddServerTiming(response,
467 localDOMWindow->HasLoadEventFired() 468 localDOMWindow->HasLoadEventFired()
468 ? PerformanceBase::ShouldAddToBuffer::Never 469 ? PerformanceBase::ShouldAddToBuffer::Never
469 : PerformanceBase::ShouldAddToBuffer::Always); 470 : PerformanceBase::ShouldAddToBuffer::Always);
470 } 471 }
471 } 472 }
472 473
473 void FrameFetchContext::DispatchDidReceiveData(unsigned long identifier, 474 void FrameFetchContext::DispatchDidReceiveData(unsigned long identifier,
474 const char* data, 475 const char* data,
475 int data_length) { 476 int data_length) {
476 if (IsDetached()) 477 if (IsDetached())
477 return; 478 return;
478 479
479 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length); 480 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length);
480 probe::didReceiveData(GetFrame(), identifier, data, data_length); 481 probe::didReceiveData(GetFrame()->GetDocument(), identifier,
482 MasterDocumentLoader(), data, data_length);
481 } 483 }
482 484
483 void FrameFetchContext::DispatchDidReceiveEncodedData(unsigned long identifier, 485 void FrameFetchContext::DispatchDidReceiveEncodedData(unsigned long identifier,
484 int encoded_data_length) { 486 int encoded_data_length) {
485 if (IsDetached()) 487 if (IsDetached())
486 return; 488 return;
487 489 probe::didReceiveEncodedDataLength(GetFrame()->GetDocument(), identifier,
488 probe::didReceiveEncodedDataLength(GetFrame(), identifier,
489 encoded_data_length); 490 encoded_data_length);
490 } 491 }
491 492
492 void FrameFetchContext::DispatchDidDownloadData(unsigned long identifier, 493 void FrameFetchContext::DispatchDidDownloadData(unsigned long identifier,
493 int data_length, 494 int data_length,
494 int encoded_data_length) { 495 int encoded_data_length) {
495 if (IsDetached()) 496 if (IsDetached())
496 return; 497 return;
497 498
498 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length); 499 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length);
499 probe::didReceiveData(GetFrame(), identifier, 0, data_length); 500 probe::didReceiveData(GetFrame()->GetDocument(), identifier,
500 probe::didReceiveEncodedDataLength(GetFrame(), identifier, 501 MasterDocumentLoader(), 0, data_length);
502 probe::didReceiveEncodedDataLength(GetFrame()->GetDocument(), identifier,
501 encoded_data_length); 503 encoded_data_length);
502 } 504 }
503 505
504 void FrameFetchContext::DispatchDidFinishLoading(unsigned long identifier, 506 void FrameFetchContext::DispatchDidFinishLoading(unsigned long identifier,
505 double finish_time, 507 double finish_time,
506 int64_t encoded_data_length, 508 int64_t encoded_data_length,
507 int64_t decoded_body_length) { 509 int64_t decoded_body_length) {
508 if (IsDetached()) 510 if (IsDetached())
509 return; 511 return;
510 512
511 GetFrame()->Loader().Progress().CompleteProgress(identifier); 513 GetFrame()->Loader().Progress().CompleteProgress(identifier);
512 probe::didFinishLoading(GetFrame(), identifier, finish_time, 514 probe::didFinishLoading(GetFrame()->GetDocument(), identifier,
515 MasterDocumentLoader(), finish_time,
513 encoded_data_length, decoded_body_length); 516 encoded_data_length, decoded_body_length);
514 if (GetFrame()->FrameScheduler()) 517 if (GetFrame()->FrameScheduler())
515 GetFrame()->FrameScheduler()->DidStopLoading(identifier); 518 GetFrame()->FrameScheduler()->DidStopLoading(identifier);
516 } 519 }
517 520
518 void FrameFetchContext::DispatchDidFail(unsigned long identifier, 521 void FrameFetchContext::DispatchDidFail(unsigned long identifier,
519 const ResourceError& error, 522 const ResourceError& error,
520 int64_t encoded_data_length, 523 int64_t encoded_data_length,
521 bool is_internal_request) { 524 bool is_internal_request) {
522 if (IsDetached()) 525 if (IsDetached())
523 return; 526 return;
524 527
525 GetFrame()->Loader().Progress().CompleteProgress(identifier); 528 GetFrame()->Loader().Progress().CompleteProgress(identifier);
526 probe::didFailLoading(GetFrame(), identifier, error); 529 probe::didFailLoading(GetFrame()->GetDocument(), identifier, error);
527 // Notification to FrameConsole should come AFTER InspectorInstrumentation 530 // Notification to FrameConsole should come AFTER InspectorInstrumentation
528 // call, DevTools front-end relies on this. 531 // call, DevTools front-end relies on this.
529 if (!is_internal_request) 532 if (!is_internal_request)
530 GetFrame()->Console().DidFailLoading(identifier, error); 533 GetFrame()->Console().DidFailLoading(identifier, error);
531 if (GetFrame()->FrameScheduler()) 534 if (GetFrame()->FrameScheduler())
532 GetFrame()->FrameScheduler()->DidStopLoading(identifier); 535 GetFrame()->FrameScheduler()->DidStopLoading(identifier);
533 } 536 }
534 537
535 void FrameFetchContext::DispatchDidLoadResourceFromMemoryCache( 538 void FrameFetchContext::DispatchDidLoadResourceFromMemoryCache(
536 unsigned long identifier, 539 unsigned long identifier,
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 return nullptr; 895 return nullptr;
893 DocumentLoader* document_loader = MasterDocumentLoader(); 896 DocumentLoader* document_loader = MasterDocumentLoader();
894 return document_loader ? document_loader->GetSubresourceFilter() : nullptr; 897 return document_loader ? document_loader->GetSubresourceFilter() : nullptr;
895 } 898 }
896 899
897 bool FrameFetchContext::ShouldBlockRequestByInspector( 900 bool FrameFetchContext::ShouldBlockRequestByInspector(
898 const ResourceRequest& resource_request) const { 901 const ResourceRequest& resource_request) const {
899 if (IsDetached()) 902 if (IsDetached())
900 return false; 903 return false;
901 bool should_block_request = false; 904 bool should_block_request = false;
902 probe::shouldBlockRequest(GetFrame(), resource_request, 905 probe::shouldBlockRequest(GetFrame()->GetDocument(), resource_request,
903 &should_block_request); 906 &should_block_request);
904 return should_block_request; 907 return should_block_request;
905 } 908 }
906 909
907 void FrameFetchContext::DispatchDidBlockRequest( 910 void FrameFetchContext::DispatchDidBlockRequest(
908 const ResourceRequest& resource_request, 911 const ResourceRequest& resource_request,
909 const FetchInitiatorInfo& fetch_initiator_info, 912 const FetchInitiatorInfo& fetch_initiator_info,
910 ResourceRequestBlockedReason blocked_reason) const { 913 ResourceRequestBlockedReason blocked_reason) const {
911 if (IsDetached()) 914 if (IsDetached())
912 return; 915 return;
913 probe::didBlockRequest(GetFrame(), resource_request, MasterDocumentLoader(), 916 probe::didBlockRequest(GetFrame()->GetDocument(), resource_request,
914 fetch_initiator_info, blocked_reason); 917 MasterDocumentLoader(), fetch_initiator_info,
918 blocked_reason);
915 } 919 }
916 920
917 bool FrameFetchContext::ShouldBypassMainWorldCSP() const { 921 bool FrameFetchContext::ShouldBypassMainWorldCSP() const {
918 if (IsDetached()) 922 if (IsDetached())
919 return false; 923 return false;
920 924
921 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP(); 925 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP();
922 } 926 }
923 927
924 bool FrameFetchContext::IsSVGImageChromeClient() const { 928 bool FrameFetchContext::IsSVGImageChromeClient() const {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 } 1130 }
1127 1131
1128 DEFINE_TRACE(FrameFetchContext) { 1132 DEFINE_TRACE(FrameFetchContext) {
1129 visitor->Trace(document_loader_); 1133 visitor->Trace(document_loader_);
1130 visitor->Trace(document_); 1134 visitor->Trace(document_);
1131 visitor->Trace(frozen_state_); 1135 visitor->Trace(frozen_state_);
1132 BaseFetchContext::Trace(visitor); 1136 BaseFetchContext::Trace(visitor);
1133 } 1137 }
1134 1138
1135 } // namespace blink 1139 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698