| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 void HistoryService::Cleanup() { | 234 void HistoryService::Cleanup() { |
| 235 DCHECK(thread_checker_.CalledOnValidThread()); | 235 DCHECK(thread_checker_.CalledOnValidThread()); |
| 236 if (!thread_) { | 236 if (!thread_) { |
| 237 // We've already cleaned up. | 237 // We've already cleaned up. |
| 238 return; | 238 return; |
| 239 } | 239 } |
| 240 | 240 |
| 241 weak_ptr_factory_.InvalidateWeakPtrs(); | 241 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 242 | 242 |
| 243 // Unload the backend. | 243 // Unload the backend. |
| 244 if (history_backend_) { | 244 if (history_backend_.get()) { |
| 245 // Get rid of the in-memory backend. | 245 // Get rid of the in-memory backend. |
| 246 in_memory_backend_.reset(); | 246 in_memory_backend_.reset(); |
| 247 | 247 |
| 248 // Give the InMemoryURLIndex a chance to shutdown. | 248 // Give the InMemoryURLIndex a chance to shutdown. |
| 249 // NOTE: In tests, there may be no index. | 249 // NOTE: In tests, there may be no index. |
| 250 if (in_memory_url_index_) | 250 if (in_memory_url_index_) |
| 251 in_memory_url_index_->ShutDown(); | 251 in_memory_url_index_->ShutDown(); |
| 252 | 252 |
| 253 // The backend's destructor must run on the history thread since it is not | 253 // The backend's destructor must run on the history thread since it is not |
| 254 // threadsafe. So this thread must not be the last thread holding a | 254 // threadsafe. So this thread must not be the last thread holding a |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 DCHECK(thread_checker_.CalledOnValidThread()); | 1222 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1223 visit_database_observers_.RemoveObserver(observer); | 1223 visit_database_observers_.RemoveObserver(observer); |
| 1224 } | 1224 } |
| 1225 | 1225 |
| 1226 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 1226 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
| 1227 const history::BriefVisitInfo& info) { | 1227 const history::BriefVisitInfo& info) { |
| 1228 DCHECK(thread_checker_.CalledOnValidThread()); | 1228 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1229 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, | 1229 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, |
| 1230 OnAddVisit(info)); | 1230 OnAddVisit(info)); |
| 1231 } | 1231 } |
| OLD | NEW |