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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 base::Bind(callback, base::Owned(result))); | 874 base::Bind(callback, base::Owned(result))); |
875 } | 875 } |
876 | 876 |
877 void HistoryService::Cleanup() { | 877 void HistoryService::Cleanup() { |
878 DCHECK(thread_checker_.CalledOnValidThread()); | 878 DCHECK(thread_checker_.CalledOnValidThread()); |
879 if (!thread_) { | 879 if (!thread_) { |
880 // We've already cleaned up. | 880 // We've already cleaned up. |
881 return; | 881 return; |
882 } | 882 } |
883 | 883 |
| 884 NotifyHistoryServiceBeingDeleted(); |
| 885 |
884 weak_ptr_factory_.InvalidateWeakPtrs(); | 886 weak_ptr_factory_.InvalidateWeakPtrs(); |
885 | 887 |
886 // Unload the backend. | 888 // Unload the backend. |
887 if (history_backend_.get()) { | 889 if (history_backend_.get()) { |
888 // Get rid of the in-memory backend. | 890 // Get rid of the in-memory backend. |
889 in_memory_backend_.reset(); | 891 in_memory_backend_.reset(); |
890 | 892 |
891 // Give the InMemoryURLIndex a chance to shutdown. | 893 // Give the InMemoryURLIndex a chance to shutdown. |
892 // NOTE: In tests, there may be no index. | 894 // NOTE: In tests, there may be no index. |
893 if (in_memory_url_index_) | 895 if (in_memory_url_index_) |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 // backend has allocated for us. The receiver of the notification will cast | 1222 // backend has allocated for us. The receiver of the notification will cast |
1221 // this to the proper type. | 1223 // this to the proper type. |
1222 content::Details<history::HistoryDetails> det(details.get()); | 1224 content::Details<history::HistoryDetails> det(details.get()); |
1223 | 1225 |
1224 content::NotificationService::current()->Notify(type, source, det); | 1226 content::NotificationService::current()->Notify(type, source, det); |
1225 } | 1227 } |
1226 | 1228 |
1227 void HistoryService::OnDBLoaded() { | 1229 void HistoryService::OnDBLoaded() { |
1228 DCHECK(thread_checker_.CalledOnValidThread()); | 1230 DCHECK(thread_checker_.CalledOnValidThread()); |
1229 backend_loaded_ = true; | 1231 backend_loaded_ = true; |
1230 content::NotificationService::current()->Notify( | 1232 NotifyHistoryServiceLoaded(); |
1231 chrome::NOTIFICATION_HISTORY_LOADED, | |
1232 content::Source<Profile>(profile_), | |
1233 content::Details<HistoryService>(this)); | |
1234 } | 1233 } |
1235 | 1234 |
1236 bool HistoryService::GetRowForURL(const GURL& url, history::URLRow* url_row) { | 1235 bool HistoryService::GetRowForURL(const GURL& url, history::URLRow* url_row) { |
1237 DCHECK(thread_checker_.CalledOnValidThread()); | 1236 DCHECK(thread_checker_.CalledOnValidThread()); |
1238 history::URLDatabase* db = InMemoryDatabase(); | 1237 history::URLDatabase* db = InMemoryDatabase(); |
1239 return db && (db->GetRowForURL(url, url_row) != 0); | 1238 return db && (db->GetRowForURL(url, url_row) != 0); |
1240 } | 1239 } |
1241 | 1240 |
1242 void HistoryService::NotifyAddVisit(const history::BriefVisitInfo& info) { | 1241 void HistoryService::NotifyAddVisit(const history::BriefVisitInfo& info) { |
1243 DCHECK(thread_checker_.CalledOnValidThread()); | 1242 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 16 matching lines...) Expand all Loading... |
1260 const HistoryService::OnFaviconChangedCallback& callback) { | 1259 const HistoryService::OnFaviconChangedCallback& callback) { |
1261 DCHECK(thread_checker_.CalledOnValidThread()); | 1260 DCHECK(thread_checker_.CalledOnValidThread()); |
1262 return favicon_changed_callback_list_.Add(callback); | 1261 return favicon_changed_callback_list_.Add(callback); |
1263 } | 1262 } |
1264 | 1263 |
1265 void HistoryService::NotifyFaviconChanged( | 1264 void HistoryService::NotifyFaviconChanged( |
1266 const std::set<GURL>& changed_favicons) { | 1265 const std::set<GURL>& changed_favicons) { |
1267 DCHECK(thread_checker_.CalledOnValidThread()); | 1266 DCHECK(thread_checker_.CalledOnValidThread()); |
1268 favicon_changed_callback_list_.Notify(changed_favicons); | 1267 favicon_changed_callback_list_.Notify(changed_favicons); |
1269 } | 1268 } |
| 1269 |
| 1270 void HistoryService::NotifyHistoryServiceLoaded() { |
| 1271 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1272 FOR_EACH_OBSERVER(history::HistoryServiceObserver, observers_, |
| 1273 OnHistoryServiceLoaded(this)); |
| 1274 } |
| 1275 |
| 1276 void HistoryService::NotifyHistoryServiceBeingDeleted() { |
| 1277 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1278 FOR_EACH_OBSERVER(history::HistoryServiceObserver, observers_, |
| 1279 HistoryServiceBeingDeleted(this)); |
| 1280 } |
OLD | NEW |