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 2747203002: Make prepareRequest() a separate callback of FetchContext (Closed)
Patch Set: . Created 3 years, 9 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 void FrameFetchContext::dispatchDidChangeResourcePriority( 415 void FrameFetchContext::dispatchDidChangeResourcePriority(
416 unsigned long identifier, 416 unsigned long identifier,
417 ResourceLoadPriority loadPriority, 417 ResourceLoadPriority loadPriority,
418 int intraPriorityValue) { 418 int intraPriorityValue) {
419 TRACE_EVENT1( 419 TRACE_EVENT1(
420 "devtools.timeline", "ResourceChangePriority", "data", 420 "devtools.timeline", "ResourceChangePriority", "data",
421 InspectorChangeResourcePriorityEvent::data(identifier, loadPriority)); 421 InspectorChangeResourcePriorityEvent::data(identifier, loadPriority));
422 probe::didChangeResourcePriority(frame(), identifier, loadPriority); 422 probe::didChangeResourcePriority(frame(), identifier, loadPriority);
423 } 423 }
424 424
425 void FrameFetchContext::prepareRequest(ResourceRequest& request) { 425 void FrameFetchContext::prepareRequest(ResourceRequest& request,
426 RedirectType redirectType) {
426 frame()->loader().applyUserAgent(request); 427 frame()->loader().applyUserAgent(request);
427 localFrameClient()->dispatchWillSendRequest(request); 428 localFrameClient()->dispatchWillSendRequest(request);
428 429
430 // ServiceWorker hook ups.
429 if (masterDocumentLoader()->getServiceWorkerNetworkProvider()) { 431 if (masterDocumentLoader()->getServiceWorkerNetworkProvider()) {
430 WrappedResourceRequest webreq(request); 432 WrappedResourceRequest webreq(request);
431 masterDocumentLoader()->getServiceWorkerNetworkProvider()->willSendRequest( 433 masterDocumentLoader()->getServiceWorkerNetworkProvider()->willSendRequest(
432 webreq); 434 webreq);
433 } 435 }
436
437 // If it's not for redirect, hook up ApplicationCache here too.
438 if (redirectType == FetchContext::RedirectType::kNotForRedirect &&
439 m_documentLoader && !m_documentLoader->fetcher()->archive() &&
440 request.url().isValid()) {
441 m_documentLoader->applicationCacheHost()->willStartLoading(request);
442 }
434 } 443 }
435 444
436 void FrameFetchContext::dispatchWillSendRequest( 445 void FrameFetchContext::dispatchWillSendRequest(
437 unsigned long identifier, 446 unsigned long identifier,
438 ResourceRequest& request, 447 ResourceRequest& request,
439 const ResourceResponse& redirectResponse, 448 const ResourceResponse& redirectResponse,
440 const FetchInitiatorInfo& initiatorInfo) { 449 const FetchInitiatorInfo& initiatorInfo) {
441 // For initial requests, prepareRequest() is called in 450 if (redirectResponse.isNull()) {
442 // willStartLoadingResource(), before revalidation policy is determined. That 451 // This is an initial requests, not for redirects.
Nate Chapin 2017/03/22 19:12:59 This comment doesn't add much that the if() statem
kinuko 2017/03/23 05:12:17 Sounds good, done.
443 // call doesn't exist for redirects, so call preareRequest() here.
444 if (!redirectResponse.isNull()) {
445 prepareRequest(request);
446 } else {
447 frame()->loader().progress().willStartLoading(identifier, 452 frame()->loader().progress().willStartLoading(identifier,
448 request.priority()); 453 request.priority());
449 } 454 }
450 probe::willSendRequest(frame(), identifier, masterDocumentLoader(), request, 455 probe::willSendRequest(frame(), identifier, masterDocumentLoader(), request,
451 redirectResponse, initiatorInfo); 456 redirectResponse, initiatorInfo);
452 if (frame()->frameScheduler()) 457 if (frame()->frameScheduler())
453 frame()->frameScheduler()->didStartLoading(identifier); 458 frame()->frameScheduler()->didStartLoading(identifier);
454 } 459 }
455 460
456 void FrameFetchContext::dispatchDidReceiveResponse( 461 void FrameFetchContext::dispatchDidReceiveResponse(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 loadResourceTraceData(unsigned long identifier, const KURL& url, int priority) { 554 loadResourceTraceData(unsigned long identifier, const KURL& url, int priority) {
550 String requestId = IdentifiersFactory::requestId(identifier); 555 String requestId = IdentifiersFactory::requestId(identifier);
551 556
552 std::unique_ptr<TracedValue> value = TracedValue::create(); 557 std::unique_ptr<TracedValue> value = TracedValue::create();
553 value->setString("requestId", requestId); 558 value->setString("requestId", requestId);
554 value->setString("url", url.getString()); 559 value->setString("url", url.getString());
555 value->setInteger("priority", priority); 560 value->setInteger("priority", priority);
556 return value; 561 return value;
557 } 562 }
558 563
559 void FrameFetchContext::willStartLoadingResource( 564 void FrameFetchContext::recordLoadingActivity(
560 unsigned long identifier, 565 unsigned long identifier,
561 ResourceRequest& request, 566 const ResourceRequest& request,
562 Resource::Type type, 567 Resource::Type type,
563 const AtomicString& fetchInitiatorName, 568 const AtomicString& fetchInitiatorName) {
564 V8ActivityLoggingPolicy loggingPolicy) {
565 TRACE_EVENT_ASYNC_BEGIN1( 569 TRACE_EVENT_ASYNC_BEGIN1(
566 "blink.net", "Resource", identifier, "data", 570 "blink.net", "Resource", identifier, "data",
567 loadResourceTraceData(identifier, request.url(), request.priority())); 571 loadResourceTraceData(identifier, request.url(), request.priority()));
568 prepareRequest(request);
569
570 if (!m_documentLoader || m_documentLoader->fetcher()->archive() || 572 if (!m_documentLoader || m_documentLoader->fetcher()->archive() ||
571 !request.url().isValid()) 573 !request.url().isValid())
572 return; 574 return;
573 if (type == Resource::MainResource) { 575 V8DOMActivityLogger* activityLogger = nullptr;
574 m_documentLoader->applicationCacheHost()->willStartLoadingMainResource( 576 if (fetchInitiatorName == FetchInitiatorTypeNames::xmlhttprequest) {
575 request); 577 activityLogger = V8DOMActivityLogger::currentActivityLogger();
576 } else { 578 } else {
577 m_documentLoader->applicationCacheHost()->willStartLoadingResource(request); 579 activityLogger =
580 V8DOMActivityLogger::currentActivityLoggerIfIsolatedWorld();
578 } 581 }
579 if (loggingPolicy == V8ActivityLoggingPolicy::Log) {
580 V8DOMActivityLogger* activityLogger = nullptr;
581 if (fetchInitiatorName == FetchInitiatorTypeNames::xmlhttprequest) {
582 activityLogger = V8DOMActivityLogger::currentActivityLogger();
583 } else {
584 activityLogger =
585 V8DOMActivityLogger::currentActivityLoggerIfIsolatedWorld();
586 }
587 582
588 if (activityLogger) { 583 if (activityLogger) {
589 Vector<String> argv; 584 Vector<String> argv;
590 argv.push_back(Resource::resourceTypeToString(type, fetchInitiatorName)); 585 argv.push_back(Resource::resourceTypeToString(type, fetchInitiatorName));
591 argv.push_back(request.url()); 586 argv.push_back(request.url());
592 activityLogger->logEvent("blinkRequestResource", argv.size(), 587 activityLogger->logEvent("blinkRequestResource", argv.size(), argv.data());
593 argv.data());
594 }
595 } 588 }
596 } 589 }
597 590
598 void FrameFetchContext::didLoadResource(Resource* resource) { 591 void FrameFetchContext::didLoadResource(Resource* resource) {
599 if (resource->isLoadEventBlockingResourceType()) 592 if (resource->isLoadEventBlockingResourceType())
600 frame()->loader().checkCompleted(); 593 frame()->loader().checkCompleted();
601 if (m_document) 594 if (m_document)
602 FirstMeaningfulPaintDetector::from(*m_document).checkNetworkStable(); 595 FirstMeaningfulPaintDetector::from(*m_document).checkNetworkStable();
603 } 596 }
604 597
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 response); 1050 response);
1058 } 1051 }
1059 1052
1060 DEFINE_TRACE(FrameFetchContext) { 1053 DEFINE_TRACE(FrameFetchContext) {
1061 visitor->trace(m_document); 1054 visitor->trace(m_document);
1062 visitor->trace(m_documentLoader); 1055 visitor->trace(m_documentLoader);
1063 FetchContext::trace(visitor); 1056 FetchContext::trace(visitor);
1064 } 1057 }
1065 1058
1066 } // namespace blink 1059 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698