| 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()); |
| 217 if (isSync && isThirdParty) |
| 218 return ReturnCacheDataDontLoad; |
| 219 } |
| 215 } | 220 } |
| 216 | 221 |
| 217 if (request.isConditional()) | 222 if (request.isConditional()) |
| 218 return ReloadIgnoringCacheData; | 223 return ReloadIgnoringCacheData; |
| 219 | 224 |
| 220 if (m_documentLoader && m_document && !m_document->loadEventFinished()) { | 225 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. | 226 // 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. | 227 // This policy should not be inherited by subresources. |
| 223 ResourceRequestCachePolicy mainResourceCachePolicy = m_documentLoader->r
equest().getCachePolicy(); | 228 ResourceRequestCachePolicy mainResourceCachePolicy = m_documentLoader->r
equest().getCachePolicy(); |
| 224 if (m_documentLoader->request().httpMethod() == "POST") { | 229 if (m_documentLoader->request().httpMethod() == "POST") { |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 } | 811 } |
| 807 | 812 |
| 808 DEFINE_TRACE(FrameFetchContext) | 813 DEFINE_TRACE(FrameFetchContext) |
| 809 { | 814 { |
| 810 visitor->trace(m_document); | 815 visitor->trace(m_document); |
| 811 visitor->trace(m_documentLoader); | 816 visitor->trace(m_documentLoader); |
| 812 FetchContext::trace(visitor); | 817 FetchContext::trace(visitor); |
| 813 } | 818 } |
| 814 | 819 |
| 815 } // namespace blink | 820 } // namespace blink |
| OLD | NEW |