Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/ChildProcessConnection.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnection.java b/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnection.java |
| index ddd88797d18c027697cde5851d846fac6c310676..424ad90a6ba569781ff40d03be70a4cf198ee3ef 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnection.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/ChildProcessConnection.java |
| @@ -268,7 +268,6 @@ public class ChildProcessConnection { |
| mInitialBinding.unbind(); |
| mStrongBinding.unbind(); |
| mWaivedBinding.unbind(); |
| - mAttachAsActiveCount = 0; |
| if (mService != null) { |
| mService = null; |
| mPID = 0; |
| @@ -355,14 +354,22 @@ public class ChildProcessConnection { |
| TraceEvent.end(); |
| } |
| + private static final long REMOVE_INITIAL_BINDING_DELAY_MILLIS = 1 * 1000; // One second. |
| + |
| /** |
| * Called to remove the strong binding estabilished when the connection was started. It is safe |
| - * to call this multiple times. |
| + * to call this multiple times. The binding is removed after a fixed delay period so that the |
| + * renderer will not be killed immediately after the call. |
| */ |
| void removeInitialBinding() { |
| - synchronized(mUiThreadLock) { |
| - mInitialBinding.unbind(); |
| - } |
| + ThreadUtils.postOnUiThreadDelayed(new Runnable() { |
|
klobag.chromium
2013/07/19 16:19:55
why need this?
klobag.chromium
2013/07/19 18:19:05
Just saw the comment in the other CL, thanks.
Thi
ppi
2013/07/22 13:50:38
Done.
|
| + @Override |
| + public void run() { |
| + synchronized(mUiThreadLock) { |
| + mInitialBinding.unbind(); |
| + } |
| + } |
| + }, REMOVE_INITIAL_BINDING_DELAY_MILLIS); |
| } |
| /** |
| @@ -384,21 +391,29 @@ public class ChildProcessConnection { |
| } |
| } |
| + private static final long DETACH_AS_ACTIVE_DELAY_MILLIS = 5 * 1000; // Five seconds. |
| + |
| /** |
| - * Called when the service is no longer considered active. |
| + * Called when the service is no longer considered active. Actual binding is removed after a |
| + * fixed delay period so that the renderer will not be killed immediately after the call. |
| */ |
| void detachAsActive() { |
| - synchronized(mUiThreadLock) { |
| - assert mAttachAsActiveCount > 0; |
| - if (mService == null) { |
| - Log.w(TAG, "The connection is not bound for " + mPID); |
| - return; |
| - } |
| - mAttachAsActiveCount--; |
| - if (mAttachAsActiveCount == 0) { |
| - mStrongBinding.unbind(); |
| + ThreadUtils.postOnUiThreadDelayed(new Runnable() { |
| + @Override |
| + public void run() { |
| + synchronized(mUiThreadLock) { |
| + assert mAttachAsActiveCount > 0; |
| + if (mService == null) { |
|
klobag.chromium
2013/07/19 16:19:55
If you move line 405 to above 410, you can leave s
ppi
2013/07/22 13:50:38
Thanks, done (moved).
|
| + Log.w(TAG, "The connection is not bound for " + mPID); |
| + return; |
| + } |
| + mAttachAsActiveCount--; |
| + if (mAttachAsActiveCount == 0) { |
| + mStrongBinding.unbind(); |
| + } |
| + } |
| } |
| - } |
| + }, DETACH_AS_ACTIVE_DELAY_MILLIS); |
| } |