OLD | NEW |
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 Loading... |
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 Loading... |
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, |
397 } | 398 MasterDocumentLoader(), data, data_length); |
398 | |
399 void FrameFetchContext::DispatchDidReceiveEncodedData(unsigned long identifier, | |
400 int encoded_data_length) { | |
401 probe::didReceiveEncodedDataLength(GetFrame(), identifier, | |
402 encoded_data_length); | |
403 } | 399 } |
404 | 400 |
405 void FrameFetchContext::DispatchDidDownloadData(unsigned long identifier, | 401 void FrameFetchContext::DispatchDidDownloadData(unsigned long identifier, |
406 int data_length, | 402 int data_length, |
407 int encoded_data_length) { | 403 int encoded_data_length) { |
408 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length); | 404 GetFrame()->Loader().Progress().IncrementProgress(identifier, data_length); |
409 probe::didReceiveData(GetFrame(), identifier, 0, data_length); | 405 probe::didReceiveData(GetFrame()->GetDocument(), identifier, |
410 probe::didReceiveEncodedDataLength(GetFrame(), identifier, | 406 MasterDocumentLoader(), 0, data_length); |
| 407 probe::didReceiveEncodedDataLength(GetFrame()->GetDocument(), identifier, |
411 encoded_data_length); | 408 encoded_data_length); |
412 } | 409 } |
413 | 410 |
414 void FrameFetchContext::DispatchDidFinishLoading(unsigned long identifier, | 411 void FrameFetchContext::DispatchDidFinishLoading(unsigned long identifier, |
415 double finish_time, | 412 double finish_time, |
416 int64_t encoded_data_length, | 413 int64_t encoded_data_length, |
417 int64_t decoded_body_length) { | 414 int64_t decoded_body_length) { |
418 GetFrame()->Loader().Progress().CompleteProgress(identifier); | 415 GetFrame()->Loader().Progress().CompleteProgress(identifier); |
419 probe::didFinishLoading(GetFrame(), identifier, finish_time, | 416 probe::didFinishLoading(GetFrame()->GetDocument(), identifier, |
| 417 MasterDocumentLoader(), finish_time, |
420 encoded_data_length, decoded_body_length); | 418 encoded_data_length, decoded_body_length); |
421 if (GetFrame()->FrameScheduler()) | 419 if (GetFrame()->FrameScheduler()) |
422 GetFrame()->FrameScheduler()->DidStopLoading(identifier); | 420 GetFrame()->FrameScheduler()->DidStopLoading(identifier); |
423 } | 421 } |
424 | 422 |
425 void FrameFetchContext::DispatchDidFail(unsigned long identifier, | 423 void FrameFetchContext::DispatchDidFail(unsigned long identifier, |
426 const ResourceError& error, | 424 const ResourceError& error, |
427 int64_t encoded_data_length, | 425 int64_t encoded_data_length, |
428 bool is_internal_request) { | 426 bool is_internal_request) { |
429 GetFrame()->Loader().Progress().CompleteProgress(identifier); | 427 GetFrame()->Loader().Progress().CompleteProgress(identifier); |
430 probe::didFailLoading(GetFrame(), identifier, error); | 428 probe::didFailLoading(GetFrame()->GetDocument(), identifier, error); |
431 // Notification to FrameConsole should come AFTER InspectorInstrumentation | 429 // Notification to FrameConsole should come AFTER InspectorInstrumentation |
432 // call, DevTools front-end relies on this. | 430 // call, DevTools front-end relies on this. |
433 if (!is_internal_request) | 431 if (!is_internal_request) |
434 GetFrame()->Console().DidFailLoading(identifier, error); | 432 GetFrame()->Console().DidFailLoading(identifier, error); |
435 if (GetFrame()->FrameScheduler()) | 433 if (GetFrame()->FrameScheduler()) |
436 GetFrame()->FrameScheduler()->DidStopLoading(identifier); | 434 GetFrame()->FrameScheduler()->DidStopLoading(identifier); |
437 } | 435 } |
438 | 436 |
439 void FrameFetchContext::DispatchDidLoadResourceFromMemoryCache( | 437 void FrameFetchContext::DispatchDidLoadResourceFromMemoryCache( |
440 unsigned long identifier, | 438 unsigned long identifier, |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 DocumentLoader* document_loader = MasterDocumentLoader(); | 723 DocumentLoader* document_loader = MasterDocumentLoader(); |
726 return document_loader ? document_loader->GetSubresourceFilter() : nullptr; | 724 return document_loader ? document_loader->GetSubresourceFilter() : nullptr; |
727 } | 725 } |
728 | 726 |
729 SecurityContext* FrameFetchContext::GetParentSecurityContext() const { | 727 SecurityContext* FrameFetchContext::GetParentSecurityContext() const { |
730 if (Frame* parent = GetFrame()->Tree().Parent()) | 728 if (Frame* parent = GetFrame()->Tree().Parent()) |
731 return parent->GetSecurityContext(); | 729 return parent->GetSecurityContext(); |
732 return nullptr; | 730 return nullptr; |
733 } | 731 } |
734 | 732 |
735 bool FrameFetchContext::ShouldBlockRequestByInspector( | |
736 const ResourceRequest& resource_request) const { | |
737 bool should_block_request = false; | |
738 probe::shouldBlockRequest(GetFrame(), resource_request, | |
739 &should_block_request); | |
740 return should_block_request; | |
741 } | |
742 | |
743 void FrameFetchContext::DispatchDidBlockRequest( | 733 void FrameFetchContext::DispatchDidBlockRequest( |
744 const ResourceRequest& resource_request, | 734 const ResourceRequest& resource_request, |
745 const FetchInitiatorInfo& fetch_initiator_info, | 735 const FetchInitiatorInfo& fetch_initiator_info, |
746 ResourceRequestBlockedReason blocked_reason) const { | 736 ResourceRequestBlockedReason blocked_reason) const { |
747 probe::didBlockRequest(GetFrame(), resource_request, MasterDocumentLoader(), | 737 probe::didBlockRequest(GetDocument(), resource_request, |
748 fetch_initiator_info, blocked_reason); | 738 MasterDocumentLoader(), fetch_initiator_info, |
| 739 blocked_reason); |
749 } | 740 } |
750 | 741 |
751 void FrameFetchContext::ReportLocalLoadFailed(const KURL& url) const { | 742 void FrameFetchContext::ReportLocalLoadFailed(const KURL& url) const { |
752 FrameLoader::ReportLocalLoadFailed(GetFrame(), url.ElidedString()); | 743 FrameLoader::ReportLocalLoadFailed(GetFrame(), url.ElidedString()); |
753 } | 744 } |
754 | 745 |
755 bool FrameFetchContext::ShouldBypassMainWorldCSP() const { | 746 bool FrameFetchContext::ShouldBypassMainWorldCSP() const { |
756 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP(); | 747 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP(); |
757 } | 748 } |
758 | 749 |
(...skipping 20 matching lines...) Expand all Loading... |
779 std::unique_ptr<WebURLLoader> FrameFetchContext::CreateURLLoader() { | 770 std::unique_ptr<WebURLLoader> FrameFetchContext::CreateURLLoader() { |
780 return GetFrame()->CreateURLLoader(); | 771 return GetFrame()->CreateURLLoader(); |
781 } | 772 } |
782 | 773 |
783 DEFINE_TRACE(FrameFetchContext) { | 774 DEFINE_TRACE(FrameFetchContext) { |
784 visitor->Trace(document_loader_); | 775 visitor->Trace(document_loader_); |
785 BaseFetchContext::Trace(visitor); | 776 BaseFetchContext::Trace(visitor); |
786 } | 777 } |
787 | 778 |
788 } // namespace blink | 779 } // namespace blink |
OLD | NEW |