| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 IsConnectionEffectively2G(effective_connection)); | 216 IsConnectionEffectively2G(effective_connection)); |
| 217 } | 217 } |
| 218 | 218 |
| 219 enum class RequestMethod { kIsPost, kIsNotPost }; | 219 enum class RequestMethod { kIsPost, kIsNotPost }; |
| 220 enum class RequestType { kIsConditional, kIsNotConditional }; | 220 enum class RequestType { kIsConditional, kIsNotConditional }; |
| 221 enum class ResourceType { kIsMainResource, kIsNotMainResource }; | 221 enum class ResourceType { kIsMainResource, kIsNotMainResource }; |
| 222 | 222 |
| 223 // Determines WebCachePolicy for a main resource, or WebCachePolicy that is | 223 // Determines WebCachePolicy for a main resource, or WebCachePolicy that is |
| 224 // corresponding to FrameLoadType. | 224 // corresponding to FrameLoadType. |
| 225 // TODO(toyoshim): Probably, we should split FrameLoadType to WebCachePolicy | 225 // TODO(toyoshim): Probably, we should split FrameLoadType to WebCachePolicy |
| 226 // conversion logic into a separate function once other TODOs in this function | 226 // conversion logic into a separate function. |
| 227 // are resolved. | |
| 228 WebCachePolicy DetermineWebCachePolicy(RequestMethod method, | 227 WebCachePolicy DetermineWebCachePolicy(RequestMethod method, |
| 229 RequestType request_type, | 228 RequestType request_type, |
| 230 ResourceType resource_type, | 229 ResourceType resource_type, |
| 231 FrameLoadType load_type) { | 230 FrameLoadType load_type) { |
| 232 switch (load_type) { | 231 switch (load_type) { |
| 233 case kFrameLoadTypeStandard: | 232 case kFrameLoadTypeStandard: |
| 233 case kFrameLoadTypeReplaceCurrentItem: |
| 234 case kFrameLoadTypeInitialInChildFrame: |
| 234 return (request_type == RequestType::kIsConditional || | 235 return (request_type == RequestType::kIsConditional || |
| 235 method == RequestMethod::kIsPost) | 236 method == RequestMethod::kIsPost) |
| 236 ? WebCachePolicy::kValidatingCacheData | 237 ? WebCachePolicy::kValidatingCacheData |
| 237 : WebCachePolicy::kUseProtocolCachePolicy; | 238 : WebCachePolicy::kUseProtocolCachePolicy; |
| 238 case kFrameLoadTypeReplaceCurrentItem: | 239 case kFrameLoadTypeBackForward: |
| 239 case kFrameLoadTypeInitialInChildFrame: | |
| 240 // TODO(toyoshim): Should be the same with FrameLoadTypeStandard, but | |
| 241 // keep legacy logic as is. To be changed in a follow-up patch soon. | |
| 242 return (resource_type == ResourceType::kIsMainResource && | |
| 243 (request_type == RequestType::kIsConditional || | |
| 244 method == RequestMethod::kIsPost)) | |
| 245 ? WebCachePolicy::kValidatingCacheData | |
| 246 : WebCachePolicy::kUseProtocolCachePolicy; | |
| 247 case kFrameLoadTypeInitialHistoryLoad: | 240 case kFrameLoadTypeInitialHistoryLoad: |
| 248 // TODO(toyoshim): Should be the same with FrameLoadTypeBackForward, but | |
| 249 // keep legacy logic as is. To be changed in a follow-up patch soon. | |
| 250 return (resource_type == ResourceType::kIsMainResource && | |
| 251 (request_type == RequestType::kIsConditional || | |
| 252 method == RequestMethod::kIsPost)) | |
| 253 ? WebCachePolicy::kValidatingCacheData | |
| 254 : WebCachePolicy::kUseProtocolCachePolicy; | |
| 255 case kFrameLoadTypeBackForward: | |
| 256 // Mutates the policy for POST requests to avoid form resubmission. | 241 // Mutates the policy for POST requests to avoid form resubmission. |
| 257 return method == RequestMethod::kIsPost | 242 return method == RequestMethod::kIsPost |
| 258 ? WebCachePolicy::kReturnCacheDataDontLoad | 243 ? WebCachePolicy::kReturnCacheDataDontLoad |
| 259 : WebCachePolicy::kReturnCacheDataElseLoad; | 244 : WebCachePolicy::kReturnCacheDataElseLoad; |
| 260 case kFrameLoadTypeReload: | 245 case kFrameLoadTypeReload: |
| 261 return resource_type == ResourceType::kIsMainResource | 246 return resource_type == ResourceType::kIsMainResource |
| 262 ? WebCachePolicy::kValidatingCacheData | 247 ? WebCachePolicy::kValidatingCacheData |
| 263 : WebCachePolicy::kUseProtocolCachePolicy; | 248 : WebCachePolicy::kUseProtocolCachePolicy; |
| 264 case kFrameLoadTypeReloadBypassingCache: | 249 case kFrameLoadTypeReloadBypassingCache: |
| 265 return WebCachePolicy::kBypassingCache; | 250 return WebCachePolicy::kBypassingCache; |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 return GetFrame()->FrameScheduler()->LoadingTaskRunner(); | 1072 return GetFrame()->FrameScheduler()->LoadingTaskRunner(); |
| 1088 } | 1073 } |
| 1089 | 1074 |
| 1090 DEFINE_TRACE(FrameFetchContext) { | 1075 DEFINE_TRACE(FrameFetchContext) { |
| 1091 visitor->Trace(document_); | 1076 visitor->Trace(document_); |
| 1092 visitor->Trace(document_loader_); | 1077 visitor->Trace(document_loader_); |
| 1093 FetchContext::Trace(visitor); | 1078 FetchContext::Trace(visitor); |
| 1094 } | 1079 } |
| 1095 | 1080 |
| 1096 } // namespace blink | 1081 } // namespace blink |
| OLD | NEW |