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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 return true; | 280 return true; |
281 | 281 |
282 // For non cached responses, we will ensure that the freshness lifetime is | 282 // For non cached responses, we will ensure that the freshness lifetime is |
283 // some sane value. | 283 // some sane value. |
284 const net::HttpResponseInfo& response_info = response->response_info(); | 284 const net::HttpResponseInfo& response_info = response->response_info(); |
285 if (!response_info.headers.get()) | 285 if (!response_info.headers.get()) |
286 return false; | 286 return false; |
287 base::Time response_time(response_info.response_time); | 287 base::Time response_time(response_info.response_time); |
288 response_time += base::TimeDelta::FromSeconds(1); | 288 response_time += base::TimeDelta::FromSeconds(1); |
289 base::TimeDelta freshness = | 289 base::TimeDelta freshness = |
290 response_info.headers->GetFreshnessLifetimes(response_time).freshness; | 290 response_info.headers->GetExpirationTimes(response_info.request_time, |
| 291 response_time) |
| 292 .freshness_lifetime; |
291 return freshness > base::TimeDelta(); | 293 return freshness > base::TimeDelta(); |
292 } | 294 } |
293 | 295 |
294 // static | 296 // static |
295 content::ResourceType ResourcePrefetchPredictor::GetResourceTypeFromMimeType( | 297 content::ResourceType ResourcePrefetchPredictor::GetResourceTypeFromMimeType( |
296 const std::string& mime_type, | 298 const std::string& mime_type, |
297 content::ResourceType fallback) { | 299 content::ResourceType fallback) { |
298 if (mime_util::IsSupportedImageMimeType(mime_type)) | 300 if (mime_util::IsSupportedImageMimeType(mime_type)) |
299 return content::RESOURCE_TYPE_IMAGE; | 301 return content::RESOURCE_TYPE_IMAGE; |
300 else if (mime_util::IsSupportedJavascriptMimeType(mime_type)) | 302 else if (mime_util::IsSupportedJavascriptMimeType(mime_type)) |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 // HistoryService is already loaded. Continue with Initialization. | 1336 // HistoryService is already loaded. Continue with Initialization. |
1335 OnHistoryAndCacheLoaded(); | 1337 OnHistoryAndCacheLoaded(); |
1336 return; | 1338 return; |
1337 } | 1339 } |
1338 DCHECK(!history_service_observer_.IsObserving(history_service)); | 1340 DCHECK(!history_service_observer_.IsObserving(history_service)); |
1339 history_service_observer_.Add(history_service); | 1341 history_service_observer_.Add(history_service); |
1340 return; | 1342 return; |
1341 } | 1343 } |
1342 | 1344 |
1343 } // namespace predictors | 1345 } // namespace predictors |
OLD | NEW |