| OLD | NEW |
| 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 29 matching lines...) Expand all Loading... |
| 40 #include "chrome/browser/history/web_history_service_factory.h" | 40 #include "chrome/browser/history/web_history_service_factory.h" |
| 41 #include "chrome/browser/profiles/profile.h" | 41 #include "chrome/browser/profiles/profile.h" |
| 42 #include "chrome/common/chrome_constants.h" | 42 #include "chrome/common/chrome_constants.h" |
| 43 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
| 44 #include "chrome/common/importer/imported_favicon_usage.h" | 44 #include "chrome/common/importer/imported_favicon_usage.h" |
| 45 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
| 46 #include "chrome/common/url_constants.h" | 46 #include "chrome/common/url_constants.h" |
| 47 #include "components/dom_distiller/core/url_constants.h" | 47 #include "components/dom_distiller/core/url_constants.h" |
| 48 #include "components/history/core/browser/download_row.h" | 48 #include "components/history/core/browser/download_row.h" |
| 49 #include "components/history/core/browser/history_client.h" | 49 #include "components/history/core/browser/history_client.h" |
| 50 #include "components/history/core/browser/history_database_params.h" |
| 50 #include "components/history/core/browser/history_service_observer.h" | 51 #include "components/history/core/browser/history_service_observer.h" |
| 51 #include "components/history/core/browser/history_types.h" | 52 #include "components/history/core/browser/history_types.h" |
| 52 #include "components/history/core/browser/in_memory_database.h" | 53 #include "components/history/core/browser/in_memory_database.h" |
| 53 #include "components/history/core/browser/keyword_search_term.h" | 54 #include "components/history/core/browser/keyword_search_term.h" |
| 54 #include "components/history/core/browser/visit_database.h" | 55 #include "components/history/core/browser/visit_database.h" |
| 55 #include "components/history/core/browser/visit_filter.h" | 56 #include "components/history/core/browser/visit_filter.h" |
| 56 #include "components/history/core/common/thumbnail_score.h" | 57 #include "components/history/core/common/thumbnail_score.h" |
| 57 #include "components/visitedlink/browser/visitedlink_master.h" | 58 #include "components/visitedlink/browser/visitedlink_master.h" |
| 58 #include "content/public/browser/browser_thread.h" | 59 #include "content/public/browser/browser_thread.h" |
| 59 #include "content/public/browser/download_item.h" | 60 #include "content/public/browser/download_item.h" |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 } | 985 } |
| 985 } | 986 } |
| 986 | 987 |
| 987 void HistoryService::RebuildTable( | 988 void HistoryService::RebuildTable( |
| 988 const scoped_refptr<URLEnumerator>& enumerator) { | 989 const scoped_refptr<URLEnumerator>& enumerator) { |
| 989 DCHECK(thread_) << "History service being called after cleanup"; | 990 DCHECK(thread_) << "History service being called after cleanup"; |
| 990 DCHECK(thread_checker_.CalledOnValidThread()); | 991 DCHECK(thread_checker_.CalledOnValidThread()); |
| 991 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::IterateURLs, enumerator); | 992 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::IterateURLs, enumerator); |
| 992 } | 993 } |
| 993 | 994 |
| 994 bool HistoryService::Init(const base::FilePath& history_dir, bool no_db) { | 995 bool HistoryService::Init( |
| 996 bool no_db, |
| 997 const history::HistoryDatabaseParams& history_database_params) { |
| 995 DCHECK(thread_) << "History service being called after cleanup"; | 998 DCHECK(thread_) << "History service being called after cleanup"; |
| 996 DCHECK(thread_checker_.CalledOnValidThread()); | 999 DCHECK(thread_checker_.CalledOnValidThread()); |
| 997 base::Thread::Options options; | 1000 base::Thread::Options options; |
| 998 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 1001 options.timer_slack = base::TIMER_SLACK_MAXIMUM; |
| 999 if (!thread_->StartWithOptions(options)) { | 1002 if (!thread_->StartWithOptions(options)) { |
| 1000 Cleanup(); | 1003 Cleanup(); |
| 1001 return false; | 1004 return false; |
| 1002 } | 1005 } |
| 1003 | 1006 |
| 1004 history_dir_ = history_dir; | 1007 history_dir_ = history_database_params.history_dir; |
| 1005 no_db_ = no_db; | 1008 no_db_ = no_db; |
| 1006 | 1009 |
| 1007 if (profile_) { | 1010 if (profile_) { |
| 1008 std::string languages = | 1011 std::string languages = |
| 1009 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); | 1012 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); |
| 1010 in_memory_url_index_.reset(new history::InMemoryURLIndex( | 1013 in_memory_url_index_.reset(new history::InMemoryURLIndex( |
| 1011 profile_, this, history_dir_, languages, history_client_)); | 1014 profile_, this, history_dir_, languages, history_client_)); |
| 1012 in_memory_url_index_->Init(); | 1015 in_memory_url_index_->Init(); |
| 1013 } | 1016 } |
| 1014 | 1017 |
| 1015 // Create the history backend. | 1018 // Create the history backend. |
| 1016 scoped_refptr<HistoryBackend> backend( | 1019 scoped_refptr<HistoryBackend> backend( |
| 1017 new HistoryBackend(history_dir_, | 1020 new HistoryBackend(history_dir_, |
| 1018 new BackendDelegate( | 1021 new BackendDelegate( |
| 1019 weak_ptr_factory_.GetWeakPtr(), | 1022 weak_ptr_factory_.GetWeakPtr(), |
| 1020 base::ThreadTaskRunnerHandle::Get(), | 1023 base::ThreadTaskRunnerHandle::Get(), |
| 1021 profile_), | 1024 profile_), |
| 1022 history_client_)); | 1025 history_client_)); |
| 1023 history_backend_.swap(backend); | 1026 history_backend_.swap(backend); |
| 1024 | 1027 |
| 1025 // There may not be a profile when unit testing. | 1028 // There may not be a profile when unit testing. |
| 1026 std::string languages; | 1029 std::string languages; |
| 1027 if (profile_) { | 1030 if (profile_) { |
| 1028 PrefService* prefs = profile_->GetPrefs(); | 1031 PrefService* prefs = profile_->GetPrefs(); |
| 1029 languages = prefs->GetString(prefs::kAcceptLanguages); | 1032 languages = prefs->GetString(prefs::kAcceptLanguages); |
| 1030 } | 1033 } |
| 1031 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::Init, languages, no_db_); | 1034 |
| 1035 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::Init, languages, no_db_, |
| 1036 history_database_params); |
| 1032 | 1037 |
| 1033 if (visitedlink_master_) { | 1038 if (visitedlink_master_) { |
| 1034 bool result = visitedlink_master_->Init(); | 1039 bool result = visitedlink_master_->Init(); |
| 1035 DCHECK(result); | 1040 DCHECK(result); |
| 1036 } | 1041 } |
| 1037 | 1042 |
| 1038 return true; | 1043 return true; |
| 1039 } | 1044 } |
| 1040 | 1045 |
| 1041 void HistoryService::ScheduleAutocomplete(const base::Callback< | 1046 void HistoryService::ScheduleAutocomplete(const base::Callback< |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 const HistoryService::OnFaviconChangedCallback& callback) { | 1307 const HistoryService::OnFaviconChangedCallback& callback) { |
| 1303 DCHECK(thread_checker_.CalledOnValidThread()); | 1308 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1304 return favicon_changed_callback_list_.Add(callback); | 1309 return favicon_changed_callback_list_.Add(callback); |
| 1305 } | 1310 } |
| 1306 | 1311 |
| 1307 void HistoryService::NotifyFaviconChanged( | 1312 void HistoryService::NotifyFaviconChanged( |
| 1308 const std::set<GURL>& changed_favicons) { | 1313 const std::set<GURL>& changed_favicons) { |
| 1309 DCHECK(thread_checker_.CalledOnValidThread()); | 1314 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1310 favicon_changed_callback_list_.Notify(changed_favicons); | 1315 favicon_changed_callback_list_.Notify(changed_favicons); |
| 1311 } | 1316 } |
| OLD | NEW |