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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 void HistoryService::AddObserver(history::HistoryServiceObserver* observer) { | 322 void HistoryService::AddObserver(history::HistoryServiceObserver* observer) { |
323 DCHECK(thread_checker_.CalledOnValidThread()); | 323 DCHECK(thread_checker_.CalledOnValidThread()); |
324 observers_.AddObserver(observer); | 324 observers_.AddObserver(observer); |
325 } | 325 } |
326 | 326 |
327 void HistoryService::RemoveObserver(history::HistoryServiceObserver* observer) { | 327 void HistoryService::RemoveObserver(history::HistoryServiceObserver* observer) { |
328 DCHECK(thread_checker_.CalledOnValidThread()); | 328 DCHECK(thread_checker_.CalledOnValidThread()); |
329 observers_.RemoveObserver(observer); | 329 observers_.RemoveObserver(observer); |
330 } | 330 } |
331 | 331 |
332 void HistoryService::ScheduleDBTask(scoped_ptr<history::HistoryDBTask> task, | 332 base::CancelableTaskTracker::TaskId HistoryService::ScheduleDBTask( |
333 base::CancelableTaskTracker* tracker) { | 333 scoped_ptr<history::HistoryDBTask> task, |
| 334 base::CancelableTaskTracker* tracker) { |
334 DCHECK(thread_) << "History service being called after cleanup"; | 335 DCHECK(thread_) << "History service being called after cleanup"; |
335 DCHECK(thread_checker_.CalledOnValidThread()); | 336 DCHECK(thread_checker_.CalledOnValidThread()); |
336 base::CancelableTaskTracker::IsCanceledCallback is_canceled; | 337 base::CancelableTaskTracker::IsCanceledCallback is_canceled; |
337 tracker->NewTrackedTaskId(&is_canceled); | 338 base::CancelableTaskTracker::TaskId task_id = |
| 339 tracker->NewTrackedTaskId(&is_canceled); |
338 // Use base::ThreadTaskRunnerHandler::Get() to get a message loop proxy to | 340 // Use base::ThreadTaskRunnerHandler::Get() to get a message loop proxy to |
339 // the current message loop so that we can forward the call to the method | 341 // the current message loop so that we can forward the call to the method |
340 // HistoryDBTask::DoneRunOnMainThread in the correct thread. | 342 // HistoryDBTask::DoneRunOnMainThread() in the correct thread. |
341 thread_->message_loop_proxy()->PostTask( | 343 thread_->message_loop_proxy()->PostTask( |
342 FROM_HERE, | 344 FROM_HERE, |
343 base::Bind(&HistoryBackend::ProcessDBTask, | 345 base::Bind(&HistoryBackend::ProcessDBTask, |
344 history_backend_.get(), | 346 history_backend_.get(), |
345 base::Passed(&task), | 347 base::Passed(&task), |
346 base::ThreadTaskRunnerHandle::Get(), | 348 base::ThreadTaskRunnerHandle::Get(), |
347 is_canceled)); | 349 is_canceled)); |
| 350 return task_id; |
348 } | 351 } |
349 | 352 |
350 void HistoryService::FlushForTest(const base::Closure& flushed) { | 353 void HistoryService::FlushForTest(const base::Closure& flushed) { |
351 thread_->message_loop_proxy()->PostTaskAndReply( | 354 thread_->message_loop_proxy()->PostTaskAndReply( |
352 FROM_HERE, base::Bind(&base::DoNothing), flushed); | 355 FROM_HERE, base::Bind(&base::DoNothing), flushed); |
353 } | 356 } |
354 | 357 |
355 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { | 358 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { |
356 DCHECK(thread_) << "History service being called after cleanup"; | 359 DCHECK(thread_) << "History service being called after cleanup"; |
357 DCHECK(thread_checker_.CalledOnValidThread()); | 360 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 const HistoryService::OnFaviconChangedCallback& callback) { | 1245 const HistoryService::OnFaviconChangedCallback& callback) { |
1243 DCHECK(thread_checker_.CalledOnValidThread()); | 1246 DCHECK(thread_checker_.CalledOnValidThread()); |
1244 return favicon_changed_callback_list_.Add(callback); | 1247 return favicon_changed_callback_list_.Add(callback); |
1245 } | 1248 } |
1246 | 1249 |
1247 void HistoryService::NotifyFaviconChanged( | 1250 void HistoryService::NotifyFaviconChanged( |
1248 const std::set<GURL>& changed_favicons) { | 1251 const std::set<GURL>& changed_favicons) { |
1249 DCHECK(thread_checker_.CalledOnValidThread()); | 1252 DCHECK(thread_checker_.CalledOnValidThread()); |
1250 favicon_changed_callback_list_.Notify(changed_favicons); | 1253 favicon_changed_callback_list_.Notify(changed_favicons); |
1251 } | 1254 } |
OLD | NEW |