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 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" | 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer = | 81 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer = |
82 LAZY_INSTANCE_INITIALIZER; | 82 LAZY_INSTANCE_INITIALIZER; |
83 | 83 |
84 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( | 84 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( |
85 const content::MainFunctionParams& parameters) | 85 const content::MainFunctionParams& parameters) |
86 : ChromeBrowserMainPartsLinux(parameters) { | 86 : ChromeBrowserMainPartsLinux(parameters) { |
87 } | 87 } |
88 | 88 |
89 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { | 89 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { |
| 90 // Shutdown the upgrade detector for Chrome OS. The upgrade detector |
| 91 // stops monitoring changes from the update engine. |
| 92 if (UpgradeDetectorChromeos::GetInstance()) |
| 93 UpgradeDetectorChromeos::GetInstance()->Shutdown(); |
| 94 |
| 95 // Shutdown the network change notifier for Chrome OS. The network |
| 96 // change notifier stops monitoring changes from the power manager and |
| 97 // the network manager. |
| 98 if (chromeos::CrosNetworkChangeNotifierFactory::GetInstance()) |
| 99 chromeos::CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); |
| 100 |
90 chromeos::disks::DiskMountManager::Shutdown(); | 101 chromeos::disks::DiskMountManager::Shutdown(); |
91 | 102 |
92 chromeos::BluetoothManager::Shutdown(); | 103 chromeos::BluetoothManager::Shutdown(); |
93 | 104 |
| 105 // We should remove observers attached to D-Bus clients before |
| 106 // DBusThreadManager is shut down. |
| 107 if (session_manager_observer_.get()) { |
| 108 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 109 RemoveObserver(session_manager_observer_.get()); |
| 110 } |
| 111 if (brightness_observer_.get()) { |
| 112 chromeos::DBusThreadManager::Get()->GetPowerManagerClient() |
| 113 ->RemoveObserver(brightness_observer_.get()); |
| 114 } |
| 115 |
94 chromeos::DBusThreadManager::Shutdown(); | 116 chromeos::DBusThreadManager::Shutdown(); |
95 | 117 |
96 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) | 118 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) |
97 chromeos::CrosLibrary::Shutdown(); | 119 chromeos::CrosLibrary::Shutdown(); |
98 | 120 |
99 // To be precise, logout (browser shutdown) is not yet done, but the | 121 // To be precise, logout (browser shutdown) is not yet done, but the |
100 // remaining work is negligible, hence we say LogoutDone here. | 122 // remaining work is negligible, hence we say LogoutDone here. |
101 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 123 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
102 false); | 124 false); |
103 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 125 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // parsed command line until after about_flags::ConvertFlagsToSwitches has | 162 // parsed command line until after about_flags::ConvertFlagsToSwitches has |
141 // been called. | 163 // been called. |
142 // TODO(vlaviano): Move this back to PostMainMessageLoopStart when we remove | 164 // TODO(vlaviano): Move this back to PostMainMessageLoopStart when we remove |
143 // the --enable-bluetooth flag. | 165 // the --enable-bluetooth flag. |
144 if (parsed_command_line().HasSwitch(switches::kEnableBluetooth)) { | 166 if (parsed_command_line().HasSwitch(switches::kEnableBluetooth)) { |
145 chromeos::BluetoothManager::Initialize(); | 167 chromeos::BluetoothManager::Initialize(); |
146 } | 168 } |
147 } | 169 } |
148 | 170 |
149 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 171 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
150 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); | 172 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); |
151 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 173 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
152 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 174 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
153 | 175 |
154 // Initialize DBusThreadManager for the browser. This must be done after | 176 // Initialize DBusThreadManager for the browser. This must be done after |
155 // the main message loop is started, as it uses the message loop. | 177 // the main message loop is started, as it uses the message loop. |
156 chromeos::DBusThreadManager::Initialize(); | 178 chromeos::DBusThreadManager::Initialize(); |
157 | 179 |
158 // Initialize the brightness observer so that we'll display an onscreen | 180 // Initialize the brightness observer so that we'll display an onscreen |
159 // indication of brightness changes during login. | 181 // indication of brightness changes during login. |
160 brightness_observer_.reset(new chromeos::BrightnessObserver()); | 182 brightness_observer_.reset(new chromeos::BrightnessObserver()); |
(...skipping 22 matching lines...) Expand all Loading... |
183 // Enable Num Lock on X start up. | 205 // Enable Num Lock on X start up. |
184 chromeos::input_method::InputMethodManager::GetInstance()-> | 206 chromeos::input_method::InputMethodManager::GetInstance()-> |
185 GetXKeyboard()->SetNumLockEnabled(true); | 207 GetXKeyboard()->SetNumLockEnabled(true); |
186 | 208 |
187 #if defined(USE_AURA) | 209 #if defined(USE_AURA) |
188 initial_browser_window_observer_.reset( | 210 initial_browser_window_observer_.reset( |
189 new chromeos::InitialBrowserWindowObserver); | 211 new chromeos::InitialBrowserWindowObserver); |
190 #endif | 212 #endif |
191 } | 213 } |
192 } | 214 } |
193 | |
194 // Shut down services before the browser process, etc are destroyed. | |
195 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { | |
196 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); | |
197 | |
198 // Shutdown the upgrade detector for Chrome OS. The upgrade detector | |
199 // stops monitoring changes from the update engine. | |
200 if (UpgradeDetectorChromeos::GetInstance()) | |
201 UpgradeDetectorChromeos::GetInstance()->Shutdown(); | |
202 | |
203 // Shutdown the network change notifier for Chrome OS. The network | |
204 // change notifier stops monitoring changes from the power manager and | |
205 // the network manager. | |
206 if (chromeos::CrosNetworkChangeNotifierFactory::GetInstance()) | |
207 chromeos::CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); | |
208 | |
209 // We should remove observers attached to D-Bus clients before | |
210 // DBusThreadManager is shut down. | |
211 if (session_manager_observer_.get()) { | |
212 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | |
213 RemoveObserver(session_manager_observer_.get()); | |
214 } | |
215 if (brightness_observer_.get()) { | |
216 chromeos::DBusThreadManager::Get()->GetPowerManagerClient() | |
217 ->RemoveObserver(brightness_observer_.get()); | |
218 } | |
219 } | |
OLD | NEW |