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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor.cc

Issue 455623003: stale-while-revalidate experimental implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 2 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
OLDNEW
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if (response->was_cached()) 239 if (response->was_cached())
240 return true; 240 return true;
241 241
242 // For non cached responses, we will ensure that the freshness lifetime is 242 // For non cached responses, we will ensure that the freshness lifetime is
243 // some sane value. 243 // some sane value.
244 const net::HttpResponseInfo& response_info = response->response_info(); 244 const net::HttpResponseInfo& response_info = response->response_info();
245 if (!response_info.headers.get()) 245 if (!response_info.headers.get())
246 return false; 246 return false;
247 base::Time response_time(response_info.response_time); 247 base::Time response_time(response_info.response_time);
248 response_time += base::TimeDelta::FromSeconds(1); 248 response_time += base::TimeDelta::FromSeconds(1);
249 base::TimeDelta freshness = response_info.headers->GetFreshnessLifetime( 249 base::TimeDelta freshness =
250 response_time); 250 response_info.headers->GetFreshnessLifetimes(response_time).fresh;
251 return freshness > base::TimeDelta(); 251 return freshness > base::TimeDelta();
252 } 252 }
253 253
254 // static 254 // static
255 content::ResourceType ResourcePrefetchPredictor::GetResourceTypeFromMimeType( 255 content::ResourceType ResourcePrefetchPredictor::GetResourceTypeFromMimeType(
256 const std::string& mime_type, 256 const std::string& mime_type,
257 content::ResourceType fallback) { 257 content::ResourceType fallback) {
258 if (net::IsSupportedImageMimeType(mime_type.c_str())) 258 if (net::IsSupportedImageMimeType(mime_type.c_str()))
259 return content::RESOURCE_TYPE_IMAGE; 259 return content::RESOURCE_TYPE_IMAGE;
260 else if (net::IsSupportedJavascriptMimeType(mime_type.c_str())) 260 else if (net::IsSupportedJavascriptMimeType(mime_type.c_str()))
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 RPP_PREDICTED_HISTOGRAM_PERCENTAGE( 1213 RPP_PREDICTED_HISTOGRAM_PERCENTAGE(
1214 "PrefetchFromNetworkPercentOfTotalFromNetwork", 1214 "PrefetchFromNetworkPercentOfTotalFromNetwork",
1215 prefetch_network * 100.0 / total_resources_fetched_from_network); 1215 prefetch_network * 100.0 / total_resources_fetched_from_network);
1216 } 1216 }
1217 1217
1218 #undef RPP_PREDICTED_HISTOGRAM_PERCENTAGE 1218 #undef RPP_PREDICTED_HISTOGRAM_PERCENTAGE
1219 #undef RPP_PREDICTED_HISTOGRAM_COUNTS 1219 #undef RPP_PREDICTED_HISTOGRAM_COUNTS
1220 } 1220 }
1221 1221
1222 } // namespace predictors 1222 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698