diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-14 19:07:32 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-14 19:07:32 +0000 |
commit | 322f7f7005061fee5e3b691e6aee318ea93a7eb8 (patch) | |
tree | 4d743cbbbee965d8b087171b9ee315f2ffc93865 /chrome/browser/safe_browsing/safe_browsing_service.cc | |
parent | a618550847f7c09eea7bb27e43bb226f330e5525 (diff) | |
download | chromium_src-322f7f7005061fee5e3b691e6aee318ea93a7eb8.zip chromium_src-322f7f7005061fee5e3b691e6aee318ea93a7eb8.tar.gz chromium_src-322f7f7005061fee5e3b691e6aee318ea93a7eb8.tar.bz2 |
Change to integrate SystemMonitor changes into chrome.
This enables the dynamic detection of battery status
changes so that we can turn on/off the hi-res timer.
Review URL: http://codereview.chromium.org/10264
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing/safe_browsing_service.cc')
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_service.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index e38bcc4..2474c4e 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -12,6 +12,7 @@ #include "base/path_service.h" #include "base/string_util.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/profile_manager.h" #include "chrome/browser/safe_browsing/protocol_manager.h" #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" @@ -34,9 +35,16 @@ SafeBrowsingService::SafeBrowsingService() resetting_(false), database_loaded_(false) { new_safe_browsing_ = CommandLine().HasSwitch(switches::kUseNewSafeBrowsing); + base::SystemMonitor* monitor = base::SystemMonitor::Get(); + DCHECK(monitor); + if (monitor) + monitor->AddObserver(this); } SafeBrowsingService::~SafeBrowsingService() { + base::SystemMonitor* monitor = base::SystemMonitor::Get(); + if (monitor) + monitor->RemoveObserver(this); } // Only called on the UI thread. @@ -655,18 +663,17 @@ void SafeBrowsingService::CacheHashResults( GetDatabase()->CacheHashResults(prefixes, full_hashes); } -void SafeBrowsingService::OnSuspend() { +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() { - DCHECK(MessageLoop::current() == io_loop_); +void SafeBrowsingService::OnResume(base::SystemMonitor*) { if (enabled_) { - db_thread_->message_loop()->PostTask(FROM_HERE, - NewRunnableMethod(this, &SafeBrowsingService::HandleResume)); + ChromeThread::GetMessageLoop(ChromeThread::DB)->PostTask(FROM_HERE, + NewRunnableMethod(this, &SafeBrowsingService::HandleResume)); } } |