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

Side by Side Diff: chrome/browser/history/history_service.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
« no previous file with comments | « chrome/browser/history/history_service.h ('k') | chrome/browser/history/history_unittest.cc » ('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 // The history system runs on a background thread so that potentially slow 5 // The history system runs on a background thread so that potentially slow
6 // database operations don't delay the browser. This backend processing is 6 // database operations don't delay the browser. This backend processing is
7 // represented by HistoryBackend. The HistoryService's job is to dispatch to 7 // represented by HistoryBackend. The HistoryService's job is to dispatch to
8 // that thread. 8 // that thread.
9 // 9 //
10 // Main thread History thread 10 // Main thread History thread
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::DeleteMatchingURLsForKeyword, 371 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::DeleteMatchingURLsForKeyword,
372 keyword_id, term); 372 keyword_id, term);
373 } 373 }
374 374
375 void HistoryService::URLsNoLongerBookmarked(const std::set<GURL>& urls) { 375 void HistoryService::URLsNoLongerBookmarked(const std::set<GURL>& urls) {
376 DCHECK(thread_checker_.CalledOnValidThread()); 376 DCHECK(thread_checker_.CalledOnValidThread());
377 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::URLsNoLongerBookmarked, 377 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::URLsNoLongerBookmarked,
378 urls); 378 urls);
379 } 379 }
380 380
381 void HistoryService::ScheduleDBTask(history::HistoryDBTask* task, 381 void HistoryService::ScheduleDBTask(scoped_refptr<history::HistoryDBTask> task,
382 CancelableRequestConsumerBase* consumer) { 382 base::CancelableTaskTracker* tracker) {
383 DCHECK(thread_checker_.CalledOnValidThread()); 383 DCHECK(thread_checker_.CalledOnValidThread());
384 history::HistoryDBTaskRequest* request = new history::HistoryDBTaskRequest( 384 base::CancelableTaskTracker::IsCanceledCallback is_canceled;
385 base::Bind(&history::HistoryDBTask::DoneRunOnMainThread, task)); 385 tracker->NewTrackedTaskId(&is_canceled);
386 request->value = task; // The value is the task to execute. 386 // Use base::ThreadTaskRunnerHandler::Get() to get a message loop proxy to
387 Schedule(PRIORITY_UI, &HistoryBackend::ProcessDBTask, consumer, request); 387 // the current message loop so that we can forward the call to the method
388 // HistoryDBTask::DoneRunOnMainThread in the correct thread.
389 thread_->message_loop_proxy()->PostTask(
390 FROM_HERE,
391 base::Bind(&HistoryBackend::ProcessDBTask,
392 history_backend_.get(),
393 task,
394 base::ThreadTaskRunnerHandle::Get(),
395 is_canceled));
388 } 396 }
389 397
390 void HistoryService::FlushForTest(const base::Closure& flushed) { 398 void HistoryService::FlushForTest(const base::Closure& flushed) {
391 thread_->message_loop_proxy()->PostTaskAndReply( 399 thread_->message_loop_proxy()->PostTaskAndReply(
392 FROM_HERE, base::Bind(&base::DoNothing), flushed); 400 FROM_HERE, base::Bind(&base::DoNothing), flushed);
393 } 401 }
394 402
395 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { 403 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) {
396 DCHECK(thread_checker_.CalledOnValidThread()); 404 DCHECK(thread_checker_.CalledOnValidThread());
397 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask, 405 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask,
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 DCHECK(thread_checker_.CalledOnValidThread()); 1192 DCHECK(thread_checker_.CalledOnValidThread());
1185 visit_database_observers_.RemoveObserver(observer); 1193 visit_database_observers_.RemoveObserver(observer);
1186 } 1194 }
1187 1195
1188 void HistoryService::NotifyVisitDBObserversOnAddVisit( 1196 void HistoryService::NotifyVisitDBObserversOnAddVisit(
1189 const history::BriefVisitInfo& info) { 1197 const history::BriefVisitInfo& info) {
1190 DCHECK(thread_checker_.CalledOnValidThread()); 1198 DCHECK(thread_checker_.CalledOnValidThread());
1191 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, 1199 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_,
1192 OnAddVisit(info)); 1200 OnAddVisit(info));
1193 } 1201 }
OLDNEW
« no previous file with comments | « chrome/browser/history/history_service.h ('k') | chrome/browser/history/history_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698