diff options
author | sievers <sievers@chromium.org> | 2015-03-09 16:29:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-09 23:30:35 +0000 |
commit | 479947d99fd817737f517c068a77d74cd08183f8 (patch) | |
tree | cb44734ca0cca1326311a5d7beb88102c8bfe122 /content | |
parent | bfa20e6cbe5fcd30909b3e271005a527526385d9 (diff) | |
download | chromium_src-479947d99fd817737f517c068a77d74cd08183f8.zip chromium_src-479947d99fd817737f517c068a77d74cd08183f8.tar.gz chromium_src-479947d99fd817737f517c068a77d74cd08183f8.tar.bz2 |
Android: Fix GPU.GPUProcessTerminationStatus UMA stat
ChildProcessConnectionImpl.mAlwaysInForeground is used
for the GPU process and indicates that it does not participate
in hiding like renderers. The 'important' binding gives it the
same priority as the main application, so upon termination we
should just use the app's foreground status to determine whether
the GPU process was in the foreground or not.
BUG=462422
Review URL: https://codereview.chromium.org/987193003
Cr-Commit-Position: refs/heads/master@{#319768}
Diffstat (limited to 'content')
2 files changed, 23 insertions, 3 deletions
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 2020994..b13ffbb 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 @@ -177,9 +177,9 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection { if (mServiceDisconnected) { return; } - mServiceDisconnected = true; // Stash the status of the oom bindings, since stop() will release all bindings. - mWasOomProtected = mInitialBinding.isBound() || mStrongBinding.isBound(); + mWasOomProtected = isCurrentlyOomProtected(); + mServiceDisconnected = true; Log.w(TAG, "onServiceDisconnected (crash or killed by oom): pid=" + mPid); stop(); // We don't want to auto-restart on crash. Let the browser do that. mDeathCallback.onChildProcessDied(ChildProcessConnectionImpl.this); @@ -407,11 +407,19 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection { if (mServiceDisconnected) { return mWasOomProtected; } else { - return mInitialBinding.isBound() || mStrongBinding.isBound(); + return isCurrentlyOomProtected(); } } } + private boolean isCurrentlyOomProtected() { + synchronized (mLock) { + assert !mServiceDisconnected; + if (mAlwaysInForeground) return ChildProcessLauncher.isApplicationInForeground(); + return mInitialBinding.isBound() || mStrongBinding.isBound(); + } + } + @Override public void dropOomBindings() { synchronized (mLock) { diff --git a/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java b/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java index eae1698..e9f7beb 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java +++ b/content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncher.java @@ -351,6 +351,9 @@ public class ChildProcessLauncher { private static Map<Pair<Integer, Integer>, Surface> sSurfaceTextureSurfaceMap = new ConcurrentHashMap<Pair<Integer, Integer>, Surface>(); + // Whether the main application is currently brought to the foreground. + private static boolean sApplicationInForeground = true; + @VisibleForTesting public static void setBindingManagerForTesting(BindingManager manager) { sBindingManager = manager; @@ -433,6 +436,7 @@ public class ChildProcessLauncher { * Called when the embedding application is sent to background. */ public static void onSentToBackground() { + sApplicationInForeground = false; sBindingManager.onSentToBackground(); } @@ -440,10 +444,18 @@ public class ChildProcessLauncher { * Called when the embedding application is brought to foreground. */ public static void onBroughtToForeground() { + sApplicationInForeground = true; sBindingManager.onBroughtToForeground(); } /** + * Returns whether the application is currently in the foreground. + */ + static boolean isApplicationInForeground() { + return sApplicationInForeground; + } + + /** * Should be called early in startup so the work needed to spawn the child process can be done * in parallel to other startup work. Must not be called on the UI thread. Spare connection is * created in sandboxed child process. |