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

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

Issue 1303833002: Add WebPageImportanceSignals::issuedNonGetFetchFromScript() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: tyoshino-san review Created 5 years, 2 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013, Intel Corporation 3 * Copyright (C) 2013, Intel Corporation
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 30 matching lines...) Expand all
41 #include "core/frame/FrameConsole.h" 41 #include "core/frame/FrameConsole.h"
42 #include "core/frame/LocalFrame.h" 42 #include "core/frame/LocalFrame.h"
43 #include "core/frame/csp/ContentSecurityPolicy.h" 43 #include "core/frame/csp/ContentSecurityPolicy.h"
44 #include "core/inspector/InspectorInstrumentation.h" 44 #include "core/inspector/InspectorInstrumentation.h"
45 #include "core/inspector/InspectorTraceEvents.h" 45 #include "core/inspector/InspectorTraceEvents.h"
46 #include "core/loader/CrossOriginPreflightResultCache.h" 46 #include "core/loader/CrossOriginPreflightResultCache.h"
47 #include "core/loader/DocumentThreadableLoaderClient.h" 47 #include "core/loader/DocumentThreadableLoaderClient.h"
48 #include "core/loader/FrameLoader.h" 48 #include "core/loader/FrameLoader.h"
49 #include "core/loader/FrameLoaderClient.h" 49 #include "core/loader/FrameLoaderClient.h"
50 #include "core/loader/ThreadableLoaderClient.h" 50 #include "core/loader/ThreadableLoaderClient.h"
51 #include "core/page/ChromeClient.h"
52 #include "core/page/Page.h"
51 #include "platform/SharedBuffer.h" 53 #include "platform/SharedBuffer.h"
52 #include "platform/Task.h" 54 #include "platform/Task.h"
53 #include "platform/network/ResourceRequest.h" 55 #include "platform/network/ResourceRequest.h"
54 #include "platform/weborigin/SchemeRegistry.h" 56 #include "platform/weborigin/SchemeRegistry.h"
55 #include "platform/weborigin/SecurityOrigin.h" 57 #include "platform/weborigin/SecurityOrigin.h"
56 #include "public/platform/Platform.h" 58 #include "public/platform/Platform.h"
57 #include "public/platform/WebURLRequest.h" 59 #include "public/platform/WebURLRequest.h"
58 #include "wtf/Assertions.h" 60 #include "wtf/Assertions.h"
59 61
60 namespace blink { 62 namespace blink {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 m_requestStartedSeconds = monotonicallyIncreasingTime(); 157 m_requestStartedSeconds = monotonicallyIncreasingTime();
156 158
157 // Save any CORS simple headers on the request here. If this request redirec ts cross-origin, we cancel the old request 159 // Save any CORS simple headers on the request here. If this request redirec ts cross-origin, we cancel the old request
158 // create a new one, and copy these headers. 160 // create a new one, and copy these headers.
159 const HTTPHeaderMap& headerMap = request.httpHeaderFields(); 161 const HTTPHeaderMap& headerMap = request.httpHeaderFields();
160 for (const auto& header : headerMap) { 162 for (const auto& header : headerMap) {
161 if (FetchUtils::isSimpleHeader(header.key, header.value)) 163 if (FetchUtils::isSimpleHeader(header.key, header.value))
162 m_simpleRequestHeaders.add(header.key, header.value); 164 m_simpleRequestHeaders.add(header.key, header.value);
163 } 165 }
164 166
167 // DocumentThreadableLoader is used by all javascript initiated fetch, so
168 // we use this chance to update PageImportanceSignals.
tkent 2015/09/27 23:40:51 DocumentThreadableLoader should not have knowledge
kouhei (in TOK) 2015/09/28 00:42:44 Thanks for your suggestion. I thought over this ag
169 // However, this is based on the following assumptions, so please be careful
170 // when adding similar logic:
171 // - ThreadableLoader is used as backend for all javascript initiated networ k
172 // fetches.
173 // - Note that ThreadableLoader is also used for non-network fetch such as
174 // FileReaderLoader. However it emulates GET method so signal is not
175 // recorded here.
176 // - ThreadableLoader w/ non-GET request is only created from javascript
177 // initiated fetch.
178 // - Some non-script initiated fetches such as WorkerScriptLoader also use
179 // ThreadableLoader, but they are guaranteed to use GET method.
180 if (request.httpMethod() != "GET") {
tkent 2015/09/27 23:40:52 Is it safe to assume httpMethod() is always upper-
kouhei (in TOK) 2015/09/28 00:42:44 Yes. Follows other use cases: https://code.google.
tkent 2015/09/28 00:48:08 Someone should document it in ResourceRequest.h.
181 if (LocalFrame* frame = m_document.frame()) {
tkent 2015/09/27 23:40:51 m_document.page() is simpler.
kouhei (in TOK) 2015/09/28 00:42:44 Done.
182 if (Page* page = frame->page())
183 page->chromeClient().observedNonGetFetchFromScript();
184 }
185 }
186
165 // If the fetch request will be handled by the ServiceWorker, the 187 // If the fetch request will be handled by the ServiceWorker, the
166 // FetchRequestMode of the request must be FetchRequestModeCORS or 188 // FetchRequestMode of the request must be FetchRequestModeCORS or
167 // FetchRequestModeCORSWithForcedPreflight. Otherwise the ServiceWorker can 189 // FetchRequestModeCORSWithForcedPreflight. Otherwise the ServiceWorker can
168 // return a opaque response which is from the other origin site and the 190 // return a opaque response which is from the other origin site and the
169 // script in the page can read the content. 191 // script in the page can read the content.
170 // 192 //
171 // We assume that ServiceWorker is skipped for sync requests and non-HTTP 193 // We assume that ServiceWorker is skipped for sync requests and non-HTTP
172 // familiy requests by content/ code. 194 // familiy requests by content/ code.
173 if (m_async && !request.skipServiceWorker() && request.url().protocolIsInHTT PFamily() && m_document.fetcher()->isControlledByServiceWorker()) { 195 if (m_async && !request.skipServiceWorker() && request.url().protocolIsInHTT PFamily() && m_document.fetcher()->isControlledByServiceWorker()) {
174 ResourceRequest newRequest(request); 196 ResourceRequest newRequest(request);
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 return DoNotAllowStoredCredentials; 867 return DoNotAllowStoredCredentials;
846 return m_resourceLoaderOptions.allowCredentials; 868 return m_resourceLoaderOptions.allowCredentials;
847 } 869 }
848 870
849 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const 871 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const
850 { 872 {
851 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin (); 873 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin ();
852 } 874 }
853 875
854 } // namespace blink 876 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/page/ChromeClient.h » ('j') | third_party/WebKit/Source/core/page/ChromeClient.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698