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

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

Issue 2181093004: FrameFetchContext: add clear comments how FrameLoadTypeReloadMainResource works (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 CachePolicy parentCachePolicy = toLocalFrame(parentFrame)->document()->f etcher()->context().getCachePolicy(); 211 CachePolicy parentCachePolicy = toLocalFrame(parentFrame)->document()->f etcher()->context().getCachePolicy();
212 if (parentCachePolicy != CachePolicyVerify) 212 if (parentCachePolicy != CachePolicyVerify)
213 return parentCachePolicy; 213 return parentCachePolicy;
214 } 214 }
215 215
216 if (loadType == FrameLoadTypeReload) 216 if (loadType == FrameLoadTypeReload)
217 return CachePolicyRevalidate; 217 return CachePolicyRevalidate;
218 218
219 if (m_documentLoader && m_documentLoader->request().getCachePolicy() == WebC achePolicy::ReturnCacheDataElseLoad) 219 if (m_documentLoader && m_documentLoader->request().getCachePolicy() == WebC achePolicy::ReturnCacheDataElseLoad)
220 return CachePolicyHistoryBuffer; 220 return CachePolicyHistoryBuffer;
221
222 // Returns CachePolicyVerify for other cases, mainly FrameLoadTypeStandard
223 // and FrameLoadTypeReloadMainResource. See public/web/WebFrameLoadType.h
224 // to know how these load types work.
221 return CachePolicyVerify; 225 return CachePolicyVerify;
222 } 226 }
223 227
224 static WebCachePolicy memoryCachePolicyToResourceRequestCachePolicy(const CacheP olicy policy) 228 static WebCachePolicy memoryCachePolicyToResourceRequestCachePolicy(const CacheP olicy policy)
225 { 229 {
226 if (policy == CachePolicyVerify) 230 if (policy == CachePolicyVerify)
227 return WebCachePolicy::UseProtocolCachePolicy; 231 return WebCachePolicy::UseProtocolCachePolicy;
228 if (policy == CachePolicyRevalidate) 232 if (policy == CachePolicyRevalidate)
229 return WebCachePolicy::ValidatingCacheData; 233 return WebCachePolicy::ValidatingCacheData;
230 if (policy == CachePolicyReload) 234 if (policy == CachePolicyReload)
(...skipping 11 matching lines...) Expand all
242 if (request.httpMethod() == "POST" && frameLoadType == FrameLoadTypeBack Forward) 246 if (request.httpMethod() == "POST" && frameLoadType == FrameLoadTypeBack Forward)
243 return WebCachePolicy::ReturnCacheDataDontLoad; 247 return WebCachePolicy::ReturnCacheDataDontLoad;
244 if (!frame()->host()->overrideEncoding().isEmpty()) 248 if (!frame()->host()->overrideEncoding().isEmpty())
245 return WebCachePolicy::ReturnCacheDataElseLoad; 249 return WebCachePolicy::ReturnCacheDataElseLoad;
246 if (frameLoadType == FrameLoadTypeReloadMainResource || request.isCondit ional() || request.httpMethod() == "POST") 250 if (frameLoadType == FrameLoadTypeReloadMainResource || request.isCondit ional() || request.httpMethod() == "POST")
247 return WebCachePolicy::ValidatingCacheData; 251 return WebCachePolicy::ValidatingCacheData;
248 252
249 for (Frame* f = frame(); f; f = f->tree().parent()) { 253 for (Frame* f = frame(); f; f = f->tree().parent()) {
250 if (!f->isLocalFrame()) 254 if (!f->isLocalFrame())
251 continue; 255 continue;
252 frameLoadType = toLocalFrame(f)->loader().loadType(); 256 FrameLoadType parentFrameLoadType = toLocalFrame(f)->loader().loadTy pe();
253 if (frameLoadType == FrameLoadTypeBackForward) 257 if (parentFrameLoadType == FrameLoadTypeBackForward)
254 return WebCachePolicy::ReturnCacheDataElseLoad; 258 return WebCachePolicy::ReturnCacheDataElseLoad;
255 if (frameLoadType == FrameLoadTypeReloadBypassingCache) 259 if (parentFrameLoadType == FrameLoadTypeReloadBypassingCache)
256 return WebCachePolicy::BypassingCache; 260 return WebCachePolicy::BypassingCache;
257 if (frameLoadType == FrameLoadTypeReload) 261 if (parentFrameLoadType == FrameLoadTypeReload)
258 return WebCachePolicy::ValidatingCacheData; 262 return WebCachePolicy::ValidatingCacheData;
259 } 263 }
264 // Returns UseProtocolCachePolicy for other cases, parent frames not
265 // having special kinds of FrameLoadType as they are checked inside
266 // the for loop above, or |frameLoadType| being FrameLoadTypeStandard.
267 // See public/web/WebFrameLoadType.h to know how these load types work.
260 return WebCachePolicy::UseProtocolCachePolicy; 268 return WebCachePolicy::UseProtocolCachePolicy;
261 } 269 }
262 270
263 // For users on slow connections, we want to avoid blocking the parser in 271 // For users on slow connections, we want to avoid blocking the parser in
264 // the main frame on script loads inserted via document.write, since it can 272 // the main frame on script loads inserted via document.write, since it can
265 // add significant delays before page content is displayed on the screen. 273 // add significant delays before page content is displayed on the screen.
266 if (type == Resource::Script && isMainFrame() && m_document && shouldDisallo wFetchForMainFrameScript(request, defer, *m_document)) 274 if (type == Resource::Script && isMainFrame() && m_document && shouldDisallo wFetchForMainFrameScript(request, defer, *m_document))
267 return WebCachePolicy::ReturnCacheDataDontLoad; 275 return WebCachePolicy::ReturnCacheDataDontLoad;
268 276
269 if (request.isConditional()) 277 if (request.isConditional())
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 } 820 }
813 821
814 DEFINE_TRACE(FrameFetchContext) 822 DEFINE_TRACE(FrameFetchContext)
815 { 823 {
816 visitor->trace(m_document); 824 visitor->trace(m_document);
817 visitor->trace(m_documentLoader); 825 visitor->trace(m_documentLoader);
818 FetchContext::trace(visitor); 826 FetchContext::trace(visitor);
819 } 827 }
820 828
821 } // namespace blink 829 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698