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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/TabWebContentsObserver.java

Issue 1447213002: Add stats to distinguish android renderer crashes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix termination status zero value. Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.chrome.browser.tab; 5 package org.chromium.chrome.browser.tab;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Color; 8 import android.graphics.Color;
9 import android.support.annotation.IntDef;
9 import android.view.View; 10 import android.view.View;
10 11
11 import org.chromium.base.ActivityState; 12 import org.chromium.base.ActivityState;
12 import org.chromium.base.ApplicationState; 13 import org.chromium.base.ApplicationState;
13 import org.chromium.base.ApplicationStatus; 14 import org.chromium.base.ApplicationStatus;
14 import org.chromium.base.Log; 15 import org.chromium.base.Log;
15 import org.chromium.base.ObserverList.RewindableIterator; 16 import org.chromium.base.ObserverList.RewindableIterator;
16 import org.chromium.base.metrics.RecordHistogram; 17 import org.chromium.base.metrics.RecordHistogram;
17 import org.chromium.chrome.browser.ChromeApplication; 18 import org.chromium.chrome.browser.ChromeApplication;
18 import org.chromium.chrome.browser.fullscreen.FullscreenManager; 19 import org.chromium.chrome.browser.fullscreen.FullscreenManager;
(...skipping 18 matching lines...) Expand all
37 38
38 /** Used for logging. */ 39 /** Used for logging. */
39 private static final String TAG = "TabWebContentsObs"; 40 private static final String TAG = "TabWebContentsObs";
40 41
41 // TabRendererCrashStatus defined in tools/metrics/histograms/histograms.xml . 42 // TabRendererCrashStatus defined in tools/metrics/histograms/histograms.xml .
42 private static final int TAB_RENDERER_CRASH_STATUS_SHOWN_IN_FOREGROUND_APP = 0; 43 private static final int TAB_RENDERER_CRASH_STATUS_SHOWN_IN_FOREGROUND_APP = 0;
43 private static final int TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_FOREGROUND_APP = 1; 44 private static final int TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_FOREGROUND_APP = 1;
44 private static final int TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_BACKGROUND_APP = 2; 45 private static final int TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_BACKGROUND_APP = 2;
45 private static final int TAB_RENDERER_CRASH_STATUS_MAX = 3; 46 private static final int TAB_RENDERER_CRASH_STATUS_MAX = 3;
46 47
48 // TabRendererExitStatus defined in tools/metrics/histograms/histograms.xml.
49 // Designed to replace TabRendererCrashStatus if numbers line up.
50 @IntDef({TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_RUNNING_APP,
51 TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_PAUSED_APP,
52 TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_BACKGROUND_APP,
53 TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_RUNNING_APP,
54 TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_PAUSED_APP,
55 TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_BACKGROUND_APP,
56 TAB_RENDERER_EXIT_STATUS_MAX})
57 private @interface TabRendererExitStatus {}
58 private static final int TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_RUNNING_A PP = 0;
59 private static final int TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_PAUSED_AP P = 1;
60 private static final int TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_BACKGROUN D_APP = 2;
61 private static final int TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_RUNNING_A PP = 3;
62 private static final int TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_PAUSED_AP P = 4;
63 private static final int TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_BACKGROUN D_APP = 5;
64 private static final int TAB_RENDERER_EXIT_STATUS_MAX = 6;
65
47 private final Tab mTab; 66 private final Tab mTab;
48 private int mThemeColor; 67 private int mThemeColor;
49 68
50 public TabWebContentsObserver(WebContents webContents, Tab tab) { 69 public TabWebContentsObserver(WebContents webContents, Tab tab) {
51 super(webContents); 70 super(webContents);
52 mTab = tab; 71 mTab = tab;
53 mThemeColor = mTab.getDefaultThemeColor(); 72 mThemeColor = mTab.getDefaultThemeColor();
54 } 73 }
55 74
56 @Override 75 @Override
57 public void renderProcessGone(boolean processWasOomProtected) { 76 public void renderProcessGone(boolean processWasOomProtected) {
58 Log.i(TAG, "renderProcessGone() for tab id: " + mTab.getId() 77 Log.i(TAG, "renderProcessGone() for tab id: " + mTab.getId()
59 + ", oom protected: " + Boolean.toString(processWasOomProtected) 78 + ", oom protected: " + Boolean.toString(processWasOomProtected)
60 + ", already needs reload: " + Boolean.toString(mTab.needsReload ())); 79 + ", already needs reload: " + Boolean.toString(mTab.needsReload ()));
61 // Do nothing for subsequent calls that happen while the tab remains cra shed. This 80 // Do nothing for subsequent calls that happen while the tab remains cra shed. This
62 // can occur when the tab is in the background and it shares the rendere r with other 81 // can occur when the tab is in the background and it shares the rendere r with other
63 // tabs. After the renderer crashes, the WebContents of its tabs are sti ll around 82 // tabs. After the renderer crashes, the WebContents of its tabs are sti ll around
64 // and they still share the RenderProcessHost. When one of the tabs relo ads spawning 83 // and they still share the RenderProcessHost. When one of the tabs relo ads spawning
65 // a new renderer for the shared RenderProcessHost and the new renderer crashes 84 // a new renderer for the shared RenderProcessHost and the new renderer crashes
66 // again, all tabs sharing this renderer will be notified about the cras h (including 85 // again, all tabs sharing this renderer will be notified about the cras h (including
67 // potential background tabs that did not reload yet). 86 // potential background tabs that did not reload yet).
68 if (mTab.needsReload() || mTab.isShowingSadTab()) return; 87 if (mTab.needsReload() || mTab.isShowingSadTab()) return;
69 88
89 // This will replace TabRendererCrashStatus if numbers line up.
90 int appState = ApplicationStatus.getStateForApplication();
91 boolean applicationRunning = (appState == ApplicationState.HAS_RUNNING_A CTIVITIES);
92 boolean applicationPaused = (appState == ApplicationState.HAS_PAUSED_ACT IVITIES);
93 @TabRendererExitStatus int rendererExitStatus = TAB_RENDERER_EXIT_STATUS _MAX;
94 if (processWasOomProtected) {
95 if (applicationRunning) {
96 rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_R UNNING_APP;
97 } else if (applicationPaused) {
98 rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_P AUSED_APP;
99 } else {
100 rendererExitStatus = TAB_RENDERER_EXIT_STATUS_OOM_PROTECTED_IN_B ACKGROUND_APP;
101 }
102 } else {
103 if (applicationRunning) {
104 rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_R UNNING_APP;
105 } else if (applicationPaused) {
106 rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_P AUSED_APP;
107 } else {
108 rendererExitStatus = TAB_RENDERER_EXIT_STATUS_NOT_PROTECTED_IN_B ACKGROUND_APP;
109 }
110 }
111 RecordHistogram.recordEnumeratedHistogram(
112 "Tab.RendererExitStatus", rendererExitStatus, TAB_RENDERER_EXIT_ STATUS_MAX);
113
70 int activityState = ApplicationStatus.getStateForActivity( 114 int activityState = ApplicationStatus.getStateForActivity(
71 mTab.getWindowAndroid().getActivity().get()); 115 mTab.getWindowAndroid().getActivity().get());
72 int rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_MAX; 116 int rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_MAX;
73 if (!processWasOomProtected 117 if (!processWasOomProtected
74 || activityState == ActivityState.PAUSED 118 || activityState == ActivityState.PAUSED
75 || activityState == ActivityState.STOPPED 119 || activityState == ActivityState.STOPPED
76 || activityState == ActivityState.DESTROYED) { 120 || activityState == ActivityState.DESTROYED) {
77 // The tab crashed in background or was killed by the OS out-of-memo ry killer. 121 // The tab crashed in background or was killed by the OS out-of-memo ry killer.
78 //setNeedsReload(true); 122 //setNeedsReload(true);
79 mTab.setNeedsReload(true); 123 mTab.setNeedsReload(true);
80 if (ApplicationStatus.getStateForApplication() 124 if (applicationRunning) {
81 == ApplicationState.HAS_RUNNING_ACTIVITIES) {
82 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_FOREGR OUND_APP; 125 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_FOREGR OUND_APP;
83 } else { 126 } else {
84 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_BACKGR OUND_APP; 127 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_BACKGR OUND_APP;
85 } 128 }
86 } else { 129 } else {
87 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_SHOWN_IN_FOREGROUND_ APP; 130 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_SHOWN_IN_FOREGROUND_ APP;
88 mTab.showSadTab(); 131 mTab.showSadTab();
89 // This is necessary to correlate histogram data with stability coun ts. 132 // This is necessary to correlate histogram data with stability coun ts.
90 UmaSessionStats.logRendererCrash(); 133 UmaSessionStats.logRendererCrash();
91 } 134 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 * @return The theme-color for this web contents. 337 * @return The theme-color for this web contents.
295 */ 338 */
296 int getThemeColor() { 339 int getThemeColor() {
297 return mThemeColor; 340 return mThemeColor;
298 } 341 }
299 342
300 private static boolean isThemeColorEnabled(Context context) { 343 private static boolean isThemeColorEnabled(Context context) {
301 return !DeviceFormFactor.isTablet(context); 344 return !DeviceFormFactor.isTablet(context);
302 } 345 }
303 } 346 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698