| OLD | NEW |
| 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 Loading... |
| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 if (in_memory_backend_.get()) | 241 if (in_memory_backend_.get()) |
| 243 return in_memory_backend_->db(); | 242 return in_memory_backend_->db(); |
| 244 return NULL; | 243 return NULL; |
| 245 } | 244 } |
| 246 | 245 |
| 247 history::InMemoryURLIndex* HistoryService::InMemoryIndex() { | 246 history::InMemoryURLIndex* HistoryService::InMemoryIndex() { |
| 248 // NOTE: See comments in BackendLoaded() as to why we call | 247 // NOTE: See comments in BackendLoaded() as to why we call |
| 249 // LoadBackendIfNecessary() here even though it won't affect the return value | 248 // LoadBackendIfNecessary() here even though it won't affect the return value |
| 250 // for this call. | 249 // for this call. |
| 251 LoadBackendIfNecessary(); | 250 LoadBackendIfNecessary(); |
| 252 if (history_backend_.get()) | 251 if (in_memory_backend_.get()) |
| 253 return history_backend_->InMemoryIndex(); | 252 return in_memory_backend_->InMemoryIndex(); |
| 254 return NULL; | 253 return NULL; |
| 255 } | 254 } |
| 256 | 255 |
| 257 void HistoryService::SetSegmentPresentationIndex(int64 segment_id, int index) { | 256 void HistoryService::SetSegmentPresentationIndex(int64 segment_id, int index) { |
| 258 ScheduleAndForget(PRIORITY_UI, | 257 ScheduleAndForget(PRIORITY_UI, |
| 259 &HistoryBackend::SetSegmentPresentationIndex, | 258 &HistoryBackend::SetSegmentPresentationIndex, |
| 260 segment_id, index); | 259 segment_id, index); |
| 261 } | 260 } |
| 262 | 261 |
| 263 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url, | 262 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url, |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 | 793 |
| 795 content::NotificationService::current()->Notify(type, source, det); | 794 content::NotificationService::current()->Notify(type, source, det); |
| 796 } | 795 } |
| 797 | 796 |
| 798 void HistoryService::LoadBackendIfNecessary() { | 797 void HistoryService::LoadBackendIfNecessary() { |
| 799 if (!thread_ || history_backend_) | 798 if (!thread_ || history_backend_) |
| 800 return; // Failed to init, or already started loading. | 799 return; // Failed to init, or already started loading. |
| 801 | 800 |
| 802 ++current_backend_id_; | 801 ++current_backend_id_; |
| 803 scoped_refptr<HistoryBackend> backend( | 802 scoped_refptr<HistoryBackend> backend( |
| 804 new HistoryBackend(profile_, | 803 new HistoryBackend(history_dir_, |
| 805 history_dir_, | |
| 806 current_backend_id_, | 804 current_backend_id_, |
| 807 new BackendDelegate(this, profile_), | 805 new BackendDelegate(this, profile_), |
| 808 bookmark_service_)); | 806 bookmark_service_)); |
| 809 history_backend_.swap(backend); | 807 history_backend_.swap(backend); |
| 810 | 808 |
| 811 // There may not be a profile when unit testing. | 809 // There may not be a profile when unit testing. |
| 812 std::string languages; | 810 std::string languages; |
| 813 if (profile_) { | 811 if (profile_) { |
| 814 PrefService* prefs = profile_->GetPrefs(); | 812 PrefService* prefs = profile_->GetPrefs(); |
| 815 languages = prefs->GetString(prefs::kAcceptLanguages); | 813 languages = prefs->GetString(prefs::kAcceptLanguages); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 846 history::TopSites* ts = profile_->GetTopSitesWithoutCreating(); | 844 history::TopSites* ts = profile_->GetTopSitesWithoutCreating(); |
| 847 if (ts) | 845 if (ts) |
| 848 ts->MigrateFromHistory(); | 846 ts->MigrateFromHistory(); |
| 849 } | 847 } |
| 850 } | 848 } |
| 851 | 849 |
| 852 void HistoryService::OnTopSitesReady() { | 850 void HistoryService::OnTopSitesReady() { |
| 853 ScheduleAndForget(PRIORITY_NORMAL, | 851 ScheduleAndForget(PRIORITY_NORMAL, |
| 854 &HistoryBackend::MigrateThumbnailsDatabase); | 852 &HistoryBackend::MigrateThumbnailsDatabase); |
| 855 } | 853 } |
| OLD | NEW |