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

Side by Side Diff: chrome/browser/android/process_utils.cc

Issue 10816038: Upstreaming RegisterProcessUtils() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/android/chrome_jni_registrar.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/process_utils.h" 5 #include "chrome/browser/android/process_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h"
11 #include "chrome/common/render_messages.h" 14 #include "chrome/common/render_messages.h"
15 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/render_process_host.h" 16 #include "content/public/browser/render_process_host.h"
13 #include "jni/ProcessUtils_jni.h" 17 #include "jni/ProcessUtils_jni.h"
18 #include "net/http/http_network_session.h"
19 #include "net/http/http_transaction_factory.h"
20 #include "net/url_request/url_request_context.h"
21 #include "net/url_request/url_request_context_getter.h"
14 22
15 namespace { 23 namespace {
16 24
25 void CloseIdleConnectionsForProfile(
Yaron 2012/07/24 17:15:47 Not familiar with this. Adding Satish
26 scoped_refptr<net::URLRequestContextGetter> context_getter) {
27 DCHECK(context_getter.get());
28 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
29 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
30 base::Bind(&CloseIdleConnectionsForProfile,
31 context_getter));
32 return;
33 }
34
35 net::URLRequestContext* context = context_getter->GetURLRequestContext();
36 DCHECK(context->http_transaction_factory());
37 // TODO(satish): Remove this early return after verifying the above doesn't
38 // fail.
39 if (!context->http_transaction_factory())
40 return;
41 net::HttpNetworkSession* session =
42 context->http_transaction_factory()->GetSession();
43 DCHECK(session);
44 // TODO(satish): Remove this check after verifying the above doesn't fail.
45 if (session)
46 session->CloseIdleConnections();
47 }
48
17 // Only accessed from the JNI thread by ToggleWebKitSharedTimers() which is 49 // Only accessed from the JNI thread by ToggleWebKitSharedTimers() which is
18 // implemented below. 50 // implemented below.
19 base::LazyInstance<std::vector<int /* process id */> > g_suspended_processes = 51 base::LazyInstance<std::vector<int /* process id */> > g_suspended_processes =
20 LAZY_INSTANCE_INITIALIZER; 52 LAZY_INSTANCE_INITIALIZER;
21 53
22 // Suspends timers in all current render processes. 54 // Suspends timers in all current render processes.
23 void SuspendWebKitSharedTimers(std::vector<int>* suspended_processes) { 55 void SuspendWebKitSharedTimers(std::vector<int>* suspended_processes) {
24 for (content::RenderProcessHost::iterator i( 56 for (content::RenderProcessHost::iterator i(
25 content::RenderProcessHost::AllHostsIterator()); 57 content::RenderProcessHost::AllHostsIterator());
26 !i.IsAtEnd(); i.Advance()) { 58 !i.IsAtEnd(); i.Advance()) {
(...skipping 20 matching lines...) Expand all
47 std::vector<int>* suspended_processes = &g_suspended_processes.Get(); 79 std::vector<int>* suspended_processes = &g_suspended_processes.Get();
48 if (suspend) { 80 if (suspend) {
49 DCHECK(suspended_processes->empty()); 81 DCHECK(suspended_processes->empty());
50 SuspendWebKitSharedTimers(suspended_processes); 82 SuspendWebKitSharedTimers(suspended_processes);
51 } else { 83 } else {
52 ResumeWebkitSharedTimers(*suspended_processes); 84 ResumeWebkitSharedTimers(*suspended_processes);
53 suspended_processes->clear(); 85 suspended_processes->clear();
54 } 86 }
55 } 87 }
56 88
57 // TODO(pliard): http://crbug.com/137674 89 // TODO(pliard): http://crbug.com/137674
Yaron 2012/07/24 17:15:47 Remove TODO
aurimas (slooooooooow) 2012/07/24 18:12:14 Done.
58 bool RegisterProcessUtils(JNIEnv* env) { 90 bool RegisterProcessUtils(JNIEnv* env) {
59 return RegisterNativesImpl(env); 91 return RegisterNativesImpl(env);
60 } 92 }
OLDNEW
« no previous file with comments | « chrome/browser/android/chrome_jni_registrar.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698