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 // 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 Loading... |
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 Loading... |
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 } |
OLD | NEW |