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