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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ManagedChildProcessConnection.java

Issue 2855323003: Removed the service number member from BaseChildProcessConnection. (Closed)
Patch Set: Minor clean-up Created 3 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Bundle; 8 import android.os.Bundle;
9 9
10 import org.chromium.base.Log; 10 import org.chromium.base.Log;
11 import org.chromium.base.VisibleForTesting; 11 import org.chromium.base.VisibleForTesting;
12 import org.chromium.base.process_launcher.ChildProcessCreationParams; 12 import org.chromium.base.process_launcher.ChildProcessCreationParams;
13 13
14 /** 14 /**
15 * ManagedChildProcessConnection is a connection to a child service that can hol d several bindings 15 * ManagedChildProcessConnection is a connection to a child service that can hol d several bindings
16 * to the service so it can be more or less agressively protected against OOM. 16 * to the service so it can be more or less agressively protected against OOM.
17 * Accessed from the launcher thread. (but for isOomProtectedOrWasWhenDied()). 17 * Accessed from the launcher thread. (but for isOomProtectedOrWasWhenDied()).
18 */ 18 */
19 public class ManagedChildProcessConnection extends BaseChildProcessConnection { 19 public class ManagedChildProcessConnection extends BaseChildProcessConnection {
20 private static final String TAG = "ManChildProcessConn"; 20 private static final String TAG = "ManChildProcessConn";
21 21
22 public static final Factory FACTORY = new BaseChildProcessConnection.Factory () { 22 public static final Factory FACTORY = new BaseChildProcessConnection.Factory () {
23 @Override 23 @Override
24 public BaseChildProcessConnection create(Context context, int number, bo olean sandboxed, 24 public BaseChildProcessConnection create(Context context, boolean sandbo xed,
25 DeathCallback deathCallback, String serviceClassName, 25 DeathCallback deathCallback, String serviceClassName,
26 Bundle childProcessCommonParameters, ChildProcessCreationParams creationParams) { 26 Bundle childProcessCommonParameters, ChildProcessCreationParams creationParams) {
27 assert LauncherThread.runningOnLauncherThread(); 27 assert LauncherThread.runningOnLauncherThread();
28 return new ManagedChildProcessConnection(context, number, sandboxed, deathCallback, 28 return new ManagedChildProcessConnection(context, sandboxed, deathCa llback,
29 serviceClassName, childProcessCommonParameters, creationPara ms); 29 serviceClassName, childProcessCommonParameters, creationPara ms);
30 } 30 }
31 }; 31 };
32 32
33 // Initial binding protects the newly spawned process from being killed befo re it is put to use, 33 // Initial binding protects the newly spawned process from being killed befo re it is put to use,
34 // it is maintained between calls to start() and removeInitialBinding(). 34 // it is maintained between calls to start() and removeInitialBinding().
35 private final ChildServiceConnection mInitialBinding; 35 private final ChildServiceConnection mInitialBinding;
36 36
37 // Strong binding will make the service priority equal to the priority of th e activity. We want 37 // Strong binding will make the service priority equal to the priority of th e activity. We want
38 // the OS to be able to kill background renderers as it kills other backgrou nd apps, so strong 38 // the OS to be able to kill background renderers as it kills other backgrou nd apps, so strong
(...skipping 14 matching lines...) Expand all
53 private final ChildServiceConnection mModerateBinding; 53 private final ChildServiceConnection mModerateBinding;
54 54
55 // Indicates whether the connection is OOM protected (if the connection is u nbound, it contains 55 // Indicates whether the connection is OOM protected (if the connection is u nbound, it contains
56 // the state at time of unbinding). 56 // the state at time of unbinding).
57 private boolean mOomProtected; 57 private boolean mOomProtected;
58 58
59 // Set to true once unbind() was called. 59 // Set to true once unbind() was called.
60 private boolean mUnbound; 60 private boolean mUnbound;
61 61
62 @VisibleForTesting 62 @VisibleForTesting
63 ManagedChildProcessConnection(Context context, int number, boolean sandboxed , 63 ManagedChildProcessConnection(Context context, boolean sandboxed, DeathCallb ack deathCallback,
64 DeathCallback deathCallback, String serviceClassName, 64 String serviceClassName, Bundle childProcessCommonParameters,
65 Bundle childProcessCommonParameters, ChildProcessCreationParams crea tionParams) { 65 ChildProcessCreationParams creationParams) {
66 super(context, number, sandboxed, deathCallback, serviceClassName, 66 super(context, sandboxed, deathCallback, serviceClassName, childProcessC ommonParameters,
67 childProcessCommonParameters, creationParams); 67 creationParams);
68 68
69 int initialFlags = Context.BIND_AUTO_CREATE; 69 int initialFlags = Context.BIND_AUTO_CREATE;
70 int extraBindFlags = shouldBindAsExportedService() ? Context.BIND_EXTERN AL_SERVICE : 0; 70 int extraBindFlags = shouldBindAsExportedService() ? Context.BIND_EXTERN AL_SERVICE : 0;
71 mInitialBinding = createServiceConnection(initialFlags | extraBindFlags) ; 71 mInitialBinding = createServiceConnection(initialFlags | extraBindFlags) ;
72 mStrongBinding = createServiceConnection( 72 mStrongBinding = createServiceConnection(
73 Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT | extraBindFla gs); 73 Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT | extraBindFla gs);
74 mWaivedBinding = createServiceConnection( 74 mWaivedBinding = createServiceConnection(
75 Context.BIND_AUTO_CREATE | Context.BIND_WAIVE_PRIORITY | extraBi ndFlags); 75 Context.BIND_AUTO_CREATE | Context.BIND_WAIVE_PRIORITY | extraBi ndFlags);
76 mModerateBinding = createServiceConnection(Context.BIND_AUTO_CREATE | ex traBindFlags); 76 mModerateBinding = createServiceConnection(Context.BIND_AUTO_CREATE | ex traBindFlags);
77 } 77 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 mModerateBinding.unbind(); 188 mModerateBinding.unbind();
189 } 189 }
190 190
191 // Should be called every time the mInitialBinding or mStrongBinding are bou nd/unbound. 191 // Should be called every time the mInitialBinding or mStrongBinding are bou nd/unbound.
192 private void updateOomProtectedState() { 192 private void updateOomProtectedState() {
193 if (!mUnbound) { 193 if (!mUnbound) {
194 mOomProtected = mInitialBinding.isBound() || mStrongBinding.isBound( ); 194 mOomProtected = mInitialBinding.isBound() || mStrongBinding.isBound( );
195 } 195 }
196 } 196 }
197 } 197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698