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 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 // Delete the thread, which joins with the background thread. We defensively | 880 // Delete the thread, which joins with the background thread. We defensively |
881 // nullptr the pointer before deleting it in case somebody tries to use it | 881 // nullptr the pointer before deleting it in case somebody tries to use it |
882 // during shutdown, but this shouldn't happen. | 882 // during shutdown, but this shouldn't happen. |
883 base::Thread* thread = thread_; | 883 base::Thread* thread = thread_; |
884 thread_ = nullptr; | 884 thread_ = nullptr; |
885 delete thread; | 885 delete thread; |
886 } | 886 } |
887 | 887 |
888 bool HistoryService::Init( | 888 bool HistoryService::Init( |
889 bool no_db, | 889 bool no_db, |
890 const std::string& languages, | |
891 const HistoryDatabaseParams& history_database_params) { | 890 const HistoryDatabaseParams& history_database_params) { |
892 TRACE_EVENT0("browser,startup", "HistoryService::Init") | 891 TRACE_EVENT0("browser,startup", "HistoryService::Init") |
893 SCOPED_UMA_HISTOGRAM_TIMER("History.HistoryServiceInitTime"); | 892 SCOPED_UMA_HISTOGRAM_TIMER("History.HistoryServiceInitTime"); |
894 DCHECK(thread_) << "History service being called after cleanup"; | 893 DCHECK(thread_) << "History service being called after cleanup"; |
895 DCHECK(thread_checker_.CalledOnValidThread()); | 894 DCHECK(thread_checker_.CalledOnValidThread()); |
896 | 895 |
897 base::Thread::Options options; | 896 base::Thread::Options options; |
898 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 897 options.timer_slack = base::TIMER_SLACK_MAXIMUM; |
899 if (!thread_->StartWithOptions(options)) { | 898 if (!thread_->StartWithOptions(options)) { |
900 Cleanup(); | 899 Cleanup(); |
901 return false; | 900 return false; |
902 } | 901 } |
903 | 902 |
904 // Create the history backend. | 903 // Create the history backend. |
905 scoped_refptr<HistoryBackend> backend(new HistoryBackend( | 904 scoped_refptr<HistoryBackend> backend(new HistoryBackend( |
906 new BackendDelegate(weak_ptr_factory_.GetWeakPtr(), | 905 new BackendDelegate(weak_ptr_factory_.GetWeakPtr(), |
907 base::ThreadTaskRunnerHandle::Get()), | 906 base::ThreadTaskRunnerHandle::Get()), |
908 history_client_ ? history_client_->CreateBackendClient() : nullptr, | 907 history_client_ ? history_client_->CreateBackendClient() : nullptr, |
909 thread_->task_runner())); | 908 thread_->task_runner())); |
910 history_backend_.swap(backend); | 909 history_backend_.swap(backend); |
911 | 910 |
912 ScheduleTask(PRIORITY_UI, | 911 ScheduleTask(PRIORITY_UI, |
913 base::Bind(&HistoryBackend::Init, history_backend_.get(), | 912 base::Bind(&HistoryBackend::Init, history_backend_.get(), |
914 languages, no_db, history_database_params)); | 913 no_db, history_database_params)); |
915 | 914 |
916 if (visit_delegate_ && !visit_delegate_->Init(this)) | 915 if (visit_delegate_ && !visit_delegate_->Init(this)) |
917 return false; | 916 return false; |
918 | 917 |
919 if (history_client_) | 918 if (history_client_) |
920 history_client_->OnHistoryServiceCreated(this); | 919 history_client_->OnHistoryServiceCreated(this); |
921 | 920 |
922 return true; | 921 return true; |
923 } | 922 } |
924 | 923 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 return favicon_changed_callback_list_.Add(callback); | 1164 return favicon_changed_callback_list_.Add(callback); |
1166 } | 1165 } |
1167 | 1166 |
1168 void HistoryService::NotifyFaviconsChanged(const std::set<GURL>& page_urls, | 1167 void HistoryService::NotifyFaviconsChanged(const std::set<GURL>& page_urls, |
1169 const GURL& icon_url) { | 1168 const GURL& icon_url) { |
1170 DCHECK(thread_checker_.CalledOnValidThread()); | 1169 DCHECK(thread_checker_.CalledOnValidThread()); |
1171 favicon_changed_callback_list_.Notify(page_urls, icon_url); | 1170 favicon_changed_callback_list_.Notify(page_urls, icon_url); |
1172 } | 1171 } |
1173 | 1172 |
1174 } // namespace history | 1173 } // namespace history |
OLD | NEW |