| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/predictors/resource_prefetch_predictor.h" | 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return actual_resource_type == content::RESOURCE_TYPE_STYLESHEET || | 210 return actual_resource_type == content::RESOURCE_TYPE_STYLESHEET || |
| 211 actual_resource_type == content::RESOURCE_TYPE_SCRIPT || | 211 actual_resource_type == content::RESOURCE_TYPE_SCRIPT || |
| 212 actual_resource_type == content::RESOURCE_TYPE_IMAGE || | 212 actual_resource_type == content::RESOURCE_TYPE_IMAGE || |
| 213 actual_resource_type == content::RESOURCE_TYPE_FONT_RESOURCE; | 213 actual_resource_type == content::RESOURCE_TYPE_FONT_RESOURCE; |
| 214 } | 214 } |
| 215 | 215 |
| 216 // static | 216 // static |
| 217 content::ResourceType ResourcePrefetchPredictor::GetResourceType( | 217 content::ResourceType ResourcePrefetchPredictor::GetResourceType( |
| 218 content::ResourceType resource_type, | 218 content::ResourceType resource_type, |
| 219 const std::string& mime_type) { | 219 const std::string& mime_type) { |
| 220 // Restricts content::RESOURCE_TYPE_{PREFETCH,SUB_RESOURCE} to a small set of | 220 // Restricts content::RESOURCE_TYPE_{PREFETCH,SUB_RESOURCE,XHR} to a small set |
| 221 // mime types, because these resource types don't communicate how the | 221 // of mime types, because these resource types don't communicate how the |
| 222 // resources will be used. | 222 // resources will be used. |
| 223 if (resource_type == content::RESOURCE_TYPE_PREFETCH || | 223 if (resource_type == content::RESOURCE_TYPE_PREFETCH || |
| 224 resource_type == content::RESOURCE_TYPE_SUB_RESOURCE) { | 224 resource_type == content::RESOURCE_TYPE_SUB_RESOURCE || |
| 225 resource_type == content::RESOURCE_TYPE_XHR) { |
| 225 return GetResourceTypeFromMimeType(mime_type, | 226 return GetResourceTypeFromMimeType(mime_type, |
| 226 content::RESOURCE_TYPE_LAST_TYPE); | 227 content::RESOURCE_TYPE_LAST_TYPE); |
| 227 } | 228 } |
| 228 return resource_type; | 229 return resource_type; |
| 229 } | 230 } |
| 230 | 231 |
| 231 // static | 232 // static |
| 232 bool ResourcePrefetchPredictor::IsNoStore(const net::URLRequest* response) { | 233 bool ResourcePrefetchPredictor::IsNoStore(const net::URLRequest* response) { |
| 233 if (response->was_cached()) | 234 if (response->was_cached()) |
| 234 return false; | 235 return false; |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 TestObserver::~TestObserver() { | 1157 TestObserver::~TestObserver() { |
| 1157 predictor_->SetObserverForTesting(nullptr); | 1158 predictor_->SetObserverForTesting(nullptr); |
| 1158 } | 1159 } |
| 1159 | 1160 |
| 1160 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) | 1161 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) |
| 1161 : predictor_(predictor) { | 1162 : predictor_(predictor) { |
| 1162 predictor_->SetObserverForTesting(this); | 1163 predictor_->SetObserverForTesting(this); |
| 1163 } | 1164 } |
| 1164 | 1165 |
| 1165 } // namespace predictors | 1166 } // namespace predictors |
| OLD | NEW |