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

Side by Side Diff: chrome/browser/prerender/prerender_local_predictor.cc

Issue 11412288: Add new stats to local predictor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prerender/prerender_local_predictor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/prerender/prerender_local_predictor.h" 5 #include "chrome/browser/prerender/prerender_local_predictor.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 base::Time GetCurrentTime() { 137 base::Time GetCurrentTime() {
138 return base::Time::Now(); 138 return base::Time::Now();
139 } 139 }
140 140
141 bool StrCaseStr(std::string haystack, std::string needle) { 141 bool StrCaseStr(std::string haystack, std::string needle) {
142 std::transform(haystack.begin(), haystack.end(), haystack.begin(), ::tolower); 142 std::transform(haystack.begin(), haystack.end(), haystack.begin(), ::tolower);
143 std::transform(needle.begin(), needle.end(), needle.begin(), ::tolower); 143 std::transform(needle.begin(), needle.end(), needle.begin(), ::tolower);
144 return haystack.find(needle) != std::string::npos; 144 return haystack.find(needle) != std::string::npos;
145 } 145 }
146 146
147 bool IsExtendedRootURL(const GURL& url) {
148 const std::string& path = url.path();
149 return path == "/index.html" || path == "/home.html" ||
Shishir 2012/12/01 01:33:23 Maybe add this to a static set and lookup.
150 path == "/main.html" ||
151 path == "/index.htm" || path == "/home.htm" || path == "/main.htm" ||
152 path == "/index.php" || path == "/home.php" || path == "/main.php" ||
153 path == "/index.asp" || path == "/home.asp" || path == "/main.asp" ||
154 path == "/index.py" || path == "/home.py" || path == "/main.py" ||
155 path == "/index.pl" || path == "/home.pl" || path == "/main.pl";
156 }
157
147 bool IsRootPageURL(const GURL& url) { 158 bool IsRootPageURL(const GURL& url) {
148 return (url.path() == "/" || url.path() == "") && (!url.has_query()) && 159 return (url.path() == "/" || url.path() == "" || IsExtendedRootURL(url)) &&
149 (!url.has_ref()); 160 (!url.has_query()) && (!url.has_ref());
150 } 161 }
151 162
152 int64 URLHashToInt64(const unsigned char* data) { 163 int64 URLHashToInt64(const unsigned char* data) {
153 COMPILE_ASSERT(kURLHashSize < sizeof(int64), url_hash_must_fit_in_int64); 164 COMPILE_ASSERT(kURLHashSize < sizeof(int64), url_hash_must_fit_in_int64);
154 int64 value = 0; 165 int64 value = 0;
155 memcpy(&value, data, kURLHashSize); 166 memcpy(&value, data, kURLHashSize);
156 return value; 167 return value;
157 } 168 }
158 169
159 int64 GetInt64URLHashForURL(const GURL& url) { 170 int64 GetInt64URLHashForURL(const GURL& url) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 388 }
378 } 389 }
379 390
380 if (url_whitelist_.count(GetInt64URLHashForURL(url)) > 0) { 391 if (url_whitelist_.count(GetInt64URLHashForURL(url)) > 0) {
381 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_ON_WHITELIST); 392 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_ON_WHITELIST);
382 if (IsRootPageURL(url)) 393 if (IsRootPageURL(url))
383 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_ON_WHITELIST_ROOT_PAGE); 394 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_ON_WHITELIST_ROOT_PAGE);
384 } 395 }
385 if (IsRootPageURL(url)) 396 if (IsRootPageURL(url))
386 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_ROOT_PAGE); 397 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_ROOT_PAGE);
398 if (IsExtendedRootURL(url))
399 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_EXTENDED_ROOT_PAGE);
400 if (IsRootPageURL(url) && url.SchemeIs("http"))
401 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_ROOT_PAGE_HTTP);
387 if (url.SchemeIs("http")) 402 if (url.SchemeIs("http"))
388 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_IS_HTTP); 403 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_IS_HTTP);
389 if (url.has_query()) 404 if (url.has_query())
390 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_HAS_QUERY_STRING); 405 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_HAS_QUERY_STRING);
391 if (StrCaseStr(url.spec().c_str(), "logout") || 406 if (StrCaseStr(url.spec().c_str(), "logout") ||
392 StrCaseStr(url.spec().c_str(), "signout")) 407 StrCaseStr(url.spec().c_str(), "signout"))
393 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_CONTAINS_LOGOUT); 408 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_CONTAINS_LOGOUT);
394 if (StrCaseStr(url.spec().c_str(), "login") || 409 if (StrCaseStr(url.spec().c_str(), "login") ||
395 StrCaseStr(url.spec().c_str(), "signin")) 410 StrCaseStr(url.spec().c_str(), "signin"))
396 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_CONTAINS_LOGIN); 411 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT_CONTAINS_LOGIN);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 bool PrerenderLocalPredictor::ShouldReplaceCurrentPrerender( 507 bool PrerenderLocalPredictor::ShouldReplaceCurrentPrerender(
493 double priority) const { 508 double priority) const {
494 base::TimeDelta max_age = 509 base::TimeDelta max_age =
495 base::TimeDelta::FromMilliseconds(kMaxLocalPredictionTimeMs); 510 base::TimeDelta::FromMilliseconds(kMaxLocalPredictionTimeMs);
496 return (!current_prerender_.get()) || 511 return (!current_prerender_.get()) ||
497 current_prerender_->priority < priority || 512 current_prerender_->priority < priority ||
498 current_prerender_->start_time < GetCurrentTime() - max_age; 513 current_prerender_->start_time < GetCurrentTime() - max_age;
499 } 514 }
500 515
501 } // namespace prerender 516 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_local_predictor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698