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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 #include "core/inspector/InstrumentingAgents.h" | 49 #include "core/inspector/InstrumentingAgents.h" |
50 #include "core/loader/DocumentLoader.h" | 50 #include "core/loader/DocumentLoader.h" |
51 #include "core/loader/FrameLoader.h" | 51 #include "core/loader/FrameLoader.h" |
52 #include "core/loader/FrameLoaderClient.h" | 52 #include "core/loader/FrameLoaderClient.h" |
53 #include "core/loader/LinkLoader.h" | 53 #include "core/loader/LinkLoader.h" |
54 #include "core/loader/MixedContentChecker.h" | 54 #include "core/loader/MixedContentChecker.h" |
55 #include "core/loader/NetworkHintsInterface.h" | 55 #include "core/loader/NetworkHintsInterface.h" |
56 #include "core/loader/PingLoader.h" | 56 #include "core/loader/PingLoader.h" |
57 #include "core/loader/ProgressTracker.h" | 57 #include "core/loader/ProgressTracker.h" |
58 #include "core/loader/appcache/ApplicationCacheHost.h" | 58 #include "core/loader/appcache/ApplicationCacheHost.h" |
59 #include "core/page/NetworkStateNotifier.h" | |
59 #include "core/page/Page.h" | 60 #include "core/page/Page.h" |
60 #include "core/svg/graphics/SVGImageChromeClient.h" | 61 #include "core/svg/graphics/SVGImageChromeClient.h" |
61 #include "core/timing/DOMWindowPerformance.h" | 62 #include "core/timing/DOMWindowPerformance.h" |
62 #include "core/timing/Performance.h" | 63 #include "core/timing/Performance.h" |
63 #include "platform/Logging.h" | 64 #include "platform/Logging.h" |
64 #include "platform/mhtml/MHTMLArchive.h" | 65 #include "platform/mhtml/MHTMLArchive.h" |
65 #include "platform/network/ResourceTimingInfo.h" | 66 #include "platform/network/ResourceTimingInfo.h" |
66 #include "platform/weborigin/SchemeRegistry.h" | 67 #include "platform/weborigin/SchemeRegistry.h" |
67 #include "platform/weborigin/SecurityPolicy.h" | 68 #include "platform/weborigin/SecurityPolicy.h" |
68 #include "public/platform/WebFrameScheduler.h" | 69 #include "public/platform/WebFrameScheduler.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 return UseProtocolCachePolicy; | 167 return UseProtocolCachePolicy; |
167 if (policy == CachePolicyRevalidate) | 168 if (policy == CachePolicyRevalidate) |
168 return ReloadIgnoringCacheData; | 169 return ReloadIgnoringCacheData; |
169 if (policy == CachePolicyReload) | 170 if (policy == CachePolicyReload) |
170 return ReloadBypassingCache; | 171 return ReloadBypassingCache; |
171 if (policy == CachePolicyHistoryBuffer) | 172 if (policy == CachePolicyHistoryBuffer) |
172 return ReturnCacheDataElseLoad; | 173 return ReturnCacheDataElseLoad; |
173 return UseProtocolCachePolicy; | 174 return UseProtocolCachePolicy; |
174 } | 175 } |
175 | 176 |
176 ResourceRequestCachePolicy FrameFetchContext::resourceRequestCachePolicy(const R esourceRequest& request, Resource::Type type) const | 177 ResourceRequestCachePolicy FrameFetchContext::resourceRequestCachePolicy(const R esourceRequest& request, Resource::Type type, FetchRequest::DeferOption defer) c onst |
177 { | 178 { |
178 ASSERT(frame()); | 179 ASSERT(frame()); |
179 if (type == Resource::MainResource) { | 180 if (type == Resource::MainResource) { |
180 FrameLoadType frameLoadType = frame()->loader().loadType(); | 181 FrameLoadType frameLoadType = frame()->loader().loadType(); |
181 if (request.httpMethod() == "POST" && frameLoadType == FrameLoadTypeBack Forward) | 182 if (request.httpMethod() == "POST" && frameLoadType == FrameLoadTypeBack Forward) |
182 return ReturnCacheDataDontLoad; | 183 return ReturnCacheDataDontLoad; |
183 if (!frame()->host()->overrideEncoding().isEmpty()) | 184 if (!frame()->host()->overrideEncoding().isEmpty()) |
184 return ReturnCacheDataElseLoad; | 185 return ReturnCacheDataElseLoad; |
185 if (frameLoadType == FrameLoadTypeSame || request.isConditional() || req uest.httpMethod() == "POST") | 186 if (frameLoadType == FrameLoadTypeSame || request.isConditional() || req uest.httpMethod() == "POST") |
186 return ReloadIgnoringCacheData; | 187 return ReloadIgnoringCacheData; |
(...skipping 14 matching lines...) Expand all Loading... | |
201 | 202 |
202 // For users on slow connections, we want to avoid blocking the parser in | 203 // For users on slow connections, we want to avoid blocking the parser in |
203 // the main frame on script loads inserted via document.write, since it can | 204 // the main frame on script loads inserted via document.write, since it can |
204 // add significant delays before page content is displayed on the screen. | 205 // add significant delays before page content is displayed on the screen. |
205 // For now, as a prototype, we block fetches for main frame scripts | 206 // For now, as a prototype, we block fetches for main frame scripts |
206 // inserted via document.write as long as the | 207 // inserted via document.write as long as the |
207 // disallowFetchForDocWrittenScriptsInMainFrame setting is enabled. In the | 208 // disallowFetchForDocWrittenScriptsInMainFrame setting is enabled. In the |
208 // future, we'll extend this logic to only block if estimated network RTT | 209 // future, we'll extend this logic to only block if estimated network RTT |
209 // is above some threshold. | 210 // is above some threshold. |
210 if (type == Resource::Script && isMainFrame()) { | 211 if (type == Resource::Script && isMainFrame()) { |
212 const bool disallowFetchForDocWriteScripts = frame()->settings() && fram e()->settings()->disallowFetchForDocWrittenScriptsInMainFrame(); | |
211 const bool isInDocumentWrite = m_document && m_document->isInDocumentWri te(); | 213 const bool isInDocumentWrite = m_document && m_document->isInDocumentWri te(); |
212 const bool disallowFetchForDocWriteScripts = frame()->settings() && fram e()->settings()->disallowFetchForDocWrittenScriptsInMainFrame(); | 214 if (isInDocumentWrite && disallowFetchForDocWriteScripts) { |
213 if (isInDocumentWrite && disallowFetchForDocWriteScripts) | 215 const bool isSync = (defer == FetchRequest::NoDefer); |
214 return ReturnCacheDataDontLoad; | 216 const bool isThirdParty = (request.url().host() != m_document->getSe curityOrigin()->domain()); |
Bryan McQuade
2016/04/05 12:46:11
let's add a comment here noting that we continue t
| |
217 const bool isSlowConnection = networkStateNotifier().connectionType( ) == WebConnectionTypeCellular2G; | |
Bryan McQuade
2016/04/05 12:46:11
Let's add a comment that for now we restrict slow
| |
218 if (isSync && isThirdParty && isSlowConnection) | |
219 return ReturnCacheDataDontLoad; | |
220 } | |
215 } | 221 } |
216 | 222 |
217 if (request.isConditional()) | 223 if (request.isConditional()) |
218 return ReloadIgnoringCacheData; | 224 return ReloadIgnoringCacheData; |
219 | 225 |
220 if (m_documentLoader && m_document && !m_document->loadEventFinished()) { | 226 if (m_documentLoader && m_document && !m_document->loadEventFinished()) { |
221 // For POST requests, we mutate the main resource's cache policy to avoi d form resubmission. | 227 // For POST requests, we mutate the main resource's cache policy to avoi d form resubmission. |
222 // This policy should not be inherited by subresources. | 228 // This policy should not be inherited by subresources. |
223 ResourceRequestCachePolicy mainResourceCachePolicy = m_documentLoader->r equest().getCachePolicy(); | 229 ResourceRequestCachePolicy mainResourceCachePolicy = m_documentLoader->r equest().getCachePolicy(); |
224 if (m_documentLoader->request().httpMethod() == "POST") { | 230 if (m_documentLoader->request().httpMethod() == "POST") { |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 } | 812 } |
807 | 813 |
808 DEFINE_TRACE(FrameFetchContext) | 814 DEFINE_TRACE(FrameFetchContext) |
809 { | 815 { |
810 visitor->trace(m_document); | 816 visitor->trace(m_document); |
811 visitor->trace(m_documentLoader); | 817 visitor->trace(m_documentLoader); |
812 FetchContext::trace(visitor); | 818 FetchContext::trace(visitor); |
813 } | 819 } |
814 | 820 |
815 } // namespace blink | 821 } // namespace blink |
OLD | NEW |