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

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

Issue 387923002: Make HistoryDBTask not refcounted, and ensure it's destroyed on its origin thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert unnecessary changes 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(lookup_info_ptr, 558 scoped_ptr<history::HistoryDBTask>(
559 base::Bind(&PrerenderLocalPredictor::OnLookupURL, 559 new GetURLForURLIDTask(
560 base::Unretained(this), 560 lookup_info_ptr,
561 base::Passed(&lookup_info))), 561 base::Bind(&PrerenderLocalPredictor::OnLookupURL,
562 base::Unretained(this),
563 base::Passed(&lookup_info)))),
562 &history_db_tracker_); 564 &history_db_tracker_);
563 } 565 }
564 } 566 }
565 567
566 void PrerenderLocalPredictor::OnLookupURL( 568 void PrerenderLocalPredictor::OnLookupURL(
567 scoped_ptr<CandidatePrerenderInfo> info) { 569 scoped_ptr<CandidatePrerenderInfo> info) {
568 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
569 571
570 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT); 572 RecordEvent(EVENT_PRERENDER_URL_LOOKUP_RESULT);
571 573
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 993 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
992 RecordEvent(EVENT_INIT_STARTED); 994 RecordEvent(EVENT_INIT_STARTED);
993 Profile* profile = prerender_manager_->profile(); 995 Profile* profile = prerender_manager_->profile();
994 if (!profile || DisableLocalPredictorBasedOnSyncAndConfiguration(profile)) { 996 if (!profile || DisableLocalPredictorBasedOnSyncAndConfiguration(profile)) {
995 RecordEvent(EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED); 997 RecordEvent(EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED);
996 return; 998 return;
997 } 999 }
998 HistoryService* history = GetHistoryIfExists(); 1000 HistoryService* history = GetHistoryIfExists();
999 if (history) { 1001 if (history) {
1000 CHECK(!is_visit_database_observer_); 1002 CHECK(!is_visit_database_observer_);
1001 history->ScheduleDBTask(new GetVisitHistoryTask(this, kMaxVisitHistory), 1003 history->ScheduleDBTask(
1002 &history_db_tracker_); 1004 scoped_ptr<history::HistoryDBTask>(
1005 new GetVisitHistoryTask(this, kMaxVisitHistory)),
1006 &history_db_tracker_);
1003 history->AddVisitDatabaseObserver(this); 1007 history->AddVisitDatabaseObserver(this);
1004 is_visit_database_observer_ = true; 1008 is_visit_database_observer_ = true;
1005 } else { 1009 } else {
1006 RecordEvent(EVENT_INIT_FAILED_NO_HISTORY); 1010 RecordEvent(EVENT_INIT_FAILED_NO_HISTORY);
1007 } 1011 }
1008 } 1012 }
1009 1013
1010 void PrerenderLocalPredictor::OnPLTEventForURL(const GURL& url, 1014 void PrerenderLocalPredictor::OnPLTEventForURL(const GURL& url,
1011 base::TimeDelta page_load_time) { 1015 base::TimeDelta page_load_time) {
1012 scoped_ptr<PrerenderProperties> prerender; 1016 scoped_ptr<PrerenderProperties> prerender;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 break; 1419 break;
1416 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE: 1420 case content::SessionStorageNamespace::MERGE_RESULT_MERGEABLE:
1417 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE); 1421 RecordEvent(EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE);
1418 break; 1422 break;
1419 default: 1423 default:
1420 NOTREACHED(); 1424 NOTREACHED();
1421 } 1425 }
1422 } 1426 }
1423 1427
1424 } // namespace prerender 1428 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/history/url_index_private_data.cc ('k') | chrome/browser/sync/glue/history_model_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698