diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-13 20:48:36 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-13 20:48:36 +0000 |
commit | 0a30765779382fa4cd46d47dab4db0ad607e7569 (patch) | |
tree | ae593d32fc4052115c428382f451bdd110bcf460 /chrome/browser/profile_manager.cc | |
parent | a211dddeb82823e7bf1baa24eb9583f95db7de4e (diff) | |
download | chromium_src-0a30765779382fa4cd46d47dab4db0ad607e7569.zip chromium_src-0a30765779382fa4cd46d47dab4db0ad607e7569.tar.gz chromium_src-0a30765779382fa4cd46d47dab4db0ad607e7569.tar.bz2 |
A new shot at the old system monitor changelist.
Review URL: http://codereview.chromium.org/12883
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6974 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profile_manager.cc')
-rw-r--r-- | chrome/browser/profile_manager.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/chrome/browser/profile_manager.cc b/chrome/browser/profile_manager.cc index d8c5099..23ad108 100644 --- a/chrome/browser/profile_manager.cc +++ b/chrome/browser/profile_manager.cc @@ -21,6 +21,8 @@ #include "chrome/common/logging_chrome.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" +#include "net/url_request/url_request_job.h" +#include "net/url_request/url_request_job_tracker.h" #include "generated_resources.h" @@ -39,9 +41,16 @@ void ProfileManager::ShutdownSessionServices() { } ProfileManager::ProfileManager() { + base::SystemMonitor* monitor = base::SystemMonitor::Get(); + if (monitor) + monitor->AddObserver(this); } ProfileManager::~ProfileManager() { + base::SystemMonitor* monitor = base::SystemMonitor::Get(); + if (monitor) + monitor->RemoveObserver(this); + // Destroy all profiles that we're keeping track of. for (ProfileVector::const_iterator iter = profiles_.begin(); iter != profiles_.end(); ++iter) { @@ -215,6 +224,47 @@ Profile* ProfileManager::GetProfileByID(const std::wstring& id) const { return NULL; } +void ProfileManager::OnSuspend(base::SystemMonitor* monitor) { + DCHECK(CalledOnValidThread()); + + ProfileManager::const_iterator it = begin(); + while(it != end()) { + g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, + NewRunnableFunction(&ProfileManager::SuspendProfile, *it)); + it++; + } +} + +void ProfileManager::OnResume(base::SystemMonitor* monitor) { + DCHECK(CalledOnValidThread()); + ProfileManager::const_iterator it = begin(); + while (it != end()) { + g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, + NewRunnableFunction(&ProfileManager::ResumeProfile, *it)); + it++; + } +} + +void ProfileManager::SuspendProfile(Profile* profile) { + DCHECK(profile); + DCHECK(MessageLoop::current() == + ChromeThread::GetMessageLoop(ChromeThread::IO)); + + URLRequestJobTracker::JobIterator it = g_url_request_job_tracker.begin(); + for (;it != g_url_request_job_tracker.end(); ++it) + (*it)->Kill(); + + profile->GetRequestContext()->http_transaction_factory()->Suspend(true); +} + +void ProfileManager::ResumeProfile(Profile* profile) { + DCHECK(profile); + DCHECK(MessageLoop::current() == + ChromeThread::GetMessageLoop(ChromeThread::IO)); + profile->GetRequestContext()->http_transaction_factory()->Suspend(false); +} + + // static bool ProfileManager::IsProfile(const std::wstring& path) { |