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

Side by Side Diff: chrome/browser/history/history_service.cc

Issue 573553004: Eliminate NOTIFICATION_HISTORY_LOADED notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ScopedObserver to InMemoryHistoryBackend,PrerenderLocalPredictor,ChromeTemplateURLServiceClient Created 6 years 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
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 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 base::Bind(callback, base::Owned(result))); 881 base::Bind(callback, base::Owned(result)));
882 } 882 }
883 883
884 void HistoryService::Cleanup() { 884 void HistoryService::Cleanup() {
885 DCHECK(thread_checker_.CalledOnValidThread()); 885 DCHECK(thread_checker_.CalledOnValidThread());
886 if (!thread_) { 886 if (!thread_) {
887 // We've already cleaned up. 887 // We've already cleaned up.
888 return; 888 return;
889 } 889 }
890 890
891 NotifyHistoryServiceBeingDeleted();
892
891 weak_ptr_factory_.InvalidateWeakPtrs(); 893 weak_ptr_factory_.InvalidateWeakPtrs();
892 894
893 // Unload the backend. 895 // Unload the backend.
894 if (history_backend_.get()) { 896 if (history_backend_.get()) {
895 // Get rid of the in-memory backend. 897 // Get rid of the in-memory backend.
896 in_memory_backend_.reset(); 898 in_memory_backend_.reset();
897 899
898 // Give the InMemoryURLIndex a chance to shutdown. 900 // Give the InMemoryURLIndex a chance to shutdown.
899 // NOTE: In tests, there may be no index. 901 // NOTE: In tests, there may be no index.
900 if (in_memory_url_index_) 902 if (in_memory_url_index_)
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 // backend has allocated for us. The receiver of the notification will cast 1229 // backend has allocated for us. The receiver of the notification will cast
1228 // this to the proper type. 1230 // this to the proper type.
1229 content::Details<history::HistoryDetails> det(details.get()); 1231 content::Details<history::HistoryDetails> det(details.get());
1230 1232
1231 content::NotificationService::current()->Notify(type, source, det); 1233 content::NotificationService::current()->Notify(type, source, det);
1232 } 1234 }
1233 1235
1234 void HistoryService::OnDBLoaded() { 1236 void HistoryService::OnDBLoaded() {
1235 DCHECK(thread_checker_.CalledOnValidThread()); 1237 DCHECK(thread_checker_.CalledOnValidThread());
1236 backend_loaded_ = true; 1238 backend_loaded_ = true;
1237 content::NotificationService::current()->Notify( 1239 NotifyHistoryServiceLoaded();
1238 chrome::NOTIFICATION_HISTORY_LOADED,
1239 content::Source<Profile>(profile_),
1240 content::Details<HistoryService>(this));
1241 } 1240 }
1242 1241
1243 bool HistoryService::GetRowForURL(const GURL& url, history::URLRow* url_row) { 1242 bool HistoryService::GetRowForURL(const GURL& url, history::URLRow* url_row) {
1244 DCHECK(thread_checker_.CalledOnValidThread()); 1243 DCHECK(thread_checker_.CalledOnValidThread());
1245 history::URLDatabase* db = InMemoryDatabase(); 1244 history::URLDatabase* db = InMemoryDatabase();
1246 return db && (db->GetRowForURL(url, url_row) != 0); 1245 return db && (db->GetRowForURL(url, url_row) != 0);
1247 } 1246 }
1248 1247
1249 void HistoryService::NotifyAddVisit(const history::BriefVisitInfo& info) { 1248 void HistoryService::NotifyAddVisit(const history::BriefVisitInfo& info) {
1250 DCHECK(thread_checker_.CalledOnValidThread()); 1249 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 11 matching lines...) Expand all
1262 OnURLVisited(this, transition, row, redirects, visit_time)); 1261 OnURLVisited(this, transition, row, redirects, visit_time));
1263 } 1262 }
1264 1263
1265 void HistoryService::NotifyURLsModified(const history::URLRows& changed_urls) { 1264 void HistoryService::NotifyURLsModified(const history::URLRows& changed_urls) {
1266 DCHECK(thread_checker_.CalledOnValidThread()); 1265 DCHECK(thread_checker_.CalledOnValidThread());
1267 FOR_EACH_OBSERVER(history::HistoryServiceObserver, 1266 FOR_EACH_OBSERVER(history::HistoryServiceObserver,
1268 observers_, 1267 observers_,
1269 OnURLsModified(this, changed_urls)); 1268 OnURLsModified(this, changed_urls));
1270 } 1269 }
1271 1270
1271 void HistoryService::NotifyHistoryServiceLoaded() {
1272 DCHECK(thread_checker_.CalledOnValidThread());
1273 FOR_EACH_OBSERVER(history::HistoryServiceObserver, observers_,
1274 OnHistoryServiceLoaded(this));
1275 }
1276
1277 void HistoryService::NotifyHistoryServiceBeingDeleted() {
1278 DCHECK(thread_checker_.CalledOnValidThread());
1279 FOR_EACH_OBSERVER(history::HistoryServiceObserver, observers_,
1280 HistoryServiceBeingDeleted(this));
1281 }
1282
1272 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription> 1283 scoped_ptr<base::CallbackList<void(const std::set<GURL>&)>::Subscription>
1273 HistoryService::AddFaviconChangedCallback( 1284 HistoryService::AddFaviconChangedCallback(
1274 const HistoryService::OnFaviconChangedCallback& callback) { 1285 const HistoryService::OnFaviconChangedCallback& callback) {
1275 DCHECK(thread_checker_.CalledOnValidThread()); 1286 DCHECK(thread_checker_.CalledOnValidThread());
1276 return favicon_changed_callback_list_.Add(callback); 1287 return favicon_changed_callback_list_.Add(callback);
1277 } 1288 }
1278 1289
1279 void HistoryService::NotifyFaviconChanged( 1290 void HistoryService::NotifyFaviconChanged(
1280 const std::set<GURL>& changed_favicons) { 1291 const std::set<GURL>& changed_favicons) {
1281 DCHECK(thread_checker_.CalledOnValidThread()); 1292 DCHECK(thread_checker_.CalledOnValidThread());
1282 favicon_changed_callback_list_.Notify(changed_favicons); 1293 favicon_changed_callback_list_.Notify(changed_favicons);
1283 } 1294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698