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

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

Issue 8662035: Revert 111378 - HQP Refactoring (in Preparation for SQLite Cache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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_backend.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) 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
11 // ----------- -------------- 11 // ----------- --------------
12 // HistoryService <----------------> HistoryBackend 12 // HistoryService <----------------> HistoryBackend
13 // -> HistoryDatabase 13 // -> HistoryDatabase
14 // -> SQLite connection to History 14 // -> SQLite connection to History
15 // -> ArchivedDatabase 15 // -> ArchivedDatabase
16 // -> SQLite connection to Archived History 16 // -> SQLite connection to Archived History
17 // -> TextDatabaseManager 17 // -> TextDatabaseManager
18 // -> SQLite connection to one month's data 18 // -> SQLite connection to one month's data
19 // -> SQLite connection to one month's data 19 // -> SQLite connection to one month's data
20 // ... 20 // ...
21 // -> ThumbnailDatabase 21 // -> ThumbnailDatabase
22 // -> SQLite connection to Thumbnails 22 // -> SQLite connection to Thumbnails
23 // (and favicons) 23 // (and favicons)
24 24
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"
29 #include "base/memory/ref_counted.h" 28 #include "base/memory/ref_counted.h"
30 #include "base/message_loop.h" 29 #include "base/message_loop.h"
31 #include "base/path_service.h" 30 #include "base/path_service.h"
32 #include "base/string_util.h" 31 #include "base/string_util.h"
33 #include "base/task.h" 32 #include "base/task.h"
34 #include "chrome/browser/autocomplete/history_url_provider.h" 33 #include "chrome/browser/autocomplete/history_url_provider.h"
35 #include "chrome/browser/browser_process.h" 34 #include "chrome/browser/browser_process.h"
36 #include "chrome/browser/history/history_backend.h" 35 #include "chrome/browser/history/history_backend.h"
37 #include "chrome/browser/history/history_notifications.h" 36 #include "chrome/browser/history/history_notifications.h"
38 #include "chrome/browser/history/history_types.h" 37 #include "chrome/browser/history/history_types.h"
39 #include "chrome/browser/history/in_memory_database.h" 38 #include "chrome/browser/history/in_memory_database.h"
40 #include "chrome/browser/history/in_memory_history_backend.h" 39 #include "chrome/browser/history/in_memory_history_backend.h"
41 #include "chrome/browser/history/in_memory_url_index.h"
42 #include "chrome/browser/history/top_sites.h" 40 #include "chrome/browser/history/top_sites.h"
43 #include "chrome/browser/prefs/pref_service.h" 41 #include "chrome/browser/prefs/pref_service.h"
44 #include "chrome/browser/profiles/profile.h" 42 #include "chrome/browser/profiles/profile.h"
45 #include "chrome/browser/ui/profile_error_dialog.h" 43 #include "chrome/browser/ui/profile_error_dialog.h"
46 #include "chrome/browser/visitedlink/visitedlink_master.h" 44 #include "chrome/browser/visitedlink/visitedlink_master.h"
47 #include "chrome/common/chrome_constants.h" 45 #include "chrome/common/chrome_constants.h"
48 #include "chrome/common/chrome_notification_types.h" 46 #include "chrome/common/chrome_notification_types.h"
49 #include "chrome/common/chrome_switches.h"
50 #include "chrome/common/pref_names.h" 47 #include "chrome/common/pref_names.h"
51 #include "chrome/common/thumbnail_score.h" 48 #include "chrome/common/thumbnail_score.h"
52 #include "chrome/common/url_constants.h" 49 #include "chrome/common/url_constants.h"
53 #include "content/browser/download/download_persistent_store_info.h" 50 #include "content/browser/download/download_persistent_store_info.h"
54 #include "content/public/browser/browser_thread.h" 51 #include "content/public/browser/browser_thread.h"
55 #include "content/public/browser/notification_service.h" 52 #include "content/public/browser/notification_service.h"
56 #include "grit/chromium_strings.h" 53 #include "grit/chromium_strings.h"
57 #include "grit/generated_resources.h" 54 #include "grit/generated_resources.h"
58 #include "third_party/skia/include/core/SkBitmap.h" 55 #include "third_party/skia/include/core/SkBitmap.h"
59 56
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 144
148 HistoryService::HistoryService(Profile* profile) 145 HistoryService::HistoryService(Profile* profile)
149 : thread_(new base::Thread(kHistoryThreadName)), 146 : thread_(new base::Thread(kHistoryThreadName)),
150 profile_(profile), 147 profile_(profile),
151 backend_loaded_(false), 148 backend_loaded_(false),
152 current_backend_id_(-1), 149 current_backend_id_(-1),
153 bookmark_service_(NULL), 150 bookmark_service_(NULL),
154 no_db_(false), 151 no_db_(false),
155 needs_top_sites_migration_(false) { 152 needs_top_sites_migration_(false) {
156 DCHECK(profile_); 153 DCHECK(profile_);
157 if (!CommandLine::ForCurrentProcess()->HasSwitch(
158 switches::kDisableHistoryQuickProvider)) {
159 in_memory_url_index_.reset(
160 new history::InMemoryURLIndex(profile_, history_dir_));
161 std::string languages;
162 PrefService* prefs = profile_->GetPrefs();
163 languages = prefs->GetString(prefs::kAcceptLanguages);
164 in_memory_url_index_->Init(languages);
165 }
166 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, 154 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED,
167 content::Source<Profile>(profile_)); 155 content::Source<Profile>(profile_));
168 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_REMOVED, 156 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_REMOVED,
169 content::Source<Profile>(profile_)); 157 content::Source<Profile>(profile_));
170 } 158 }
171 159
172 HistoryService::~HistoryService() { 160 HistoryService::~HistoryService() {
173 // Shutdown the backend. This does nothing if Cleanup was already invoked. 161 // Shutdown the backend. This does nothing if Cleanup was already invoked.
174 Cleanup(); 162 Cleanup();
175 } 163 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 history_backend_ = NULL; 210 history_backend_ = NULL;
223 thread_->message_loop()->ReleaseSoon(FROM_HERE, raw_ptr); 211 thread_->message_loop()->ReleaseSoon(FROM_HERE, raw_ptr);
224 } 212 }
225 213
226 void HistoryService::Cleanup() { 214 void HistoryService::Cleanup() {
227 if (!thread_) { 215 if (!thread_) {
228 // We've already cleaned up. 216 // We've already cleaned up.
229 return; 217 return;
230 } 218 }
231 219
232 // Give the InMemoryURLIndex a chance to shutdown.
233 if (in_memory_url_index_.get())
234 in_memory_url_index_->ShutDown();
235
236 // Unload the backend. 220 // Unload the backend.
237 UnloadBackend(); 221 UnloadBackend();
238 222
239 // Delete the thread, which joins with the background thread. We defensively 223 // Delete the thread, which joins with the background thread. We defensively
240 // NULL the pointer before deleting it in case somebody tries to use it 224 // NULL the pointer before deleting it in case somebody tries to use it
241 // during shutdown, but this shouldn't happen. 225 // during shutdown, but this shouldn't happen.
242 base::Thread* thread = thread_; 226 base::Thread* thread = thread_;
243 thread_ = NULL; 227 thread_ = NULL;
244 delete thread; 228 delete thread;
245 } 229 }
246 230
247 void HistoryService::NotifyRenderProcessHostDestruction(const void* host) { 231 void HistoryService::NotifyRenderProcessHostDestruction(const void* host) {
248 ScheduleAndForget(PRIORITY_NORMAL, 232 ScheduleAndForget(PRIORITY_NORMAL,
249 &HistoryBackend::NotifyRenderProcessHostDestruction, host); 233 &HistoryBackend::NotifyRenderProcessHostDestruction, host);
250 } 234 }
251 235
252 history::URLDatabase* HistoryService::InMemoryDatabase() { 236 history::URLDatabase* HistoryService::InMemoryDatabase() {
253 // NOTE: See comments in BackendLoaded() as to why we call 237 // NOTE: See comments in BackendLoaded() as to why we call
254 // LoadBackendIfNecessary() here even though it won't affect the return value 238 // LoadBackendIfNecessary() here even though it won't affect the return value
255 // for this call. 239 // for this call.
256 LoadBackendIfNecessary(); 240 LoadBackendIfNecessary();
257 if (in_memory_backend_.get()) 241 if (in_memory_backend_.get())
258 return in_memory_backend_->db(); 242 return in_memory_backend_->db();
259 return NULL; 243 return NULL;
260 } 244 }
261 245
262 history::URLDatabase* HistoryService::HistoryDatabase() {
263 return history_backend_->database();
264 }
265
266 history::InMemoryURLIndex* HistoryService::InMemoryIndex() { 246 history::InMemoryURLIndex* HistoryService::InMemoryIndex() {
267 return in_memory_url_index_.get(); 247 // NOTE: See comments in BackendLoaded() as to why we call
248 // LoadBackendIfNecessary() here even though it won't affect the return value
249 // for this call.
250 LoadBackendIfNecessary();
251 if (in_memory_backend_.get())
252 return in_memory_backend_->InMemoryIndex();
253 return NULL;
268 } 254 }
269 255
270 void HistoryService::SetSegmentPresentationIndex(int64 segment_id, int index) { 256 void HistoryService::SetSegmentPresentationIndex(int64 segment_id, int index) {
271 ScheduleAndForget(PRIORITY_UI, 257 ScheduleAndForget(PRIORITY_UI,
272 &HistoryBackend::SetSegmentPresentationIndex, 258 &HistoryBackend::SetSegmentPresentationIndex,
273 segment_id, index); 259 segment_id, index);
274 } 260 }
275 261
276 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url, 262 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url,
277 TemplateURLID keyword_id, 263 TemplateURLID keyword_id,
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 history::TopSites* ts = profile_->GetTopSitesWithoutCreating(); 850 history::TopSites* ts = profile_->GetTopSitesWithoutCreating();
865 if (ts) 851 if (ts)
866 ts->MigrateFromHistory(); 852 ts->MigrateFromHistory();
867 } 853 }
868 } 854 }
869 855
870 void HistoryService::OnTopSitesReady() { 856 void HistoryService::OnTopSitesReady() {
871 ScheduleAndForget(PRIORITY_NORMAL, 857 ScheduleAndForget(PRIORITY_NORMAL,
872 &HistoryBackend::MigrateThumbnailsDatabase); 858 &HistoryBackend::MigrateThumbnailsDatabase);
873 } 859 }
OLDNEW
« no previous file with comments | « chrome/browser/history/history.h ('k') | chrome/browser/history/history_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698