diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-01 17:59:38 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-01 17:59:38 +0000 |
commit | 4d9ae4ab9dd6d4f27c5cef5481f41979b3d58d1b (patch) | |
tree | 9978d5c639d3906ce700cc687170a6800243001b /chrome/browser | |
parent | 09d38ad48a2273d2e677e78d4828fa2c8bc65797 (diff) | |
download | chromium_src-4d9ae4ab9dd6d4f27c5cef5481f41979b3d58d1b.zip chromium_src-4d9ae4ab9dd6d4f27c5cef5481f41979b3d58d1b.tar.gz chromium_src-4d9ae4ab9dd6d4f27c5cef5481f41979b3d58d1b.tar.bz2 |
Simplify the PowerObserver API by removing unneeded args and providing default implementations.
This also makes all the subclasses use the same code to add/remove observers.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/244054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27740 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/profile_manager.cc | 16 | ||||
-rw-r--r-- | chrome/browser/profile_manager.h | 7 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_service.cc | 18 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_service.h | 6 |
4 files changed, 18 insertions, 29 deletions
diff --git a/chrome/browser/profile_manager.cc b/chrome/browser/profile_manager.cc index c25322a..b24b7b2 100644 --- a/chrome/browser/profile_manager.cc +++ b/chrome/browser/profile_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -41,15 +41,13 @@ void ProfileManager::ShutdownSessionServices() { } ProfileManager::ProfileManager() { - base::SystemMonitor* monitor = base::SystemMonitor::Get(); - if (monitor) - monitor->AddObserver(this); + base::SystemMonitor::Get()->AddObserver(this); } ProfileManager::~ProfileManager() { - base::SystemMonitor* monitor = base::SystemMonitor::Get(); - if (monitor) - monitor->RemoveObserver(this); + base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); + if (system_monitor) + system_monitor->RemoveObserver(this); // Destroy all profiles that we're keeping track of. for (ProfileVector::const_iterator iter = profiles_.begin(); @@ -227,7 +225,7 @@ Profile* ProfileManager::GetProfileByID(const std::wstring& id) const { return NULL; } -void ProfileManager::OnSuspend(base::SystemMonitor* monitor) { +void ProfileManager::OnSuspend() { DCHECK(CalledOnValidThread()); ProfileManager::const_iterator it = begin(); @@ -238,7 +236,7 @@ void ProfileManager::OnSuspend(base::SystemMonitor* monitor) { } } -void ProfileManager::OnResume(base::SystemMonitor* monitor) { +void ProfileManager::OnResume() { DCHECK(CalledOnValidThread()); ProfileManager::const_iterator it = begin(); while (it != end()) { diff --git a/chrome/browser/profile_manager.h b/chrome/browser/profile_manager.h index 466fb2f..56b9998 100644 --- a/chrome/browser/profile_manager.h +++ b/chrome/browser/profile_manager.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -129,9 +129,8 @@ class ProfileManager : public NonThreadSafe, void NewWindowWithProfile(Profile* profile); // PowerObserver notifications - void OnPowerStateChange(base::SystemMonitor*) {} - void OnSuspend(base::SystemMonitor*); - void OnResume(base::SystemMonitor*); + void OnSuspend(); + void OnResume(); // ------------------ static utility functions ------------------- diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index d3d0920..834d1cc 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -38,16 +38,13 @@ SafeBrowsingService::SafeBrowsingService() resetting_(false), database_loaded_(false), update_in_progress_(false) { - base::SystemMonitor* monitor = base::SystemMonitor::Get(); - DCHECK(monitor); - if (monitor) - monitor->AddObserver(this); + base::SystemMonitor::Get()->AddObserver(this); } SafeBrowsingService::~SafeBrowsingService() { - base::SystemMonitor* monitor = base::SystemMonitor::Get(); - if (monitor) - monitor->RemoveObserver(this); + base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); + if (system_monitor) + system_monitor->RemoveObserver(this); } // Only called on the UI thread. @@ -663,14 +660,11 @@ void SafeBrowsingService::CacheHashResults( GetDatabase()->CacheHashResults(prefixes, full_hashes); } -void SafeBrowsingService::OnSuspend(base::SystemMonitor*) { -} - // Tell the SafeBrowsing database not to do expensive disk operations for a few // minutes after waking up. It's quite likely that the act of resuming from a // low power state will involve much disk activity, which we don't want to // exacerbate. -void SafeBrowsingService::OnResume(base::SystemMonitor*) { +void SafeBrowsingService::OnResume() { if (enabled_) { safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, &SafeBrowsingService::HandleResume)); diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h index cc5651f..76b7f8c 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.h +++ b/chrome/browser/safe_browsing/safe_browsing_service.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -169,9 +169,7 @@ class SafeBrowsingService // PowerObserver notifications // We defer SafeBrowsing work for a short duration when the computer comes // out of a suspend state to avoid thrashing the disk. - void OnPowerStateChange(base::SystemMonitor*) {} - void OnSuspend(base::SystemMonitor*); - void OnResume(base::SystemMonitor*); + void OnResume(); // Report any pages that contain malware sub-resources to the SafeBrowsing // service. |