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

Unified Diff: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp

Issue 2747203002: Make prepareRequest() a separate callback of FetchContext (Closed)
Patch Set: addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
index 5f8ca3e28039e6fc019e2d530e25f246699ca152..34ec8253a454e9adec3fa4eefa0c86c31fbef9d1 100644
--- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
@@ -445,15 +445,24 @@ void FrameFetchContext::dispatchDidChangeResourcePriority(
probe::didChangeResourcePriority(frame(), identifier, loadPriority);
}
-void FrameFetchContext::prepareRequest(ResourceRequest& request) {
+void FrameFetchContext::prepareRequest(ResourceRequest& request,
+ RedirectType redirectType) {
frame()->loader().applyUserAgent(request);
localFrameClient()->dispatchWillSendRequest(request);
+ // ServiceWorker hook ups.
if (masterDocumentLoader()->getServiceWorkerNetworkProvider()) {
WrappedResourceRequest webreq(request);
masterDocumentLoader()->getServiceWorkerNetworkProvider()->willSendRequest(
webreq);
}
+
+ // If it's not for redirect, hook up ApplicationCache here too.
+ if (redirectType == FetchContext::RedirectType::kNotForRedirect &&
+ m_documentLoader && !m_documentLoader->fetcher()->archive() &&
+ request.url().isValid()) {
+ m_documentLoader->applicationCacheHost()->willStartLoading(request);
+ }
}
void FrameFetchContext::dispatchWillSendRequest(
@@ -461,12 +470,9 @@ void FrameFetchContext::dispatchWillSendRequest(
ResourceRequest& request,
const ResourceResponse& redirectResponse,
const FetchInitiatorInfo& initiatorInfo) {
- // For initial requests, prepareRequest() is called in
- // willStartLoadingResource(), before revalidation policy is determined. That
- // call doesn't exist for redirects, so call preareRequest() here.
- if (!redirectResponse.isNull()) {
- prepareRequest(request);
- } else {
+ if (redirectResponse.isNull()) {
+ // Progress doesn't care about redirects, only notify it when an
+ // initial request is sent.
frame()->loader().progress().willStartLoading(identifier,
request.priority());
}
@@ -579,42 +585,30 @@ loadResourceTraceData(unsigned long identifier, const KURL& url, int priority) {
return value;
}
-void FrameFetchContext::willStartLoadingResource(
+void FrameFetchContext::recordLoadingActivity(
unsigned long identifier,
- ResourceRequest& request,
+ const ResourceRequest& request,
Resource::Type type,
- const AtomicString& fetchInitiatorName,
- V8ActivityLoggingPolicy loggingPolicy) {
+ const AtomicString& fetchInitiatorName) {
TRACE_EVENT_ASYNC_BEGIN1(
"blink.net", "Resource", identifier, "data",
loadResourceTraceData(identifier, request.url(), request.priority()));
- prepareRequest(request);
-
if (!m_documentLoader || m_documentLoader->fetcher()->archive() ||
!request.url().isValid())
return;
- if (type == Resource::MainResource) {
- m_documentLoader->applicationCacheHost()->willStartLoadingMainResource(
- request);
+ V8DOMActivityLogger* activityLogger = nullptr;
+ if (fetchInitiatorName == FetchInitiatorTypeNames::xmlhttprequest) {
+ activityLogger = V8DOMActivityLogger::currentActivityLogger();
} else {
- m_documentLoader->applicationCacheHost()->willStartLoadingResource(request);
+ activityLogger =
+ V8DOMActivityLogger::currentActivityLoggerIfIsolatedWorld();
}
- if (loggingPolicy == V8ActivityLoggingPolicy::Log) {
- V8DOMActivityLogger* activityLogger = nullptr;
- if (fetchInitiatorName == FetchInitiatorTypeNames::xmlhttprequest) {
- activityLogger = V8DOMActivityLogger::currentActivityLogger();
- } else {
- activityLogger =
- V8DOMActivityLogger::currentActivityLoggerIfIsolatedWorld();
- }
- if (activityLogger) {
- Vector<String> argv;
- argv.push_back(Resource::resourceTypeToString(type, fetchInitiatorName));
- argv.push_back(request.url());
- activityLogger->logEvent("blinkRequestResource", argv.size(),
- argv.data());
- }
+ if (activityLogger) {
+ Vector<String> argv;
+ argv.push_back(Resource::resourceTypeToString(type, fetchInitiatorName));
+ argv.push_back(request.url());
+ activityLogger->logEvent("blinkRequestResource", argv.size(), argv.data());
}
}
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameFetchContext.h ('k') | third_party/WebKit/Source/core/loader/PingLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698