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

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

Issue 10399087: Converting BookmarkModel and HistoryService to ProfileKeyedServices. This just performs the initial… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/history.h ('k') | chrome/browser/history/history_service_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 14 matching lines...) Expand all
25 #include "chrome/browser/history/history.h" 25 #include "chrome/browser/history/history.h"
26 26
27 #include "base/callback.h" 27 #include "base/callback.h"
28 #include "base/command_line.h" 28 #include "base/command_line.h"
29 #include "base/memory/ref_counted.h" 29 #include "base/memory/ref_counted.h"
30 #include "base/message_loop.h" 30 #include "base/message_loop.h"
31 #include "base/path_service.h" 31 #include "base/path_service.h"
32 #include "base/string_util.h" 32 #include "base/string_util.h"
33 #include "base/threading/thread.h" 33 #include "base/threading/thread.h"
34 #include "chrome/browser/autocomplete/history_url_provider.h" 34 #include "chrome/browser/autocomplete/history_url_provider.h"
35 #include "chrome/browser/bookmarks/bookmark_model.h"
36 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
35 #include "chrome/browser/browser_process.h" 37 #include "chrome/browser/browser_process.h"
36 #include "chrome/browser/history/history_backend.h" 38 #include "chrome/browser/history/history_backend.h"
37 #include "chrome/browser/history/history_notifications.h" 39 #include "chrome/browser/history/history_notifications.h"
38 #include "chrome/browser/history/history_types.h" 40 #include "chrome/browser/history/history_types.h"
39 #include "chrome/browser/history/in_memory_database.h" 41 #include "chrome/browser/history/in_memory_database.h"
40 #include "chrome/browser/history/in_memory_history_backend.h" 42 #include "chrome/browser/history/in_memory_history_backend.h"
41 #include "chrome/browser/history/in_memory_url_index.h" 43 #include "chrome/browser/history/in_memory_url_index.h"
42 #include "chrome/browser/history/top_sites.h" 44 #include "chrome/browser/history/top_sites.h"
43 #include "chrome/browser/history/visit_database.h" 45 #include "chrome/browser/history/visit_database.h"
44 #include "chrome/browser/history/visit_filter.h" 46 #include "chrome/browser/history/visit_filter.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 history::URLDatabase* HistoryService::InMemoryDatabase() { 258 history::URLDatabase* HistoryService::InMemoryDatabase() {
257 // NOTE: See comments in BackendLoaded() as to why we call 259 // NOTE: See comments in BackendLoaded() as to why we call
258 // LoadBackendIfNecessary() here even though it won't affect the return value 260 // LoadBackendIfNecessary() here even though it won't affect the return value
259 // for this call. 261 // for this call.
260 LoadBackendIfNecessary(); 262 LoadBackendIfNecessary();
261 if (in_memory_backend_.get()) 263 if (in_memory_backend_.get())
262 return in_memory_backend_->db(); 264 return in_memory_backend_->db();
263 return NULL; 265 return NULL;
264 } 266 }
265 267
268 void HistoryService::ShutdownOnUIThread() {
269 // It's possible that bookmarks haven't loaded and history is waiting for
270 // bookmarks to complete loading. In such a situation history can't shutdown
271 // (meaning if we invoked history_service_->Cleanup now, we would
272 // deadlock). To break the deadlock we tell BookmarkModel it's about to be
273 // deleted so that it can release the signal history is waiting on, allowing
274 // history to shutdown (history_service_->Cleanup to complete). In such a
275 // scenario history sees an incorrect view of bookmarks, but it's better
276 // than a deadlock.
277 BookmarkModel* bookmark_model = static_cast<BookmarkModel*>(
278 BookmarkModelFactory::GetForProfileIfExists(profile_));
279 if (bookmark_model)
280 bookmark_model->Shutdown();
281
282 Cleanup();
283 }
284
266 void HistoryService::SetSegmentPresentationIndex(int64 segment_id, int index) { 285 void HistoryService::SetSegmentPresentationIndex(int64 segment_id, int index) {
267 ScheduleAndForget(PRIORITY_UI, 286 ScheduleAndForget(PRIORITY_UI,
268 &HistoryBackend::SetSegmentPresentationIndex, 287 &HistoryBackend::SetSegmentPresentationIndex,
269 segment_id, index); 288 segment_id, index);
270 } 289 }
271 290
272 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url, 291 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url,
273 TemplateURLID keyword_id, 292 TemplateURLID keyword_id,
274 const string16& term) { 293 const string16& term) {
275 ScheduleAndForget(PRIORITY_UI, 294 ScheduleAndForget(PRIORITY_UI,
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 void HistoryService::RemoveVisitDatabaseObserver( 934 void HistoryService::RemoveVisitDatabaseObserver(
916 history::VisitDatabaseObserver* observer) { 935 history::VisitDatabaseObserver* observer) {
917 visit_database_observers_->RemoveObserver(observer); 936 visit_database_observers_->RemoveObserver(observer);
918 } 937 }
919 938
920 void HistoryService::NotifyVisitDBObserversOnAddVisit( 939 void HistoryService::NotifyVisitDBObserversOnAddVisit(
921 const history::BriefVisitInfo& info) { 940 const history::BriefVisitInfo& info) {
922 visit_database_observers_->Notify( 941 visit_database_observers_->Notify(
923 &history::VisitDatabaseObserver::OnAddVisit, info); 942 &history::VisitDatabaseObserver::OnAddVisit, info);
924 } 943 }
OLDNEW
« no previous file with comments | « chrome/browser/history/history.h ('k') | chrome/browser/history/history_service_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698