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

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

Issue 8275004: Revert 105300 - HQP Refactoring (in Preparation for SQLite Cache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 19 matching lines...) Expand all
30 #include "base/path_service.h" 30 #include "base/path_service.h"
31 #include "base/string_util.h" 31 #include "base/string_util.h"
32 #include "base/task.h" 32 #include "base/task.h"
33 #include "chrome/browser/autocomplete/history_url_provider.h" 33 #include "chrome/browser/autocomplete/history_url_provider.h"
34 #include "chrome/browser/browser_process.h" 34 #include "chrome/browser/browser_process.h"
35 #include "chrome/browser/history/history_backend.h" 35 #include "chrome/browser/history/history_backend.h"
36 #include "chrome/browser/history/history_notifications.h" 36 #include "chrome/browser/history/history_notifications.h"
37 #include "chrome/browser/history/history_types.h" 37 #include "chrome/browser/history/history_types.h"
38 #include "chrome/browser/history/in_memory_database.h" 38 #include "chrome/browser/history/in_memory_database.h"
39 #include "chrome/browser/history/in_memory_history_backend.h" 39 #include "chrome/browser/history/in_memory_history_backend.h"
40 #include "chrome/browser/history/in_memory_url_index.h"
41 #include "chrome/browser/history/top_sites.h" 40 #include "chrome/browser/history/top_sites.h"
42 #include "chrome/browser/prefs/pref_service.h" 41 #include "chrome/browser/prefs/pref_service.h"
43 #include "chrome/browser/profiles/profile.h" 42 #include "chrome/browser/profiles/profile.h"
44 #include "chrome/browser/ui/profile_error_dialog.h" 43 #include "chrome/browser/ui/profile_error_dialog.h"
45 #include "chrome/browser/visitedlink/visitedlink_master.h" 44 #include "chrome/browser/visitedlink/visitedlink_master.h"
46 #include "chrome/common/chrome_constants.h" 45 #include "chrome/common/chrome_constants.h"
47 #include "chrome/common/chrome_notification_types.h" 46 #include "chrome/common/chrome_notification_types.h"
48 #include "chrome/common/pref_names.h" 47 #include "chrome/common/pref_names.h"
49 #include "chrome/common/thumbnail_score.h" 48 #include "chrome/common/thumbnail_score.h"
50 #include "chrome/common/url_constants.h" 49 #include "chrome/common/url_constants.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return backend_loaded_; 175 return backend_loaded_;
177 } 176 }
178 177
179 void HistoryService::UnloadBackend() { 178 void HistoryService::UnloadBackend() {
180 if (!history_backend_) 179 if (!history_backend_)
181 return; // Already unloaded. 180 return; // Already unloaded.
182 181
183 // Get rid of the in-memory backend. 182 // Get rid of the in-memory backend.
184 in_memory_backend_.reset(); 183 in_memory_backend_.reset();
185 184
186 // Give the InMemoryURLIndex a chance to shutdown.
187 InMemoryIndex()->ShutDown();
188
189 // The backend's destructor must run on the history thread since it is not 185 // The backend's destructor must run on the history thread since it is not
190 // threadsafe. So this thread must not be the last thread holding a reference 186 // threadsafe. So this thread must not be the last thread holding a reference
191 // to the backend, or a crash could happen. 187 // to the backend, or a crash could happen.
192 // 188 //
193 // We have a reference to the history backend. There is also an extra 189 // We have a reference to the history backend. There is also an extra
194 // reference held by our delegate installed in the backend, which 190 // reference held by our delegate installed in the backend, which
195 // HistoryBackend::Closing will release. This means if we scheduled a call 191 // HistoryBackend::Closing will release. This means if we scheduled a call
196 // to HistoryBackend::Closing and *then* released our backend reference, there 192 // to HistoryBackend::Closing and *then* released our backend reference, there
197 // will be a race between us and the backend's Closing function to see who is 193 // will be a race between us and the backend's Closing function to see who is
198 // the last holder of a reference. If the backend thread's Closing manages to 194 // the last holder of a reference. If the backend thread's Closing manages to
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (in_memory_backend_.get()) 242 if (in_memory_backend_.get())
247 return in_memory_backend_->db(); 243 return in_memory_backend_->db();
248 return NULL; 244 return NULL;
249 } 245 }
250 246
251 history::InMemoryURLIndex* HistoryService::InMemoryIndex() { 247 history::InMemoryURLIndex* HistoryService::InMemoryIndex() {
252 // NOTE: See comments in BackendLoaded() as to why we call 248 // NOTE: See comments in BackendLoaded() as to why we call
253 // LoadBackendIfNecessary() here even though it won't affect the return value 249 // LoadBackendIfNecessary() here even though it won't affect the return value
254 // for this call. 250 // for this call.
255 LoadBackendIfNecessary(); 251 LoadBackendIfNecessary();
256 if (history_backend_.get()) 252 if (in_memory_backend_.get())
257 return history_backend_->InMemoryIndex(); 253 return in_memory_backend_->InMemoryIndex();
258 return NULL; 254 return NULL;
259 } 255 }
260 256
261 void HistoryService::SetSegmentPresentationIndex(int64 segment_id, int index) { 257 void HistoryService::SetSegmentPresentationIndex(int64 segment_id, int index) {
262 ScheduleAndForget(PRIORITY_UI, 258 ScheduleAndForget(PRIORITY_UI,
263 &HistoryBackend::SetSegmentPresentationIndex, 259 &HistoryBackend::SetSegmentPresentationIndex,
264 segment_id, index); 260 segment_id, index);
265 } 261 }
266 262
267 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url, 263 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url,
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 796
801 NotificationService::current()->Notify(type, source, det); 797 NotificationService::current()->Notify(type, source, det);
802 } 798 }
803 799
804 void HistoryService::LoadBackendIfNecessary() { 800 void HistoryService::LoadBackendIfNecessary() {
805 if (!thread_ || history_backend_) 801 if (!thread_ || history_backend_)
806 return; // Failed to init, or already started loading. 802 return; // Failed to init, or already started loading.
807 803
808 ++current_backend_id_; 804 ++current_backend_id_;
809 scoped_refptr<HistoryBackend> backend( 805 scoped_refptr<HistoryBackend> backend(
810 new HistoryBackend(profile_, 806 new HistoryBackend(history_dir_,
811 history_dir_,
812 current_backend_id_, 807 current_backend_id_,
813 new BackendDelegate(this, profile_), 808 new BackendDelegate(this, profile_),
814 bookmark_service_)); 809 bookmark_service_));
815 history_backend_.swap(backend); 810 history_backend_.swap(backend);
816 811
817 // There may not be a profile when unit testing. 812 // There may not be a profile when unit testing.
818 std::string languages; 813 std::string languages;
819 if (profile_) { 814 if (profile_) {
820 PrefService* prefs = profile_->GetPrefs(); 815 PrefService* prefs = profile_->GetPrefs();
821 languages = prefs->GetString(prefs::kAcceptLanguages); 816 languages = prefs->GetString(prefs::kAcceptLanguages);
(...skipping 29 matching lines...) Expand all
851 history::TopSites* ts = profile_->GetTopSitesWithoutCreating(); 846 history::TopSites* ts = profile_->GetTopSitesWithoutCreating();
852 if (ts) 847 if (ts)
853 ts->MigrateFromHistory(); 848 ts->MigrateFromHistory();
854 } 849 }
855 } 850 }
856 851
857 void HistoryService::OnTopSitesReady() { 852 void HistoryService::OnTopSitesReady() {
858 ScheduleAndForget(PRIORITY_NORMAL, 853 ScheduleAndForget(PRIORITY_NORMAL,
859 &HistoryBackend::MigrateThumbnailsDatabase); 854 &HistoryBackend::MigrateThumbnailsDatabase);
860 } 855 }
OLDNEW
« no previous file with comments | « chrome/browser/history/expire_history_backend.cc ('k') | chrome/browser/history/history_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698