| 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" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "chrome/browser/chromeos/boot_times_loader.h" | 12 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 13 #include "chrome/browser/chromeos/brightness_observer.h" |
| 13 #include "chrome/browser/chromeos/cros/cros_library.h" | 14 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 14 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 15 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 15 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" | 16 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" |
| 16 #include "chrome/browser/chromeos/system/statistics_provider.h" | 17 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 17 #include "chrome/browser/defaults.h" | 18 #include "chrome/browser/defaults.h" |
| 18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 19 #include "content/common/main_function_params.h" | 20 #include "content/common/main_function_params.h" |
| 20 #include "net/base/network_change_notifier.h" | 21 #include "net/base/network_change_notifier.h" |
| 21 | 22 |
| 22 #if defined(TOOLKIT_USES_GTK) | 23 #if defined(TOOLKIT_USES_GTK) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 66 |
| 66 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer( | 67 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer( |
| 67 base::LINKER_INITIALIZED); | 68 base::LINKER_INITIALIZED); |
| 68 | 69 |
| 69 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( | 70 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( |
| 70 const MainFunctionParams& parameters) | 71 const MainFunctionParams& parameters) |
| 71 : ChromeBrowserMainPartsBase(parameters) { | 72 : ChromeBrowserMainPartsBase(parameters) { |
| 72 } | 73 } |
| 73 | 74 |
| 74 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { | 75 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { |
| 76 // We should remove observers attached to D-Bus clients before |
| 77 // DBusThreadManager is shut down. |
| 78 chromeos::DBusThreadManager::Get()->power_manager_client()->RemoveObserver( |
| 79 brightness_observer_.get()); |
| 80 |
| 75 chromeos::DBusThreadManager::Shutdown(); | 81 chromeos::DBusThreadManager::Shutdown(); |
| 76 | 82 |
| 77 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) | 83 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) |
| 78 chromeos::CrosLibrary::Shutdown(); | 84 chromeos::CrosLibrary::Shutdown(); |
| 79 | 85 |
| 80 // To be precise, logout (browser shutdown) is not yet done, but the | 86 // To be precise, logout (browser shutdown) is not yet done, but the |
| 81 // remaining work is negligible, hence we say LogoutDone here. | 87 // remaining work is negligible, hence we say LogoutDone here. |
| 82 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 88 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
| 83 false); | 89 false); |
| 84 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 90 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 124 } |
| 119 | 125 |
| 120 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 126 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
| 121 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); | 127 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); |
| 122 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 128 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
| 123 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 129 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
| 124 | 130 |
| 125 // Initialize DBusThreadManager for the browser. This must be done after | 131 // Initialize DBusThreadManager for the browser. This must be done after |
| 126 // the main message loop is started, as it uses the message loop. | 132 // the main message loop is started, as it uses the message loop. |
| 127 chromeos::DBusThreadManager::Initialize(); | 133 chromeos::DBusThreadManager::Initialize(); |
| 134 |
| 135 // Initialize the brightness observer so that we'll display an onscreen |
| 136 // indication of brightness changes during login. |
| 137 brightness_observer_.reset(new chromeos::BrightnessObserver()); |
| 138 chromeos::DBusThreadManager::Get()->power_manager_client()->AddObserver( |
| 139 brightness_observer_.get()); |
| 128 } | 140 } |
| OLD | NEW |