Chromium Code Reviews| Index: chrome/browser/android/process_utils.cc |
| diff --git a/chrome/browser/android/process_utils.cc b/chrome/browser/android/process_utils.cc |
| index c0f52802273241fca6752799da785159567790df..e5cff54ad8d0efb6d9837dfb05e383ebb1434bb8 100644 |
| --- a/chrome/browser/android/process_utils.cc |
| +++ b/chrome/browser/android/process_utils.cc |
| @@ -8,12 +8,37 @@ |
| #include "base/lazy_instance.h" |
| #include "base/logging.h" |
| +#include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/common/render_messages.h" |
| +#include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/render_process_host.h" |
| #include "jni/ProcessUtils_jni.h" |
| +#include "net/http/http_network_session.h" |
| +#include "net/http/http_transaction_factory.h" |
| +#include "net/url_request/url_request_context.h" |
| +#include "net/url_request/url_request_context_getter.h" |
| namespace { |
| +void CloseIdleConnectionsForProfile( |
| + scoped_refptr<net::URLRequestContextGetter> context_getter) { |
| + DCHECK(context_getter.get()); |
| + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { |
| + content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
| + base::Bind(&CloseIdleConnectionsForProfile, |
| + context_getter)); |
| + return; |
| + } |
| + |
| + net::URLRequestContext* context = context_getter->GetURLRequestContext(); |
| + DCHECK(context->http_transaction_factory()); |
| + net::HttpNetworkSession* session = |
| + context->http_transaction_factory()->GetSession(); |
| + DCHECK(session); |
|
Philippe
2012/12/03 13:17:46
Are we missing 'session->CloseIdleConnections()' h
digit1
2012/12/03 13:42:02
Yes, this looks suspicious. What happens if you ad
Philippe
2012/12/03 13:48:37
Yes, I'm building/testing this right now. FYI, we
|
| +} |
| + |
| // Only accessed from the JNI thread by ToggleWebKitSharedTimers() which is |
| // implemented below. |
| base::LazyInstance<std::vector<int /* process id */> > g_suspended_processes = |
| @@ -54,7 +79,23 @@ static void ToggleWebKitSharedTimers(JNIEnv* env, |
| } |
| } |
| -// TODO(pliard): http://crbug.com/137674 |
| +static void CloseIdleConnections(JNIEnv* env, jclass obj) { |
| + // Iterate through all loaded profiles (and their associated incognito |
| + // profiles if created), and close the idle connections associated with each |
| + // one. |
| + std::vector<Profile*> profiles( |
| + g_browser_process->profile_manager()->GetLoadedProfiles()); |
| + for (std::vector<Profile*>::iterator i = profiles.begin(); |
| + i != profiles.end(); i++) { |
| + Profile* profile = *i; |
| + CloseIdleConnectionsForProfile(profile->GetRequestContext()); |
| + if (profile->HasOffTheRecordProfile()) { |
| + CloseIdleConnectionsForProfile( |
| + profile->GetOffTheRecordProfile()->GetRequestContext()); |
| + } |
| + } |
| +} |
| + |
| bool RegisterProcessUtils(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |