Chromium Code Reviews| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 // are likely to be third party content. | 113 // are likely to be third party content. |
| 114 if (request.url().host() == document.getSecurityOrigin()->domain()) | 114 if (request.url().host() == document.getSecurityOrigin()->domain()) |
| 115 return false; | 115 return false; |
| 116 | 116 |
| 117 emitWarningForDocWriteScripts(request.url().getString(), document); | 117 emitWarningForDocWriteScripts(request.url().getString(), document); |
| 118 | 118 |
| 119 // Do not block scripts if it is a page reload. This is to enable pages to | 119 // Do not block scripts if it is a page reload. This is to enable pages to |
| 120 // recover if blocking of a script is leading to a page break and the user | 120 // recover if blocking of a script is leading to a page break and the user |
| 121 // reloads the page. | 121 // reloads the page. |
| 122 const FrameLoadType loadType = document.frame()->loader().loadType(); | 122 const FrameLoadType loadType = document.frame()->loader().loadType(); |
| 123 const bool isReload = loadType == FrameLoadTypeReload || loadType == FrameLo adTypeReloadBypassingCache || loadType == FrameLoadTypeReloadMainResource; | 123 if (isReloadLoadType(loadType)) { |
| 124 if (isReload) { | |
| 125 // Recording this metric since an increase in number of reloads for page s | 124 // Recording this metric since an increase in number of reloads for page s |
| 126 // where a script was blocked could be indicative of a page break. | 125 // where a script was blocked could be indicative of a page break. |
| 127 document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::Web LoadingBehaviorDocumentWriteBlockReload); | 126 document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::Web LoadingBehaviorDocumentWriteBlockReload); |
| 128 return false; | 127 return false; |
| 129 } | 128 } |
| 130 | 129 |
| 131 // Add the metadata that this page has scripts inserted via document.write | 130 // Add the metadata that this page has scripts inserted via document.write |
| 132 // that are eligible for blocking. Note that if there are multiple scripts | 131 // that are eligible for blocking. Note that if there are multiple scripts |
| 133 // the flag will be conveyed to the browser process only once. | 132 // the flag will be conveyed to the browser process only once. |
| 134 document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::WebLoad ingBehaviorDocumentWriteBlock); | 133 document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::WebLoad ingBehaviorDocumentWriteBlock); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 CachePolicy parentCachePolicy = toLocalFrame(parentFrame)->document()->f etcher()->context().getCachePolicy(); | 211 CachePolicy parentCachePolicy = toLocalFrame(parentFrame)->document()->f etcher()->context().getCachePolicy(); |
| 213 if (parentCachePolicy != CachePolicyVerify) | 212 if (parentCachePolicy != CachePolicyVerify) |
| 214 return parentCachePolicy; | 213 return parentCachePolicy; |
| 215 } | 214 } |
| 216 | 215 |
| 217 if (loadType == FrameLoadTypeReload) | 216 if (loadType == FrameLoadTypeReload) |
| 218 return CachePolicyRevalidate; | 217 return CachePolicyRevalidate; |
| 219 | 218 |
| 220 if (m_documentLoader && m_documentLoader->request().getCachePolicy() == WebC achePolicy::ReturnCacheDataElseLoad) | 219 if (m_documentLoader && m_documentLoader->request().getCachePolicy() == WebC achePolicy::ReturnCacheDataElseLoad) |
| 221 return CachePolicyHistoryBuffer; | 220 return CachePolicyHistoryBuffer; |
| 221 | |
| 222 // Returning CachePolicyVerify for FrameLoadTypeReloadMainResource is | |
| 223 // intentional. | |
|
hiroshige
2016/07/26 07:37:17
Not blocking this CL, but do we have any documents
Takashi Toyoshima
2016/07/26 08:14:20
How about public/web/WebFrameLoadType.h?
core/load
| |
| 222 return CachePolicyVerify; | 224 return CachePolicyVerify; |
| 223 } | 225 } |
| 224 | 226 |
| 225 static WebCachePolicy memoryCachePolicyToResourceRequestCachePolicy(const CacheP olicy policy) | 227 static WebCachePolicy memoryCachePolicyToResourceRequestCachePolicy(const CacheP olicy policy) |
| 226 { | 228 { |
| 227 if (policy == CachePolicyVerify) | 229 if (policy == CachePolicyVerify) |
| 228 return WebCachePolicy::UseProtocolCachePolicy; | 230 return WebCachePolicy::UseProtocolCachePolicy; |
| 229 if (policy == CachePolicyRevalidate) | 231 if (policy == CachePolicyRevalidate) |
| 230 return WebCachePolicy::ValidatingCacheData; | 232 return WebCachePolicy::ValidatingCacheData; |
| 231 if (policy == CachePolicyReload) | 233 if (policy == CachePolicyReload) |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 251 if (!f->isLocalFrame()) | 253 if (!f->isLocalFrame()) |
| 252 continue; | 254 continue; |
| 253 frameLoadType = toLocalFrame(f)->loader().loadType(); | 255 frameLoadType = toLocalFrame(f)->loader().loadType(); |
| 254 if (frameLoadType == FrameLoadTypeBackForward) | 256 if (frameLoadType == FrameLoadTypeBackForward) |
| 255 return WebCachePolicy::ReturnCacheDataElseLoad; | 257 return WebCachePolicy::ReturnCacheDataElseLoad; |
| 256 if (frameLoadType == FrameLoadTypeReloadBypassingCache) | 258 if (frameLoadType == FrameLoadTypeReloadBypassingCache) |
| 257 return WebCachePolicy::BypassingCache; | 259 return WebCachePolicy::BypassingCache; |
| 258 if (frameLoadType == FrameLoadTypeReload) | 260 if (frameLoadType == FrameLoadTypeReload) |
| 259 return WebCachePolicy::ValidatingCacheData; | 261 return WebCachePolicy::ValidatingCacheData; |
| 260 } | 262 } |
| 263 // Returning UseProtocolCachePolicy for FrameLoadTypeReloadMainResource | |
| 264 // is intentional. | |
|
hiroshige
2016/07/26 07:37:17
ditto.
| |
| 261 return WebCachePolicy::UseProtocolCachePolicy; | 265 return WebCachePolicy::UseProtocolCachePolicy; |
| 262 } | 266 } |
| 263 | 267 |
| 264 // For users on slow connections, we want to avoid blocking the parser in | 268 // For users on slow connections, we want to avoid blocking the parser in |
| 265 // the main frame on script loads inserted via document.write, since it can | 269 // the main frame on script loads inserted via document.write, since it can |
| 266 // add significant delays before page content is displayed on the screen. | 270 // add significant delays before page content is displayed on the screen. |
| 267 if (type == Resource::Script && isMainFrame() && m_document && shouldDisallo wFetchForMainFrameScript(request, defer, *m_document)) | 271 if (type == Resource::Script && isMainFrame() && m_document && shouldDisallo wFetchForMainFrameScript(request, defer, *m_document)) |
| 268 return WebCachePolicy::ReturnCacheDataDontLoad; | 272 return WebCachePolicy::ReturnCacheDataDontLoad; |
| 269 | 273 |
| 270 if (request.isConditional()) | 274 if (request.isConditional()) |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 809 } | 813 } |
| 810 | 814 |
| 811 DEFINE_TRACE(FrameFetchContext) | 815 DEFINE_TRACE(FrameFetchContext) |
| 812 { | 816 { |
| 813 visitor->trace(m_document); | 817 visitor->trace(m_document); |
| 814 visitor->trace(m_documentLoader); | 818 visitor->trace(m_documentLoader); |
| 815 FetchContext::trace(visitor); | 819 FetchContext::trace(visitor); |
| 816 } | 820 } |
| 817 | 821 |
| 818 } // namespace blink | 822 } // namespace blink |
| OLD | NEW |