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

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

Issue 1846733004: Rename IgnoringCacheData to ValidatingCacheData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 4 years, 8 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
OLDNEW
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 return CachePolicyHistoryBuffer; 160 return CachePolicyHistoryBuffer;
161 return CachePolicyVerify; 161 return CachePolicyVerify;
162 162
163 } 163 }
164 164
165 static ResourceRequestCachePolicy memoryCachePolicyToResourceRequestCachePolicy( 165 static ResourceRequestCachePolicy memoryCachePolicyToResourceRequestCachePolicy(
166 const CachePolicy policy) { 166 const CachePolicy policy) {
167 if (policy == CachePolicyVerify) 167 if (policy == CachePolicyVerify)
168 return UseProtocolCachePolicy; 168 return UseProtocolCachePolicy;
169 if (policy == CachePolicyRevalidate) 169 if (policy == CachePolicyRevalidate)
170 return ReloadIgnoringCacheData; 170 return ValidatingCacheData;
171 if (policy == CachePolicyReload) 171 if (policy == CachePolicyReload)
172 return ReloadBypassingCache; 172 return BypassingCache;
173 if (policy == CachePolicyHistoryBuffer) 173 if (policy == CachePolicyHistoryBuffer)
174 return ReturnCacheDataElseLoad; 174 return ReturnCacheDataElseLoad;
175 return UseProtocolCachePolicy; 175 return UseProtocolCachePolicy;
176 } 176 }
177 177
178 ResourceRequestCachePolicy FrameFetchContext::resourceRequestCachePolicy(const R esourceRequest& request, Resource::Type type) const 178 ResourceRequestCachePolicy FrameFetchContext::resourceRequestCachePolicy(const R esourceRequest& request, Resource::Type type) const
179 { 179 {
180 ASSERT(frame()); 180 ASSERT(frame());
181 if (type == Resource::MainResource) { 181 if (type == Resource::MainResource) {
182 FrameLoadType frameLoadType = frame()->loader().loadType(); 182 FrameLoadType frameLoadType = frame()->loader().loadType();
183 if (request.httpMethod() == "POST" && frameLoadType == FrameLoadTypeBack Forward) 183 if (request.httpMethod() == "POST" && frameLoadType == FrameLoadTypeBack Forward)
184 return ReturnCacheDataDontLoad; 184 return ReturnCacheDataDontLoad;
185 if (!frame()->host()->overrideEncoding().isEmpty()) 185 if (!frame()->host()->overrideEncoding().isEmpty())
186 return ReturnCacheDataElseLoad; 186 return ReturnCacheDataElseLoad;
187 if (frameLoadType == FrameLoadTypeSame || request.isConditional() || req uest.httpMethod() == "POST") 187 if (frameLoadType == FrameLoadTypeSame || request.isConditional() || req uest.httpMethod() == "POST")
188 return ReloadIgnoringCacheData; 188 return ValidatingCacheData;
189 189
190 for (Frame* f = frame(); f; f = f->tree().parent()) { 190 for (Frame* f = frame(); f; f = f->tree().parent()) {
191 if (!f->isLocalFrame()) 191 if (!f->isLocalFrame())
192 continue; 192 continue;
193 frameLoadType = toLocalFrame(f)->loader().loadType(); 193 frameLoadType = toLocalFrame(f)->loader().loadType();
194 if (frameLoadType == FrameLoadTypeBackForward) 194 if (frameLoadType == FrameLoadTypeBackForward)
195 return ReturnCacheDataElseLoad; 195 return ReturnCacheDataElseLoad;
196 if (frameLoadType == FrameLoadTypeReloadFromOrigin) 196 if (frameLoadType == FrameLoadTypeReloadFromOrigin)
197 return ReloadBypassingCache; 197 return BypassingCache;
198 if (frameLoadType == FrameLoadTypeReload) 198 if (frameLoadType == FrameLoadTypeReload)
199 return ReloadIgnoringCacheData; 199 return ValidatingCacheData;
200 } 200 }
201 return UseProtocolCachePolicy; 201 return UseProtocolCachePolicy;
202 } 202 }
203 203
204 // For users on slow connections, we want to avoid blocking the parser in 204 // For users on slow connections, we want to avoid blocking the parser in
205 // the main frame on script loads inserted via document.write, since it can 205 // the main frame on script loads inserted via document.write, since it can
206 // add significant delays before page content is displayed on the screen. 206 // add significant delays before page content is displayed on the screen.
207 // For now, as a prototype, we block fetches for main frame scripts 207 // For now, as a prototype, we block fetches for main frame scripts
208 // inserted via document.write as long as the 208 // inserted via document.write as long as the
209 // disallowFetchForDocWrittenScriptsInMainFrame setting is enabled. In the 209 // disallowFetchForDocWrittenScriptsInMainFrame setting is enabled. In the
210 // future, we'll extend this logic to only block if estimated network RTT 210 // future, we'll extend this logic to only block if estimated network RTT
211 // is above some threshold. 211 // is above some threshold.
212 if (type == Resource::Script && isMainFrame()) { 212 if (type == Resource::Script && isMainFrame()) {
213 const bool isInDocumentWrite = m_document && m_document->isInDocumentWri te(); 213 const bool isInDocumentWrite = m_document && m_document->isInDocumentWri te();
214 const bool disallowFetchForDocWriteScripts = frame()->settings() && fram e()->settings()->disallowFetchForDocWrittenScriptsInMainFrame(); 214 const bool disallowFetchForDocWriteScripts = frame()->settings() && fram e()->settings()->disallowFetchForDocWrittenScriptsInMainFrame();
215 if (isInDocumentWrite && disallowFetchForDocWriteScripts) 215 if (isInDocumentWrite && disallowFetchForDocWriteScripts)
216 return ReturnCacheDataDontLoad; 216 return ReturnCacheDataDontLoad;
217 } 217 }
218 218
219 if (request.isConditional()) 219 if (request.isConditional())
220 return ReloadIgnoringCacheData; 220 return ValidatingCacheData;
221 221
222 if (m_documentLoader && m_document && !m_document->loadEventFinished()) { 222 if (m_documentLoader && m_document && !m_document->loadEventFinished()) {
223 // For POST requests, we mutate the main resource's cache policy to avoi d form resubmission. 223 // For POST requests, we mutate the main resource's cache policy to avoi d form resubmission.
224 // This policy should not be inherited by subresources. 224 // This policy should not be inherited by subresources.
225 ResourceRequestCachePolicy mainResourceCachePolicy = m_documentLoader->r equest().getCachePolicy(); 225 ResourceRequestCachePolicy mainResourceCachePolicy = m_documentLoader->r equest().getCachePolicy();
226 if (m_documentLoader->request().httpMethod() == "POST") { 226 if (m_documentLoader->request().httpMethod() == "POST") {
227 if (mainResourceCachePolicy == ReturnCacheDataDontLoad) 227 if (mainResourceCachePolicy == ReturnCacheDataDontLoad)
228 return ReturnCacheDataElseLoad; 228 return ReturnCacheDataElseLoad;
229 return UseProtocolCachePolicy; 229 return UseProtocolCachePolicy;
230 } 230 }
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 821 }
822 822
823 DEFINE_TRACE(FrameFetchContext) 823 DEFINE_TRACE(FrameFetchContext)
824 { 824 {
825 visitor->trace(m_document); 825 visitor->trace(m_document);
826 visitor->trace(m_documentLoader); 826 visitor->trace(m_documentLoader);
827 FetchContext::trace(visitor); 827 FetchContext::trace(visitor);
828 } 828 }
829 829
830 } // namespace blink 830 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698