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

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

Issue 665023002: Post-commit fixes for "stale-while-revalidate..." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 1 month 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
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.cc ('k') | net/http/http_cache_transaction.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = 249 base::TimeDelta freshness =
250 response_info.headers->GetFreshnessLifetimes(response_time).fresh; 250 response_info.headers->GetFreshnessLifetimes(response_time).freshness;
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 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 RPP_PREDICTED_HISTOGRAM_PERCENTAGE( 1215 RPP_PREDICTED_HISTOGRAM_PERCENTAGE(
1216 "PrefetchFromNetworkPercentOfTotalFromNetwork", 1216 "PrefetchFromNetworkPercentOfTotalFromNetwork",
1217 prefetch_network * 100.0 / total_resources_fetched_from_network); 1217 prefetch_network * 100.0 / total_resources_fetched_from_network);
1218 } 1218 }
1219 1219
1220 #undef RPP_PREDICTED_HISTOGRAM_PERCENTAGE 1220 #undef RPP_PREDICTED_HISTOGRAM_PERCENTAGE
1221 #undef RPP_PREDICTED_HISTOGRAM_COUNTS 1221 #undef RPP_PREDICTED_HISTOGRAM_COUNTS
1222 } 1222 }
1223 1223
1224 } // namespace predictors 1224 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.cc ('k') | net/http/http_cache_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698