Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: chrome/browser/profile_manager.cc

Issue 12817: A new copy of the old system monitor changelist. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/profile_manager.h ('k') | chrome/browser/safe_browsing/safe_browsing_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profile_manager.cc
===================================================================
--- chrome/browser/profile_manager.cc (revision 6119)
+++ chrome/browser/profile_manager.cc (working copy)
@@ -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 @@
}
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,7 +224,48 @@
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) {
std::wstring prefs_path = GetDefaultProfilePath(path);
« no previous file with comments | « chrome/browser/profile_manager.h ('k') | chrome/browser/safe_browsing/safe_browsing_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698