diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-30 23:54:35 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-30 23:54:35 +0000 |
commit | 4f470ec4e08cf042997d68c55bb7aeeeeaa1209c (patch) | |
tree | bb0f13c32bb3f27849a8f694720e0664b0550fda /chrome/browser/profile_manager.cc | |
parent | 9b6b8dbb54aeec5b4f271a7b5aed18c45664f911 (diff) | |
download | chromium_src-4f470ec4e08cf042997d68c55bb7aeeeeaa1209c.zip chromium_src-4f470ec4e08cf042997d68c55bb7aeeeeaa1209c.tar.gz chromium_src-4f470ec4e08cf042997d68c55bb7aeeeeaa1209c.tar.bz2 |
A new copy of the old system monitor changelist.
Review URL: http://codereview.chromium.org/12817
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6126 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) { |