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

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

Issue 352913002: Port HistoryService::ScheduleDBTask to CancelableTaskTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix lifetime of base::CancelableTaskTracker for HistoryModelWorker Created 6 years, 5 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 | Annotate | Revision Log
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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 lookup_info->MaybeAddCandidateURLFromLocalData(it->first, priority); 548 lookup_info->MaybeAddCandidateURLFromLocalData(it->first, priority);
549 } 549 }
550 } 550 }
551 551
552 RecordEvent(EVENT_START_URL_LOOKUP); 552 RecordEvent(EVENT_START_URL_LOOKUP);
553 HistoryService* history = GetHistoryIfExists(); 553 HistoryService* history = GetHistoryIfExists();
554 if (history) { 554 if (history) {
555 RecordEvent(EVENT_GOT_HISTORY_ISSUING_LOOKUP); 555 RecordEvent(EVENT_GOT_HISTORY_ISSUING_LOOKUP);
556 CandidatePrerenderInfo* lookup_info_ptr = lookup_info.get(); 556 CandidatePrerenderInfo* lookup_info_ptr = lookup_info.get();
557 history->ScheduleDBTask( 557 history->ScheduleDBTask(
558 new GetURLForURLIDTask( 558 new GetURLForURLIDTask(lookup_info_ptr,
559 lookup_info_ptr, 559 base::Bind(&PrerenderLocalPredictor::OnLookupURL,
560 base::Bind(&PrerenderLocalPredictor::OnLookupURL, 560 base::Unretained(this),
561 base::Unretained(this), 561 base::Passed(&lookup_info))),
562 base::Passed(&lookup_info))), 562 &history_db_tracker_);
563 &history_db_consumer_);
564 } 563 }
565 } 564 }
566 565
567 void PrerenderLocalPredictor::OnLookupURL( 566 void PrerenderLocalPredictor::OnLookupURL(
568 scoped_ptr<CandidatePrerenderInfo> info) { 567 scoped_ptr<CandidatePrerenderInfo> info) {
569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 568 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
570 569
571 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT); 570 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT);
572 571
573 if (!info->source_url_.url_lookup_success) { 572 if (!info->source_url_.url_lookup_success) {
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 989 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
991 RecordEvent(EVENT_INIT_STARTED); 990 RecordEvent(EVENT_INIT_STARTED);
992 Profile* profile = prerender_manager_->profile(); 991 Profile* profile = prerender_manager_->profile();
993 if (!profile || DisableLocalPredictorBasedOnSyncAndConfiguration(profile)) { 992 if (!profile || DisableLocalPredictorBasedOnSyncAndConfiguration(profile)) {
994 RecordEvent(EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED); 993 RecordEvent(EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED);
995 return; 994 return;
996 } 995 }
997 HistoryService* history = GetHistoryIfExists(); 996 HistoryService* history = GetHistoryIfExists();
998 if (history) { 997 if (history) {
999 CHECK(!is_visit_database_observer_); 998 CHECK(!is_visit_database_observer_);
1000 history->ScheduleDBTask( 999 history->ScheduleDBTask(new GetVisitHistoryTask(this, kMaxVisitHistory),
1001 new GetVisitHistoryTask(this, kMaxVisitHistory), 1000 &history_db_tracker_);
1002 &history_db_consumer_);
1003 history->AddVisitDatabaseObserver(this); 1001 history->AddVisitDatabaseObserver(this);
1004 is_visit_database_observer_ = true; 1002 is_visit_database_observer_ = true;
1005 } else { 1003 } else {
1006 RecordEvent(EVENT_INIT_FAILED_NO_HISTORY); 1004 RecordEvent(EVENT_INIT_FAILED_NO_HISTORY);
1007 } 1005 }
1008 } 1006 }
1009 1007
1010 void PrerenderLocalPredictor::OnPLTEventForURL(const GURL& url, 1008 void PrerenderLocalPredictor::OnPLTEventForURL(const GURL& url,
1011 base::TimeDelta page_load_time) { 1009 base::TimeDelta page_load_time) {
1012 scoped_ptr<PrerenderProperties> prerender; 1010 scoped_ptr<PrerenderProperties> prerender;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 break; 1413 break;
1416 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE: 1414 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE:
1417 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE); 1415 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE);
1418 break; 1416 break;
1419 default: 1417 default:
1420 NOTREACHED(); 1418 NOTREACHED();
1421 } 1419 }
1422 } 1420 }
1423 1421
1424 } // namespace prerender 1422 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_local_predictor.h ('k') | chrome/browser/sync/glue/history_model_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698