| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/loader/async_revalidation_manager.h" | 5 #include "content/browser/loader/async_revalidation_manager.h" |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "content/browser/loader/async_revalidation_driver.h" | 11 #include "content/browser/loader/async_revalidation_driver.h" |
| 12 #include "content/browser/loader/resource_message_filter.h" | 12 #include "content/browser/loader/resource_message_filter.h" |
| 13 #include "content/browser/loader/resource_request_info_impl.h" | 13 #include "content/browser/loader/resource_request_info_impl.h" |
| 14 #include "content/browser/loader/resource_scheduler.h" | 14 #include "content/browser/loader/resource_scheduler.h" |
| 15 #include "content/common/resource_messages.h" | 15 #include "content/common/resource_messages.h" |
| 16 #include "content/common/resource_request.h" |
| 16 #include "content/public/browser/resource_throttle.h" | 17 #include "content/public/browser/resource_throttle.h" |
| 17 #include "net/base/load_flags.h" | 18 #include "net/base/load_flags.h" |
| 18 #include "net/http/http_transaction_factory.h" | 19 #include "net/http/http_transaction_factory.h" |
| 19 #include "net/http/http_util.h" | 20 #include "net/http/http_util.h" |
| 20 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
| 21 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
| 22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // cancelled are contiguous in the map. | 158 // cancelled are contiguous in the map. |
| 158 AsyncRevalidationKey partial_key(resource_context); | 159 AsyncRevalidationKey partial_key(resource_context); |
| 159 for (auto it = in_progress_.lower_bound(partial_key); | 160 for (auto it = in_progress_.lower_bound(partial_key); |
| 160 it != in_progress_.end() && | 161 it != in_progress_.end() && |
| 161 it->first.resource_context == resource_context;) { | 162 it->first.resource_context == resource_context;) { |
| 162 it = in_progress_.erase(it); | 163 it = in_progress_.erase(it); |
| 163 } | 164 } |
| 164 } | 165 } |
| 165 | 166 |
| 166 bool AsyncRevalidationManager::QualifiesForAsyncRevalidation( | 167 bool AsyncRevalidationManager::QualifiesForAsyncRevalidation( |
| 167 const ResourceHostMsg_Request& request) { | 168 const ResourceRequest& request) { |
| 168 if (request.load_flags & | 169 if (request.load_flags & |
| 169 (net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | | 170 (net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | |
| 170 net::LOAD_VALIDATE_CACHE | net::LOAD_PREFERRING_CACHE | | 171 net::LOAD_VALIDATE_CACHE | net::LOAD_PREFERRING_CACHE | |
| 171 net::LOAD_ONLY_FROM_CACHE | net::LOAD_IGNORE_LIMITS | | 172 net::LOAD_ONLY_FROM_CACHE | net::LOAD_IGNORE_LIMITS | |
| 172 net::LOAD_PREFETCH)) { | 173 net::LOAD_PREFETCH)) { |
| 173 return false; | 174 return false; |
| 174 } | 175 } |
| 175 if (request.method != "GET") | 176 if (request.method != "GET") |
| 176 return false; | 177 return false; |
| 177 // A GET request should not have a body. | 178 // A GET request should not have a body. |
| 178 if (request.request_body.get()) | 179 if (request.request_body.get()) |
| 179 return false; | 180 return false; |
| 180 if (!request.url.SchemeIsHTTPOrHTTPS()) | 181 if (!request.url.SchemeIsHTTPOrHTTPS()) |
| 181 return false; | 182 return false; |
| 182 | 183 |
| 183 return true; | 184 return true; |
| 184 } | 185 } |
| 185 | 186 |
| 186 void AsyncRevalidationManager::OnAsyncRevalidationComplete( | 187 void AsyncRevalidationManager::OnAsyncRevalidationComplete( |
| 187 AsyncRevalidationMap::iterator it) { | 188 AsyncRevalidationMap::iterator it) { |
| 188 in_progress_.erase(it); | 189 in_progress_.erase(it); |
| 189 } | 190 } |
| 190 | 191 |
| 191 } // namespace content | 192 } // namespace content |
| OLD | NEW |