OLD | NEW |
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 using std::vector; | 63 using std::vector; |
64 | 64 |
65 namespace prerender { | 65 namespace prerender { |
66 | 66 |
67 namespace { | 67 namespace { |
68 | 68 |
69 static const size_t kURLHashSize = 5; | 69 static const size_t kURLHashSize = 5; |
70 static const int kNumPrerenderCandidates = 5; | 70 static const int kNumPrerenderCandidates = 5; |
71 static const int kInvalidProcessId = -1; | 71 static const int kInvalidProcessId = -1; |
72 static const int kInvalidFrameId = -1; | 72 static const int kInvalidFrameId = -1; |
| 73 static const int kMaxPrefetchItems = 100; |
73 | 74 |
74 } // namespace | 75 } // namespace |
75 | 76 |
76 // When considering a candidate URL to be prerendered, we need to collect the | 77 // When considering a candidate URL to be prerendered, we need to collect the |
77 // data in this struct to make the determination whether we should issue the | 78 // data in this struct to make the determination whether we should issue the |
78 // prerender or not. | 79 // prerender or not. |
79 struct PrerenderLocalPredictor::LocalPredictorURLInfo { | 80 struct PrerenderLocalPredictor::LocalPredictorURLInfo { |
80 URLID id; | 81 URLID id; |
81 GURL url; | 82 GURL url; |
82 bool url_lookup_success; | 83 bool url_lookup_success; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 // time after the actual prerender being kept around. | 392 // time after the actual prerender being kept around. |
392 base::Time start_time; | 393 base::Time start_time; |
393 // The actual time this page was last requested for prerendering. | 394 // The actual time this page was last requested for prerendering. |
394 base::Time actual_start_time; | 395 base::Time actual_start_time; |
395 scoped_ptr<PrerenderHandle> prerender_handle; | 396 scoped_ptr<PrerenderHandle> prerender_handle; |
396 // Indicates whether this prerender would have matched a URL navigated to, | 397 // Indicates whether this prerender would have matched a URL navigated to, |
397 // but was not swapped in for some reason. | 398 // but was not swapped in for some reason. |
398 bool would_have_matched; | 399 bool would_have_matched; |
399 }; | 400 }; |
400 | 401 |
| 402 // A class simulating a set of URLs prefetched, for statistical purposes. |
| 403 class PrerenderLocalPredictor::PrefetchList { |
| 404 public: |
| 405 enum SeenType { |
| 406 SEEN_TABCONTENTS_OBSERVER, |
| 407 SEEN_HISTORY, |
| 408 SEEN_MAX_VALUE |
| 409 }; |
| 410 |
| 411 PrefetchList() {} |
| 412 ~PrefetchList() { |
| 413 STLDeleteValues(&entries_); |
| 414 } |
| 415 |
| 416 // Adds a new URL being prefetched. If the URL is already in the list, |
| 417 // nothing will happen. Returns whether a new prefetch was added. |
| 418 bool AddURL(const GURL& url) { |
| 419 ExpireOldItems(); |
| 420 string url_string = url.spec().c_str(); |
| 421 base::hash_map<string, ListEntry*>::iterator it = entries_.find(url_string); |
| 422 if (it != entries_.end()) { |
| 423 // If a prefetch previously existed, and has not been seen yet in either |
| 424 // a tab contents or a history, we will not re-issue it. Otherwise, if it |
| 425 // may have been consumed by either tab contents or history, we will |
| 426 // permit re-issuing another one. |
| 427 if (!it->second->seen_history_ && |
| 428 !it->second->seen_tabcontents_) { |
| 429 return false; |
| 430 } |
| 431 } |
| 432 ListEntry* entry = new ListEntry(url_string); |
| 433 entries_[entry->url_] = entry; |
| 434 entry_list_.push_back(entry); |
| 435 ExpireOldItems(); |
| 436 return true; |
| 437 } |
| 438 |
| 439 // Marks the URL provided as seen in the context specified. Returns true |
| 440 // iff the item is currently in the list and had not been seen before in |
| 441 // the context specified, i.e. the marking was successful. |
| 442 bool MarkURLSeen(const GURL& url, SeenType type) { |
| 443 ExpireOldItems(); |
| 444 bool return_value = false; |
| 445 base::hash_map<string, ListEntry*>::iterator it = |
| 446 entries_.find(url.spec().c_str()); |
| 447 if (it == entries_.end()) |
| 448 return return_value; |
| 449 if (type == SEEN_TABCONTENTS_OBSERVER && !it->second->seen_tabcontents_) { |
| 450 it->second->seen_tabcontents_ = true; |
| 451 return_value = true; |
| 452 } |
| 453 if (type == SEEN_HISTORY && !it->second->seen_history_) { |
| 454 it->second->seen_history_ = true; |
| 455 return_value = true; |
| 456 } |
| 457 // If the item has been seen in both the history and in tab contents, |
| 458 // erase it from the map to make room for new prefetches. |
| 459 if (it->second->seen_tabcontents_ && it->second->seen_history_) |
| 460 entries_.erase(url.spec().c_str()); |
| 461 return return_value; |
| 462 } |
| 463 |
| 464 private: |
| 465 struct ListEntry { |
| 466 explicit ListEntry(const string& url) |
| 467 : url_(url), |
| 468 add_time_(GetCurrentTime()), |
| 469 seen_tabcontents_(false), |
| 470 seen_history_(false) { |
| 471 } |
| 472 std::string url_; |
| 473 base::Time add_time_; |
| 474 bool seen_tabcontents_; |
| 475 bool seen_history_; |
| 476 }; |
| 477 |
| 478 void ExpireOldItems() { |
| 479 base::Time expiry_cutoff = GetCurrentTime() - |
| 480 base::TimeDelta::FromSeconds(GetPrerenderPrefetchListTimeoutSeconds()); |
| 481 while (!entry_list_.empty() && |
| 482 (entry_list_.front()->add_time_ < expiry_cutoff || |
| 483 entries_.size() > kMaxPrefetchItems)) { |
| 484 ListEntry* entry = entry_list_.front(); |
| 485 entry_list_.pop_front(); |
| 486 // If the entry to be deleted is still the one active in entries_, |
| 487 // we must erase it from entries_. |
| 488 base::hash_map<string, ListEntry*>::iterator it = |
| 489 entries_.find(entry->url_); |
| 490 if (it != entries_.end() && it->second == entry) |
| 491 entries_.erase(entry->url_); |
| 492 delete entry; |
| 493 } |
| 494 } |
| 495 |
| 496 base::hash_map<string, ListEntry*> entries_; |
| 497 std::list<ListEntry*> entry_list_; |
| 498 DISALLOW_COPY_AND_ASSIGN(PrefetchList); |
| 499 }; |
| 500 |
401 PrerenderLocalPredictor::PrerenderLocalPredictor( | 501 PrerenderLocalPredictor::PrerenderLocalPredictor( |
402 PrerenderManager* prerender_manager) | 502 PrerenderManager* prerender_manager) |
403 : prerender_manager_(prerender_manager), | 503 : prerender_manager_(prerender_manager), |
404 is_visit_database_observer_(false), | 504 is_visit_database_observer_(false), |
405 weak_factory_(this) { | 505 weak_factory_(this), |
| 506 prefetch_list_(new PrefetchList()) { |
406 RecordEvent(EVENT_CONSTRUCTED); | 507 RecordEvent(EVENT_CONSTRUCTED); |
407 if (base::MessageLoop::current()) { | 508 if (base::MessageLoop::current()) { |
408 timer_.Start(FROM_HERE, | 509 timer_.Start(FROM_HERE, |
409 base::TimeDelta::FromMilliseconds(kInitDelayMs), | 510 base::TimeDelta::FromMilliseconds(kInitDelayMs), |
410 this, | 511 this, |
411 &PrerenderLocalPredictor::Init); | 512 &PrerenderLocalPredictor::Init); |
412 RecordEvent(EVENT_INIT_SCHEDULED); | 513 RecordEvent(EVENT_INIT_SCHEDULED); |
413 } | 514 } |
414 | 515 |
415 static const size_t kChecksumHashSize = 32; | 516 static const size_t kChecksumHashSize = 32; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 scoped_ptr<CandidatePrerenderInfo> info) { | 670 scoped_ptr<CandidatePrerenderInfo> info) { |
570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 671 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
571 | 672 |
572 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT); | 673 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT); |
573 | 674 |
574 if (!info->source_url_.url_lookup_success) { | 675 if (!info->source_url_.url_lookup_success) { |
575 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_FAILED); | 676 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_FAILED); |
576 return; | 677 return; |
577 } | 678 } |
578 | 679 |
| 680 if (prefetch_list_->MarkURLSeen(info->source_url_.url, |
| 681 PrefetchList::SEEN_HISTORY)) { |
| 682 RecordEvent(EVENT_PREFETCH_LIST_SEEN_HISTORY); |
| 683 } |
| 684 |
579 if (info->candidate_urls_.size() > 0 && | 685 if (info->candidate_urls_.size() > 0 && |
580 info->candidate_urls_[0].url_lookup_success) { | 686 info->candidate_urls_[0].url_lookup_success) { |
581 LogCandidateURLStats(info->candidate_urls_[0].url); | 687 LogCandidateURLStats(info->candidate_urls_[0].url); |
582 } | 688 } |
583 | 689 |
584 WebContents* source_web_contents = NULL; | 690 WebContents* source_web_contents = NULL; |
585 bool multiple_source_web_contents_candidates = false; | 691 bool multiple_source_web_contents_candidates = false; |
586 | 692 |
587 #if !defined(OS_ANDROID) | 693 #if !defined(OS_ANDROID) |
588 // We need to figure out what tab launched the prerender. We do this by | 694 // We need to figure out what tab launched the prerender. We do this by |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_STARTED); | 1224 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_STARTED); |
1119 if (info->candidate_urls_.size() == 0) { | 1225 if (info->candidate_urls_.size() == 0) { |
1120 RecordEvent(EVENT_NO_PRERENDER_CANDIDATES); | 1226 RecordEvent(EVENT_NO_PRERENDER_CANDIDATES); |
1121 return; | 1227 return; |
1122 } | 1228 } |
1123 scoped_ptr<LocalPredictorURLInfo> url_info; | 1229 scoped_ptr<LocalPredictorURLInfo> url_info; |
1124 #if defined(FULL_SAFE_BROWSING) | 1230 #if defined(FULL_SAFE_BROWSING) |
1125 scoped_refptr<SafeBrowsingDatabaseManager> sb_db_manager = | 1231 scoped_refptr<SafeBrowsingDatabaseManager> sb_db_manager = |
1126 g_browser_process->safe_browsing_service()->database_manager(); | 1232 g_browser_process->safe_browsing_service()->database_manager(); |
1127 #endif | 1233 #endif |
1128 PrerenderProperties* prerender_properties = NULL; | |
1129 int num_issued = 0; | 1234 int num_issued = 0; |
1130 for (int i = 0; i < static_cast<int>(info->candidate_urls_.size()); i++) { | 1235 for (int i = 0; i < static_cast<int>(info->candidate_urls_.size()); i++) { |
1131 if (num_issued > GetLocalPredictorMaxLaunchPrerenders()) | 1236 if (num_issued >= GetLocalPredictorMaxLaunchPrerenders()) |
1132 return; | 1237 return; |
1133 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL); | 1238 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL); |
1134 url_info.reset(new LocalPredictorURLInfo(info->candidate_urls_[i])); | 1239 url_info.reset(new LocalPredictorURLInfo(info->candidate_urls_[i])); |
1135 if (url_info->local_history_based) { | 1240 if (url_info->local_history_based) { |
1136 if (SkipLocalPredictorLocalCandidates()) { | 1241 if (SkipLocalPredictorLocalCandidates()) { |
1137 url_info.reset(NULL); | 1242 url_info.reset(NULL); |
1138 continue; | 1243 continue; |
1139 } | 1244 } |
1140 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL_LOCAL); | 1245 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL_LOCAL); |
1141 } | 1246 } |
(...skipping 13 matching lines...) Expand all Loading... |
1155 // be prerendered, and we continue, which means try the next candidate | 1260 // be prerendered, and we continue, which means try the next candidate |
1156 // URL), or it can be sufficient to issue the prerender without any | 1261 // URL), or it can be sufficient to issue the prerender without any |
1157 // further checks (in which case we just break). | 1262 // further checks (in which case we just break). |
1158 // The order of the checks is critical, because it prescribes the logic | 1263 // The order of the checks is critical, because it prescribes the logic |
1159 // we use here to decide what to prerender. | 1264 // we use here to decide what to prerender. |
1160 if (!url_info->url_lookup_success) { | 1265 if (!url_info->url_lookup_success) { |
1161 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_NO_URL); | 1266 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_NO_URL); |
1162 url_info.reset(NULL); | 1267 url_info.reset(NULL); |
1163 continue; | 1268 continue; |
1164 } | 1269 } |
1165 prerender_properties = | |
1166 GetIssuedPrerenderSlotForPriority(url_info->url, url_info->priority); | |
1167 if (!prerender_properties) { | |
1168 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_PRIORITY_TOO_LOW); | |
1169 url_info.reset(NULL); | |
1170 continue; | |
1171 } | |
1172 if (!SkipLocalPredictorFragment() && | 1270 if (!SkipLocalPredictorFragment() && |
1173 URLsIdenticalIgnoringFragments(info->source_url_.url, | 1271 URLsIdenticalIgnoringFragments(info->source_url_.url, |
1174 url_info->url)) { | 1272 url_info->url)) { |
1175 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_URLS_IDENTICAL_BUT_FRAGMENT); | 1273 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_URLS_IDENTICAL_BUT_FRAGMENT); |
1176 url_info.reset(NULL); | 1274 url_info.reset(NULL); |
1177 continue; | 1275 continue; |
1178 } | 1276 } |
1179 if (!SkipLocalPredictorHTTPS() && url_info->url.SchemeIs("https")) { | 1277 if (!SkipLocalPredictorHTTPS() && url_info->url.SchemeIs("https")) { |
1180 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_HTTPS); | 1278 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_HTTPS); |
1181 url_info.reset(NULL); | 1279 url_info.reset(NULL); |
1182 continue; | 1280 continue; |
1183 } | 1281 } |
1184 if (IsRootPageURL(url_info->url)) { | 1282 if (IsRootPageURL(url_info->url)) { |
1185 // For root pages, we assume that they are reasonably safe, and we | 1283 // For root pages, we assume that they are reasonably safe, and we |
1186 // will just prerender them without any additional checks. | 1284 // will just prerender them without any additional checks. |
1187 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_ROOT_PAGE); | 1285 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_ROOT_PAGE); |
1188 IssuePrerender(info.get(), url_info.get(), prerender_properties); | 1286 IssuePrerender(info.get(), url_info.get()); |
1189 num_issued++; | 1287 num_issued++; |
1190 continue; | 1288 continue; |
1191 } | 1289 } |
1192 if (IsLogOutURL(url_info->url)) { | 1290 if (IsLogOutURL(url_info->url)) { |
1193 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_LOGOUT_URL); | 1291 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_LOGOUT_URL); |
1194 url_info.reset(NULL); | 1292 url_info.reset(NULL); |
1195 continue; | 1293 continue; |
1196 } | 1294 } |
1197 if (IsLogInURL(url_info->url)) { | 1295 if (IsLogInURL(url_info->url)) { |
1198 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_LOGIN_URL); | 1296 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_LOGIN_URL); |
1199 url_info.reset(NULL); | 1297 url_info.reset(NULL); |
1200 continue; | 1298 continue; |
1201 } | 1299 } |
1202 #if defined(FULL_SAFE_BROWSING) | 1300 #if defined(FULL_SAFE_BROWSING) |
1203 if (!SkipLocalPredictorWhitelist() && sb_db_manager && | 1301 if (!SkipLocalPredictorWhitelist() && sb_db_manager && |
1204 sb_db_manager->CheckSideEffectFreeWhitelistUrl(url_info->url)) { | 1302 sb_db_manager->CheckSideEffectFreeWhitelistUrl(url_info->url)) { |
1205 // If a page is on the side-effect free whitelist, we will just prerender | 1303 // If a page is on the side-effect free whitelist, we will just prerender |
1206 // it without any additional checks. | 1304 // it without any additional checks. |
1207 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_ON_SIDE_EFFECT_FREE_WHITELIST); | 1305 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_ON_SIDE_EFFECT_FREE_WHITELIST); |
1208 IssuePrerender(info.get(), url_info.get(), prerender_properties); | 1306 IssuePrerender(info.get(), url_info.get()); |
1209 num_issued++; | 1307 num_issued++; |
1210 continue; | 1308 continue; |
1211 } | 1309 } |
1212 #endif | 1310 #endif |
1213 if (!SkipLocalPredictorServiceWhitelist() && | 1311 if (!SkipLocalPredictorServiceWhitelist() && |
1214 url_info->service_whitelist && url_info->service_whitelist_lookup_ok) { | 1312 url_info->service_whitelist && url_info->service_whitelist_lookup_ok) { |
1215 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_ON_SERVICE_WHITELIST); | 1313 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_ON_SERVICE_WHITELIST); |
1216 IssuePrerender(info.get(), url_info.get(), prerender_properties); | 1314 IssuePrerender(info.get(), url_info.get()); |
1217 num_issued++; | 1315 num_issued++; |
1218 continue; | 1316 continue; |
1219 } | 1317 } |
1220 if (!SkipLocalPredictorLoggedIn() && | 1318 if (!SkipLocalPredictorLoggedIn() && |
1221 !url_info->logged_in && url_info->logged_in_lookup_ok) { | 1319 !url_info->logged_in && url_info->logged_in_lookup_ok) { |
1222 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_NOT_LOGGED_IN); | 1320 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_NOT_LOGGED_IN); |
1223 IssuePrerender(info.get(), url_info.get(), prerender_properties); | 1321 IssuePrerender(info.get(), url_info.get()); |
1224 num_issued++; | 1322 num_issued++; |
1225 continue; | 1323 continue; |
1226 } | 1324 } |
1227 if (!SkipLocalPredictorDefaultNoPrerender()) { | 1325 if (!SkipLocalPredictorDefaultNoPrerender()) { |
1228 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_FALLTHROUGH_NOT_PRERENDERING); | 1326 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_FALLTHROUGH_NOT_PRERENDERING); |
1229 url_info.reset(NULL); | 1327 url_info.reset(NULL); |
1230 } else { | 1328 } else { |
1231 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_FALLTHROUGH_PRERENDERING); | 1329 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_FALLTHROUGH_PRERENDERING); |
1232 IssuePrerender(info.get(), url_info.get(), prerender_properties); | 1330 IssuePrerender(info.get(), url_info.get()); |
1233 num_issued++; | 1331 num_issued++; |
1234 continue; | 1332 continue; |
1235 } | 1333 } |
1236 } | 1334 } |
1237 } | 1335 } |
1238 | 1336 |
1239 void PrerenderLocalPredictor::IssuePrerender( | 1337 void PrerenderLocalPredictor::IssuePrerender( |
1240 CandidatePrerenderInfo* info, | 1338 CandidatePrerenderInfo* info, |
1241 LocalPredictorURLInfo* url_info, | 1339 LocalPredictorURLInfo* url_info) { |
1242 PrerenderProperties* prerender_properties) { | |
1243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1341 if (prefetch_list_->AddURL(url_info->url)) |
| 1342 RecordEvent(EVENT_PREFETCH_LIST_ADDED); |
| 1343 PrerenderProperties* prerender_properties = |
| 1344 GetIssuedPrerenderSlotForPriority(url_info->url, url_info->priority); |
| 1345 if (!prerender_properties) { |
| 1346 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_PRIORITY_TOO_LOW); |
| 1347 return; |
| 1348 } |
1244 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_ISSUING_PRERENDER); | 1349 RecordEvent(EVENT_CONTINUE_PRERENDER_CHECK_ISSUING_PRERENDER); |
1245 DCHECK(prerender_properties != NULL); | 1350 DCHECK(prerender_properties != NULL); |
1246 DCHECK(info != NULL); | 1351 DCHECK(info != NULL); |
1247 DCHECK(url_info != NULL); | 1352 DCHECK(url_info != NULL); |
1248 if (!IsLocalPredictorPrerenderLaunchEnabled()) | 1353 if (!IsLocalPredictorPrerenderLaunchEnabled()) |
1249 return; | 1354 return; |
1250 URLID url_id = url_info->id; | 1355 URLID url_id = url_info->id; |
1251 const GURL& url = url_info->url; | 1356 const GURL& url = url_info->url; |
1252 double priority = url_info->priority; | 1357 double priority = url_info->priority; |
1253 base::Time current_time = GetCurrentTime(); | 1358 base::Time current_time = GetCurrentTime(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 current_prerender_.reset( | 1427 current_prerender_.reset( |
1323 new PrerenderProperties(url_id, url, priority, current_time)); | 1428 new PrerenderProperties(url_id, url, priority, current_time)); |
1324 } | 1429 } |
1325 current_prerender_->actual_start_time = current_time; | 1430 current_prerender_->actual_start_time = current_time; |
1326 } | 1431 } |
1327 | 1432 |
1328 void PrerenderLocalPredictor::OnTabHelperURLSeen( | 1433 void PrerenderLocalPredictor::OnTabHelperURLSeen( |
1329 const GURL& url, WebContents* web_contents) { | 1434 const GURL& url, WebContents* web_contents) { |
1330 RecordEvent(EVENT_TAB_HELPER_URL_SEEN); | 1435 RecordEvent(EVENT_TAB_HELPER_URL_SEEN); |
1331 | 1436 |
| 1437 if (prefetch_list_->MarkURLSeen(url, PrefetchList::SEEN_TABCONTENTS_OBSERVER)) |
| 1438 RecordEvent(EVENT_PREFETCH_LIST_SEEN_TABCONTENTS); |
1332 bool browser_navigate_initiated = false; | 1439 bool browser_navigate_initiated = false; |
1333 const content::NavigationEntry* entry = | 1440 const content::NavigationEntry* entry = |
1334 web_contents->GetController().GetPendingEntry(); | 1441 web_contents->GetController().GetPendingEntry(); |
1335 if (entry) { | 1442 if (entry) { |
1336 base::string16 result; | 1443 base::string16 result; |
1337 browser_navigate_initiated = | 1444 browser_navigate_initiated = |
1338 entry->GetExtraData(kChromeNavigateExtraDataKey, &result); | 1445 entry->GetExtraData(kChromeNavigateExtraDataKey, &result); |
1339 } | 1446 } |
1340 | 1447 |
1341 // If the namespace matches and the URL matches, we might be able to swap | 1448 // If the namespace matches and the URL matches, we might be able to swap |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 break; | 1526 break; |
1420 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE: | 1527 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE: |
1421 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE); | 1528 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE); |
1422 break; | 1529 break; |
1423 default: | 1530 default: |
1424 NOTREACHED(); | 1531 NOTREACHED(); |
1425 } | 1532 } |
1426 } | 1533 } |
1427 | 1534 |
1428 } // namespace prerender | 1535 } // namespace prerender |
OLD | NEW |