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

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

Issue 642623004: Rename VisitDatabaseObserver to HistoryServiceObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@373326
Patch Set: Address comments & 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
« no previous file with comments | « chrome/browser/prerender/prerender_local_predictor.h ('k') | components/history.gypi » ('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 (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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 } 521 }
522 522
523 base::hash_map<string, ListEntry*> entries_; 523 base::hash_map<string, ListEntry*> entries_;
524 std::list<ListEntry*> entry_list_; 524 std::list<ListEntry*> entry_list_;
525 DISALLOW_COPY_AND_ASSIGN(PrefetchList); 525 DISALLOW_COPY_AND_ASSIGN(PrefetchList);
526 }; 526 };
527 527
528 PrerenderLocalPredictor::PrerenderLocalPredictor( 528 PrerenderLocalPredictor::PrerenderLocalPredictor(
529 PrerenderManager* prerender_manager) 529 PrerenderManager* prerender_manager)
530 : prerender_manager_(prerender_manager), 530 : prerender_manager_(prerender_manager),
531 is_visit_database_observer_(false), 531 is_history_service_observer_(false),
532 prefetch_list_(new PrefetchList()), 532 prefetch_list_(new PrefetchList()),
533 weak_factory_(this) { 533 weak_factory_(this) {
534 RecordEvent(EVENT_CONSTRUCTED); 534 RecordEvent(EVENT_CONSTRUCTED);
535 if (base::MessageLoop::current()) { 535 if (base::MessageLoop::current()) {
536 timer_.Start(FROM_HERE, 536 timer_.Start(FROM_HERE,
537 base::TimeDelta::FromMilliseconds(kInitDelayMs), 537 base::TimeDelta::FromMilliseconds(kInitDelayMs),
538 this, 538 this,
539 &PrerenderLocalPredictor::Init); 539 &PrerenderLocalPredictor::Init);
540 RecordEvent(EVENT_INIT_SCHEDULED); 540 RecordEvent(EVENT_INIT_SCHEDULED);
541 } 541 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 if (p->prerender_handle) 576 if (p->prerender_handle)
577 p->prerender_handle->OnCancel(); 577 p->prerender_handle->OnCancel();
578 } 578 }
579 STLDeleteContainerPairPointers( 579 STLDeleteContainerPairPointers(
580 outstanding_prerender_service_requests_.begin(), 580 outstanding_prerender_service_requests_.begin(),
581 outstanding_prerender_service_requests_.end()); 581 outstanding_prerender_service_requests_.end());
582 } 582 }
583 583
584 void PrerenderLocalPredictor::Shutdown() { 584 void PrerenderLocalPredictor::Shutdown() {
585 timer_.Stop(); 585 timer_.Stop();
586 if (is_visit_database_observer_) { 586 if (is_history_service_observer_) {
587 HistoryService* history = GetHistoryIfExists(); 587 HistoryService* history = GetHistoryIfExists();
588 CHECK(history); 588 CHECK(history);
589 history->RemoveVisitDatabaseObserver(this); 589 history->RemoveObserver(this);
590 is_visit_database_observer_ = false; 590 is_history_service_observer_ = false;
591 } 591 }
592 } 592 }
593 593
594 void PrerenderLocalPredictor::OnAddVisit(const history::BriefVisitInfo& info) { 594 void PrerenderLocalPredictor::OnAddVisit(HistoryService* history_service,
595 const history::BriefVisitInfo& info) {
595 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 596 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
596 RecordEvent(EVENT_ADD_VISIT); 597 RecordEvent(EVENT_ADD_VISIT);
597 if (!visit_history_.get()) 598 if (!visit_history_.get())
598 return; 599 return;
599 visit_history_->push_back(info); 600 visit_history_->push_back(info);
600 if (static_cast<int>(visit_history_->size()) > kVisitHistoryPruneThreshold) { 601 if (static_cast<int>(visit_history_->size()) > kVisitHistoryPruneThreshold) {
601 visit_history_->erase(visit_history_->begin(), 602 visit_history_->erase(visit_history_->begin(),
602 visit_history_->begin() + kVisitHistoryPruneAmount); 603 visit_history_->begin() + kVisitHistoryPruneAmount);
603 } 604 }
604 RecordEvent(EVENT_ADD_VISIT_INITIALIZED); 605 RecordEvent(EVENT_ADD_VISIT_INITIALIZED);
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1132 RecordEvent(EVENT_INIT_STARTED); 1133 RecordEvent(EVENT_INIT_STARTED);
1133 Profile* profile = prerender_manager_->profile(); 1134 Profile* profile = prerender_manager_->profile();
1134 if (!profile || 1135 if (!profile ||
1135 ShouldDisableLocalPredictorBasedOnSyncAndConfiguration(profile)) { 1136 ShouldDisableLocalPredictorBasedOnSyncAndConfiguration(profile)) {
1136 RecordEvent(EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED); 1137 RecordEvent(EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED);
1137 return; 1138 return;
1138 } 1139 }
1139 HistoryService* history = GetHistoryIfExists(); 1140 HistoryService* history = GetHistoryIfExists();
1140 if (history) { 1141 if (history) {
1141 CHECK(!is_visit_database_observer_); 1142 CHECK(!is_history_service_observer_);
1142 history->ScheduleDBTask( 1143 history->ScheduleDBTask(
1143 scoped_ptr<history::HistoryDBTask>( 1144 scoped_ptr<history::HistoryDBTask>(
1144 new GetVisitHistoryTask(this, kMaxVisitHistory)), 1145 new GetVisitHistoryTask(this, kMaxVisitHistory)),
1145 &history_db_tracker_); 1146 &history_db_tracker_);
1146 history->AddVisitDatabaseObserver(this); 1147 history->AddObserver(this);
1147 is_visit_database_observer_ = true; 1148 is_history_service_observer_ = true;
1148 } else { 1149 } else {
1149 RecordEvent(EVENT_INIT_FAILED_NO_HISTORY); 1150 RecordEvent(EVENT_INIT_FAILED_NO_HISTORY);
1150 } 1151 }
1151 } 1152 }
1152 1153
1153 void PrerenderLocalPredictor::OnPLTEventForURL(const GURL& url, 1154 void PrerenderLocalPredictor::OnPLTEventForURL(const GURL& url,
1154 base::TimeDelta page_load_time) { 1155 base::TimeDelta page_load_time) {
1155 if (prefetch_list_->MarkPLTSeen(url, page_load_time)) { 1156 if (prefetch_list_->MarkPLTSeen(url, page_load_time)) {
1156 UMA_HISTOGRAM_CUSTOM_TIMES("Prerender.LocalPredictorPrefetchMatchPLT", 1157 UMA_HISTOGRAM_CUSTOM_TIMES("Prerender.LocalPredictorPrefetchMatchPLT",
1157 page_load_time, 1158 page_load_time,
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 break; 1573 break;
1573 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE: 1574 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE:
1574 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE); 1575 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE);
1575 break; 1576 break;
1576 default: 1577 default:
1577 NOTREACHED(); 1578 NOTREACHED();
1578 } 1579 }
1579 } 1580 }
1580 1581
1581 } // namespace prerender 1582 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_local_predictor.h ('k') | components/history.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698