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 #include "chrome/browser/browser_process_impl.h" | 5 #include "chrome/browser/browser_process_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // Linux. We have a timeout here because we're unable to run the UI messageloop | 126 // Linux. We have a timeout here because we're unable to run the UI messageloop |
127 // and there's some deadlock risk. Our only option is to exit anyway. | 127 // and there's some deadlock risk. Our only option is to exit anyway. |
128 static const int kEndSessionTimeoutSeconds = 10; | 128 static const int kEndSessionTimeoutSeconds = 10; |
129 #endif | 129 #endif |
130 | 130 |
131 using content::BrowserThread; | 131 using content::BrowserThread; |
132 using content::ChildProcessSecurityPolicy; | 132 using content::ChildProcessSecurityPolicy; |
133 using content::PluginService; | 133 using content::PluginService; |
134 using content::ResourceDispatcherHost; | 134 using content::ResourceDispatcherHost; |
135 | 135 |
136 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) | 136 BrowserProcessImpl::BrowserProcessImpl( |
| 137 base::SequencedTaskRunner* local_state_task_runner, |
| 138 const CommandLine& command_line) |
137 : created_metrics_service_(false), | 139 : created_metrics_service_(false), |
138 created_watchdog_thread_(false), | 140 created_watchdog_thread_(false), |
139 created_browser_policy_connector_(false), | 141 created_browser_policy_connector_(false), |
140 created_profile_manager_(false), | 142 created_profile_manager_(false), |
141 created_local_state_(false), | 143 created_local_state_(false), |
142 created_icon_manager_(false), | 144 created_icon_manager_(false), |
143 created_notification_ui_manager_(false), | 145 created_notification_ui_manager_(false), |
144 created_safe_browsing_service_(false), | 146 created_safe_browsing_service_(false), |
145 module_ref_count_(0), | 147 module_ref_count_(0), |
146 did_start_(false), | 148 did_start_(false), |
147 checked_for_new_frames_(false), | 149 checked_for_new_frames_(false), |
148 using_new_frames_(false), | 150 using_new_frames_(false), |
149 render_widget_snapshot_taker_(new RenderWidgetSnapshotTaker), | 151 render_widget_snapshot_taker_(new RenderWidgetSnapshotTaker), |
150 download_status_updater_(new DownloadStatusUpdater) { | 152 download_status_updater_(new DownloadStatusUpdater), |
| 153 local_state_task_runner_(local_state_task_runner) { |
151 g_browser_process = this; | 154 g_browser_process = this; |
152 | 155 |
153 #if defined(ENABLE_PRINTING) | 156 #if defined(ENABLE_PRINTING) |
154 // Must be created after the NotificationService. | 157 // Must be created after the NotificationService. |
155 print_job_manager_.reset(new printing::PrintJobManager); | 158 print_job_manager_.reset(new printing::PrintJobManager); |
156 #endif | 159 #endif |
157 | 160 |
158 net_log_.reset(new ChromeNetLog); | 161 net_log_.reset(new ChromeNetLog); |
159 | 162 |
160 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( | 163 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 FilePath user_data_dir; | 705 FilePath user_data_dir; |
703 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 706 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
704 profile_manager_.reset(new ProfileManager(user_data_dir)); | 707 profile_manager_.reset(new ProfileManager(user_data_dir)); |
705 } | 708 } |
706 | 709 |
707 void BrowserProcessImpl::CreateLocalState() { | 710 void BrowserProcessImpl::CreateLocalState() { |
708 DCHECK(!created_local_state_ && local_state_.get() == NULL); | 711 DCHECK(!created_local_state_ && local_state_.get() == NULL); |
709 created_local_state_ = true; | 712 created_local_state_ = true; |
710 | 713 |
711 FilePath local_state_path; | 714 FilePath local_state_path; |
712 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 715 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path)); |
713 local_state_.reset( | 716 local_state_.reset( |
714 PrefService::CreatePrefService(local_state_path, policy_service(), NULL, | 717 PrefService::CreatePrefService(local_state_path, local_state_task_runner_, |
715 false)); | 718 policy_service(), NULL, false)); |
716 | 719 |
717 // Initialize the prefs of the local state. | 720 // Initialize the prefs of the local state. |
718 chrome::RegisterLocalState(local_state_.get()); | 721 chrome::RegisterLocalState(local_state_.get()); |
719 | 722 |
720 pref_change_registrar_.Init(local_state_.get()); | 723 pref_change_registrar_.Init(local_state_.get()); |
721 | 724 |
722 // Initialize the notification for the default browser setting policy. | 725 // Initialize the notification for the default browser setting policy. |
723 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, | 726 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, |
724 false); | 727 false); |
725 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); | 728 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 } | 946 } |
944 | 947 |
945 void BrowserProcessImpl::OnAutoupdateTimer() { | 948 void BrowserProcessImpl::OnAutoupdateTimer() { |
946 if (CanAutorestartForUpdate()) { | 949 if (CanAutorestartForUpdate()) { |
947 DLOG(WARNING) << "Detected update. Restarting browser."; | 950 DLOG(WARNING) << "Detected update. Restarting browser."; |
948 RestartBackgroundInstance(); | 951 RestartBackgroundInstance(); |
949 } | 952 } |
950 } | 953 } |
951 | 954 |
952 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 955 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |