| 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 void FrameFetchContext::dispatchDidChangeResourcePriority( | 438 void FrameFetchContext::dispatchDidChangeResourcePriority( |
| 439 unsigned long identifier, | 439 unsigned long identifier, |
| 440 ResourceLoadPriority loadPriority, | 440 ResourceLoadPriority loadPriority, |
| 441 int intraPriorityValue) { | 441 int intraPriorityValue) { |
| 442 TRACE_EVENT1( | 442 TRACE_EVENT1( |
| 443 "devtools.timeline", "ResourceChangePriority", "data", | 443 "devtools.timeline", "ResourceChangePriority", "data", |
| 444 InspectorChangeResourcePriorityEvent::data(identifier, loadPriority)); | 444 InspectorChangeResourcePriorityEvent::data(identifier, loadPriority)); |
| 445 probe::didChangeResourcePriority(frame(), identifier, loadPriority); | 445 probe::didChangeResourcePriority(frame(), identifier, loadPriority); |
| 446 } | 446 } |
| 447 | 447 |
| 448 void FrameFetchContext::prepareRequest(ResourceRequest& request) { | 448 void FrameFetchContext::prepareRequest(ResourceRequest& request, |
| 449 RedirectType redirectType) { |
| 449 frame()->loader().applyUserAgent(request); | 450 frame()->loader().applyUserAgent(request); |
| 450 localFrameClient()->dispatchWillSendRequest(request); | 451 localFrameClient()->dispatchWillSendRequest(request); |
| 451 | 452 |
| 453 // ServiceWorker hook ups. |
| 452 if (masterDocumentLoader()->getServiceWorkerNetworkProvider()) { | 454 if (masterDocumentLoader()->getServiceWorkerNetworkProvider()) { |
| 453 WrappedResourceRequest webreq(request); | 455 WrappedResourceRequest webreq(request); |
| 454 masterDocumentLoader()->getServiceWorkerNetworkProvider()->willSendRequest( | 456 masterDocumentLoader()->getServiceWorkerNetworkProvider()->willSendRequest( |
| 455 webreq); | 457 webreq); |
| 456 } | 458 } |
| 459 |
| 460 // If it's not for redirect, hook up ApplicationCache here too. |
| 461 if (redirectType == FetchContext::RedirectType::kNotForRedirect && |
| 462 m_documentLoader && !m_documentLoader->fetcher()->archive() && |
| 463 request.url().isValid()) { |
| 464 m_documentLoader->applicationCacheHost()->willStartLoading(request); |
| 465 } |
| 457 } | 466 } |
| 458 | 467 |
| 459 void FrameFetchContext::dispatchWillSendRequest( | 468 void FrameFetchContext::dispatchWillSendRequest( |
| 460 unsigned long identifier, | 469 unsigned long identifier, |
| 461 ResourceRequest& request, | 470 ResourceRequest& request, |
| 462 const ResourceResponse& redirectResponse, | 471 const ResourceResponse& redirectResponse, |
| 463 const FetchInitiatorInfo& initiatorInfo) { | 472 const FetchInitiatorInfo& initiatorInfo) { |
| 464 // For initial requests, prepareRequest() is called in | 473 if (redirectResponse.isNull()) { |
| 465 // willStartLoadingResource(), before revalidation policy is determined. That | 474 // Progress doesn't care about redirects, only notify it when an |
| 466 // call doesn't exist for redirects, so call preareRequest() here. | 475 // initial request is sent. |
| 467 if (!redirectResponse.isNull()) { | |
| 468 prepareRequest(request); | |
| 469 } else { | |
| 470 frame()->loader().progress().willStartLoading(identifier, | 476 frame()->loader().progress().willStartLoading(identifier, |
| 471 request.priority()); | 477 request.priority()); |
| 472 } | 478 } |
| 473 probe::willSendRequest(frame(), identifier, masterDocumentLoader(), request, | 479 probe::willSendRequest(frame(), identifier, masterDocumentLoader(), request, |
| 474 redirectResponse, initiatorInfo); | 480 redirectResponse, initiatorInfo); |
| 475 if (frame()->frameScheduler()) | 481 if (frame()->frameScheduler()) |
| 476 frame()->frameScheduler()->didStartLoading(identifier); | 482 frame()->frameScheduler()->didStartLoading(identifier); |
| 477 } | 483 } |
| 478 | 484 |
| 479 void FrameFetchContext::dispatchDidReceiveResponse( | 485 void FrameFetchContext::dispatchDidReceiveResponse( |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 loadResourceTraceData(unsigned long identifier, const KURL& url, int priority) { | 578 loadResourceTraceData(unsigned long identifier, const KURL& url, int priority) { |
| 573 String requestId = IdentifiersFactory::requestId(identifier); | 579 String requestId = IdentifiersFactory::requestId(identifier); |
| 574 | 580 |
| 575 std::unique_ptr<TracedValue> value = TracedValue::create(); | 581 std::unique_ptr<TracedValue> value = TracedValue::create(); |
| 576 value->setString("requestId", requestId); | 582 value->setString("requestId", requestId); |
| 577 value->setString("url", url.getString()); | 583 value->setString("url", url.getString()); |
| 578 value->setInteger("priority", priority); | 584 value->setInteger("priority", priority); |
| 579 return value; | 585 return value; |
| 580 } | 586 } |
| 581 | 587 |
| 582 void FrameFetchContext::willStartLoadingResource( | 588 void FrameFetchContext::recordLoadingActivity( |
| 583 unsigned long identifier, | 589 unsigned long identifier, |
| 584 ResourceRequest& request, | 590 const ResourceRequest& request, |
| 585 Resource::Type type, | 591 Resource::Type type, |
| 586 const AtomicString& fetchInitiatorName, | 592 const AtomicString& fetchInitiatorName) { |
| 587 V8ActivityLoggingPolicy loggingPolicy) { | |
| 588 TRACE_EVENT_ASYNC_BEGIN1( | 593 TRACE_EVENT_ASYNC_BEGIN1( |
| 589 "blink.net", "Resource", identifier, "data", | 594 "blink.net", "Resource", identifier, "data", |
| 590 loadResourceTraceData(identifier, request.url(), request.priority())); | 595 loadResourceTraceData(identifier, request.url(), request.priority())); |
| 591 prepareRequest(request); | |
| 592 | |
| 593 if (!m_documentLoader || m_documentLoader->fetcher()->archive() || | 596 if (!m_documentLoader || m_documentLoader->fetcher()->archive() || |
| 594 !request.url().isValid()) | 597 !request.url().isValid()) |
| 595 return; | 598 return; |
| 596 if (type == Resource::MainResource) { | 599 V8DOMActivityLogger* activityLogger = nullptr; |
| 597 m_documentLoader->applicationCacheHost()->willStartLoadingMainResource( | 600 if (fetchInitiatorName == FetchInitiatorTypeNames::xmlhttprequest) { |
| 598 request); | 601 activityLogger = V8DOMActivityLogger::currentActivityLogger(); |
| 599 } else { | 602 } else { |
| 600 m_documentLoader->applicationCacheHost()->willStartLoadingResource(request); | 603 activityLogger = |
| 604 V8DOMActivityLogger::currentActivityLoggerIfIsolatedWorld(); |
| 601 } | 605 } |
| 602 if (loggingPolicy == V8ActivityLoggingPolicy::Log) { | |
| 603 V8DOMActivityLogger* activityLogger = nullptr; | |
| 604 if (fetchInitiatorName == FetchInitiatorTypeNames::xmlhttprequest) { | |
| 605 activityLogger = V8DOMActivityLogger::currentActivityLogger(); | |
| 606 } else { | |
| 607 activityLogger = | |
| 608 V8DOMActivityLogger::currentActivityLoggerIfIsolatedWorld(); | |
| 609 } | |
| 610 | 606 |
| 611 if (activityLogger) { | 607 if (activityLogger) { |
| 612 Vector<String> argv; | 608 Vector<String> argv; |
| 613 argv.push_back(Resource::resourceTypeToString(type, fetchInitiatorName)); | 609 argv.push_back(Resource::resourceTypeToString(type, fetchInitiatorName)); |
| 614 argv.push_back(request.url()); | 610 argv.push_back(request.url()); |
| 615 activityLogger->logEvent("blinkRequestResource", argv.size(), | 611 activityLogger->logEvent("blinkRequestResource", argv.size(), argv.data()); |
| 616 argv.data()); | |
| 617 } | |
| 618 } | 612 } |
| 619 } | 613 } |
| 620 | 614 |
| 621 void FrameFetchContext::didLoadResource(Resource* resource) { | 615 void FrameFetchContext::didLoadResource(Resource* resource) { |
| 622 if (resource->isLoadEventBlockingResourceType()) | 616 if (resource->isLoadEventBlockingResourceType()) |
| 623 frame()->loader().checkCompleted(); | 617 frame()->loader().checkCompleted(); |
| 624 if (m_document) | 618 if (m_document) |
| 625 FirstMeaningfulPaintDetector::from(*m_document).checkNetworkStable(); | 619 FirstMeaningfulPaintDetector::from(*m_document).checkNetworkStable(); |
| 626 } | 620 } |
| 627 | 621 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 response); | 1074 response); |
| 1081 } | 1075 } |
| 1082 | 1076 |
| 1083 DEFINE_TRACE(FrameFetchContext) { | 1077 DEFINE_TRACE(FrameFetchContext) { |
| 1084 visitor->trace(m_document); | 1078 visitor->trace(m_document); |
| 1085 visitor->trace(m_documentLoader); | 1079 visitor->trace(m_documentLoader); |
| 1086 FetchContext::trace(visitor); | 1080 FetchContext::trace(visitor); |
| 1087 } | 1081 } |
| 1088 | 1082 |
| 1089 } // namespace blink | 1083 } // namespace blink |
| OLD | NEW |