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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/debug/alias.h" | 15 #include "base/debug/alias.h" |
16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
19 #include "base/threading/sequenced_worker_pool.h" | |
akalin
2012/10/19 02:00:51
not needed anymore
zel
2012/10/19 18:45:07
Done.
| |
19 #include "base/threading/thread.h" | 20 #include "base/threading/thread.h" |
20 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
21 #include "chrome/browser/automation/automation_provider_list.h" | 22 #include "chrome/browser/automation/automation_provider_list.h" |
22 #include "chrome/browser/background/background_mode_manager.h" | 23 #include "chrome/browser/background/background_mode_manager.h" |
23 #include "chrome/browser/chrome_browser_main.h" | 24 #include "chrome/browser/chrome_browser_main.h" |
24 #include "chrome/browser/chrome_content_browser_client.h" | 25 #include "chrome/browser/chrome_content_browser_client.h" |
25 #include "chrome/browser/chrome_plugin_service_filter.h" | 26 #include "chrome/browser/chrome_plugin_service_filter.h" |
26 #include "chrome/browser/component_updater/component_updater_configurator.h" | 27 #include "chrome/browser/component_updater/component_updater_configurator.h" |
27 #include "chrome/browser/component_updater/component_updater_service.h" | 28 #include "chrome/browser/component_updater/component_updater_service.h" |
28 #include "chrome/browser/debugger/remote_debugging_server.h" | 29 #include "chrome/browser/debugger/remote_debugging_server.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 // Linux. We have a timeout here because we're unable to run the UI messageloop | 125 // Linux. We have a timeout here because we're unable to run the UI messageloop |
125 // and there's some deadlock risk. Our only option is to exit anyway. | 126 // and there's some deadlock risk. Our only option is to exit anyway. |
126 static const int kEndSessionTimeoutSeconds = 10; | 127 static const int kEndSessionTimeoutSeconds = 10; |
127 #endif | 128 #endif |
128 | 129 |
129 using content::BrowserThread; | 130 using content::BrowserThread; |
130 using content::ChildProcessSecurityPolicy; | 131 using content::ChildProcessSecurityPolicy; |
131 using content::PluginService; | 132 using content::PluginService; |
132 using content::ResourceDispatcherHost; | 133 using content::ResourceDispatcherHost; |
133 | 134 |
134 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) | 135 BrowserProcessImpl::BrowserProcessImpl( |
136 base::SequencedTaskRunner* local_state_task_runner, | |
137 const CommandLine& command_line) | |
135 : created_metrics_service_(false), | 138 : created_metrics_service_(false), |
136 created_watchdog_thread_(false), | 139 created_watchdog_thread_(false), |
137 created_browser_policy_connector_(false), | 140 created_browser_policy_connector_(false), |
138 created_profile_manager_(false), | 141 created_profile_manager_(false), |
139 created_local_state_(false), | 142 created_local_state_(false), |
140 created_icon_manager_(false), | 143 created_icon_manager_(false), |
141 created_notification_ui_manager_(false), | 144 created_notification_ui_manager_(false), |
142 created_safe_browsing_service_(false), | 145 created_safe_browsing_service_(false), |
143 module_ref_count_(0), | 146 module_ref_count_(0), |
144 did_start_(false), | 147 did_start_(false), |
145 checked_for_new_frames_(false), | 148 checked_for_new_frames_(false), |
146 using_new_frames_(false), | 149 using_new_frames_(false), |
147 render_widget_snapshot_taker_(new RenderWidgetSnapshotTaker), | 150 render_widget_snapshot_taker_(new RenderWidgetSnapshotTaker), |
148 download_status_updater_(new DownloadStatusUpdater) { | 151 download_status_updater_(new DownloadStatusUpdater), |
152 local_state_task_runner_(local_state_task_runner) { | |
149 g_browser_process = this; | 153 g_browser_process = this; |
150 | 154 |
151 #if defined(ENABLE_PRINTING) | 155 #if defined(ENABLE_PRINTING) |
152 // Must be created after the NotificationService. | 156 // Must be created after the NotificationService. |
153 print_job_manager_.reset(new printing::PrintJobManager); | 157 print_job_manager_.reset(new printing::PrintJobManager); |
154 #endif | 158 #endif |
155 | 159 |
156 net_log_.reset(new ChromeNetLog); | 160 net_log_.reset(new ChromeNetLog); |
157 | 161 |
158 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( | 162 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 } | 712 } |
709 | 713 |
710 void BrowserProcessImpl::CreateLocalState() { | 714 void BrowserProcessImpl::CreateLocalState() { |
711 DCHECK(!created_local_state_ && local_state_.get() == NULL); | 715 DCHECK(!created_local_state_ && local_state_.get() == NULL); |
712 created_local_state_ = true; | 716 created_local_state_ = true; |
713 | 717 |
714 FilePath local_state_path; | 718 FilePath local_state_path; |
715 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 719 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
716 local_state_.reset( | 720 local_state_.reset( |
717 PrefService::CreatePrefService(local_state_path, policy_service(), NULL, | 721 PrefService::CreatePrefService(local_state_path, policy_service(), NULL, |
718 false)); | 722 false, local_state_task_runner_)); |
719 | 723 |
720 // Initialize the prefs of the local state. | 724 // Initialize the prefs of the local state. |
721 chrome::RegisterLocalState(local_state_.get()); | 725 chrome::RegisterLocalState(local_state_.get()); |
722 | 726 |
723 pref_change_registrar_.Init(local_state_.get()); | 727 pref_change_registrar_.Init(local_state_.get()); |
724 | 728 |
725 // Initialize the notification for the default browser setting policy. | 729 // Initialize the notification for the default browser setting policy. |
726 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, | 730 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, |
727 false); | 731 false); |
728 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); | 732 pref_change_registrar_.Add(prefs::kDefaultBrowserSettingEnabled, this); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
949 } | 953 } |
950 | 954 |
951 void BrowserProcessImpl::OnAutoupdateTimer() { | 955 void BrowserProcessImpl::OnAutoupdateTimer() { |
952 if (CanAutorestartForUpdate()) { | 956 if (CanAutorestartForUpdate()) { |
953 DLOG(WARNING) << "Detected update. Restarting browser."; | 957 DLOG(WARNING) << "Detected update. Restarting browser."; |
954 RestartBackgroundInstance(); | 958 RestartBackgroundInstance(); |
955 } | 959 } |
956 } | 960 } |
957 | 961 |
958 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 962 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |