 Chromium Code Reviews
 Chromium Code Reviews Issue 1146813010:
  Introduce moderate binding  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1146813010:
  Introduce moderate binding  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java | 
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java b/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java | 
| index e134d3625d3ab16879dfe1c59ed732eb93b97a4f..c9193b386397c9b15843a33a13e0dc3d1f85efde 100644 | 
| --- a/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java | 
| +++ b/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnectionImpl.java | 
| @@ -12,9 +12,9 @@ import android.os.Bundle; | 
| import android.os.DeadObjectException; | 
| import android.os.IBinder; | 
| import android.os.RemoteException; | 
| -import android.util.Log; | 
| import org.chromium.base.CpuFeatures; | 
| +import org.chromium.base.Log; | 
| import org.chromium.base.ThreadUtils; | 
| import org.chromium.base.TraceEvent; | 
| import org.chromium.base.VisibleForTesting; | 
| @@ -63,13 +63,17 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection { | 
| private ChildServiceConnection mWaivedBinding = null; | 
| // Incremented on addStrongBinding(), decremented on removeStrongBinding(). | 
| private int mStrongBindingCount = 0; | 
| + // Moderate binding will make the service priority equal to the priority of a visible process | 
| + // while the app is in the foreground. It will be being bound only while the app is in the | 
| 
Maria
2015/06/16 01:33:02
nit: "be being bound" -> "stay bound"
 
Jaekyun Seok (inactive)
2015/06/16 02:40:32
Done.
 | 
| + // foreground to protect a background process from the system out-of-memory killer. | 
| + private ChildServiceConnection mModerateBinding = null; | 
| // Linker-related parameters. | 
| private ChromiumLinkerParams mLinkerParams = null; | 
| private final boolean mAlwaysInForeground; | 
| - private static final String TAG = "ChildProcessConnection"; | 
| + private static final String TAG = "cr.ChildProcessConnect"; | 
| 
Maria
2015/06/16 01:33:02
why change this tag?
 
Jaekyun Seok (inactive)
2015/06/16 02:40:32
presubmit required this like the followings.
Plea
 | 
| private static class ConnectionParams { | 
| final String[] mCommandLine; | 
| @@ -212,6 +216,7 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection { | 
| Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT); | 
| mWaivedBinding = new ChildServiceConnection( | 
| Context.BIND_AUTO_CREATE | Context.BIND_WAIVE_PRIORITY); | 
| + mModerateBinding = new ChildServiceConnection(Context.BIND_AUTO_CREATE); | 
| } | 
| @Override | 
| @@ -297,6 +302,7 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection { | 
| mInitialBinding.unbind(); | 
| mStrongBinding.unbind(); | 
| mWaivedBinding.unbind(); | 
| + mModerateBinding.unbind(); | 
| mStrongBindingCount = 0; | 
| if (mService != null) { | 
| mService = null; | 
| @@ -398,6 +404,8 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection { | 
| mStrongBindingCount = 0; | 
| mStrongBinding.unbind(); | 
| + | 
| + mModerateBinding.unbind(); | 
| } | 
| } | 
| @@ -430,6 +438,35 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection { | 
| } | 
| } | 
| + @Override | 
| + public boolean isModerateBindingBound() { | 
| + synchronized (mLock) { | 
| + return mModerateBinding.isBound(); | 
| + } | 
| + } | 
| + | 
| + @Override | 
| + public void addModerateBinding() { | 
| + synchronized (mLock) { | 
| + if (mService == null) { | 
| + Log.w(TAG, "The connection is not bound for " + mPid); | 
| + return; | 
| + } | 
| + mModerateBinding.bind(null); | 
| + } | 
| + } | 
| + | 
| + @Override | 
| + public void removeModerateBinding() { | 
| + synchronized (mLock) { | 
| + if (mService == null) { | 
| + Log.w(TAG, "The connection is not bound for " + mPid); | 
| + return; | 
| + } | 
| + mModerateBinding.unbind(); | 
| + } | 
| + } | 
| + | 
| @VisibleForTesting | 
| public boolean crashServiceForTesting() throws RemoteException { | 
| try { |