summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 11:08:29 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 11:08:29 +0000
commit73f5abaed7c1e90f5bf0066d69397c696daa913f (patch)
tree0654b23347c506f6bf981b57345bc65280042b64 /chrome/browser/chromeos/chrome_browser_main_chromeos.cc
parent9cedbde9594a910505cf64e34a210c014e4e9cb2 (diff)
downloadchromium_src-73f5abaed7c1e90f5bf0066d69397c696daa913f.zip
chromium_src-73f5abaed7c1e90f5bf0066d69397c696daa913f.tar.gz
chromium_src-73f5abaed7c1e90f5bf0066d69397c696daa913f.tar.bz2
Call AddObserver/RemoveObserver in observers' ctors/dtors
To make chrome_browser_main_chromeos.cc small. BUG=None TEST=None Review URL: http://codereview.chromium.org/9225015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119884 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/chrome_browser_main_chromeos.cc')
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.cc23
1 files changed, 5 insertions, 18 deletions
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index 6ab7b05..8edfe74 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -275,20 +275,14 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() {
// Initialize the brightness observer so that we'll display an onscreen
// indication of brightness changes during login.
brightness_observer_.reset(new chromeos::BrightnessObserver());
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
- brightness_observer_.get());
resume_observer_.reset(new chromeos::ResumeObserver());
screen_lock_observer_.reset(new chromeos::ScreenLockObserver());
// Initialize the session manager observer so that we'll take actions
// per signals sent from the session manager.
session_manager_observer_.reset(new chromeos::SessionManagerObserver);
- chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
- AddObserver(session_manager_observer_.get());
- // Initialize the disk mount manager.
chromeos::disks::DiskMountManager::Initialize();
- // Initialize the burn manager.
chromeos::imageburner::BurnManager::Initialize();
// Initialize the network change notifier for Chrome OS. The network
@@ -323,7 +317,6 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() {
// Threads are initialized MainMessageLoopStart and MainMessageLoopRun.
void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
- // Initialize the audio handler on ChromeOS.
chromeos::AudioHandler::Initialize();
// Listen for system key events so that the user will be able to adjust the
@@ -467,9 +460,6 @@ void ChromeBrowserMainPartsChromeos::PostBrowserStart() {
// These are dependent on the ash::Shell singleton already having been
// initialized.
power_button_observer_.reset(new chromeos::PowerButtonObserver);
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
- power_button_observer_.get());
-
video_property_writer_.reset(new chromeos::VideoPropertyWriter);
#endif
@@ -496,16 +486,10 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
// We should remove observers attached to D-Bus clients before
// DBusThreadManager is shut down.
- if (session_manager_observer_.get()) {
- chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
- RemoveObserver(session_manager_observer_.get());
- }
+ session_manager_observer_.reset();
screen_lock_observer_.reset();
resume_observer_.reset();
- if (brightness_observer_.get()) {
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()
- ->RemoveObserver(brightness_observer_.get());
- }
+ brightness_observer_.reset();
// Shut these down here instead of in the destructor in case we exited before
// running BrowserMainLoop::RunMainMessageLoopParts() and never initialized
@@ -527,6 +511,9 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
// Let VideoPropertyWriter unregister itself as an observer of the ash::Shell
// singleton before the shell is destroyed.
video_property_writer_.reset();
+ // Remove PowerButtonObserver attached to a D-Bus client before
+ // DBusThreadManager is shut down.
+ power_button_observer_.reset();
#endif
ChromeBrowserMainPartsLinux::PostMainMessageLoopRun();