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

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

Issue 1474543003: Revert "Add stats to distinguish android renderer crashes." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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;
10 import android.view.View; 9 import android.view.View;
11 10
12 import org.chromium.base.ActivityState; 11 import org.chromium.base.ActivityState;
13 import org.chromium.base.ApplicationState; 12 import org.chromium.base.ApplicationState;
14 import org.chromium.base.ApplicationStatus; 13 import org.chromium.base.ApplicationStatus;
15 import org.chromium.base.Log; 14 import org.chromium.base.Log;
16 import org.chromium.base.ObserverList.RewindableIterator; 15 import org.chromium.base.ObserverList.RewindableIterator;
17 import org.chromium.base.metrics.RecordHistogram; 16 import org.chromium.base.metrics.RecordHistogram;
18 import org.chromium.chrome.browser.ChromeApplication; 17 import org.chromium.chrome.browser.ChromeApplication;
19 import org.chromium.chrome.browser.fullscreen.FullscreenManager; 18 import org.chromium.chrome.browser.fullscreen.FullscreenManager;
(...skipping 18 matching lines...) Expand all
38 37
39 /** Used for logging. */ 38 /** Used for logging. */
40 private static final String TAG = "TabWebContentsObs"; 39 private static final String TAG = "TabWebContentsObs";
41 40
42 // TabRendererCrashStatus defined in tools/metrics/histograms/histograms.xml . 41 // TabRendererCrashStatus defined in tools/metrics/histograms/histograms.xml .
43 private static final int TAB_RENDERER_CRASH_STATUS_SHOWN_IN_FOREGROUND_APP = 0; 42 private static final int TAB_RENDERER_CRASH_STATUS_SHOWN_IN_FOREGROUND_APP = 0;
44 private static final int TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_FOREGROUND_APP = 1; 43 private static final int TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_FOREGROUND_APP = 1;
45 private static final int TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_BACKGROUND_APP = 2; 44 private static final int TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_BACKGROUND_APP = 2;
46 private static final int TAB_RENDERER_CRASH_STATUS_MAX = 3; 45 private static final int TAB_RENDERER_CRASH_STATUS_MAX = 3;
47 46
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
66 private final Tab mTab; 47 private final Tab mTab;
67 private int mThemeColor; 48 private int mThemeColor;
68 49
69 public TabWebContentsObserver(WebContents webContents, Tab tab) { 50 public TabWebContentsObserver(WebContents webContents, Tab tab) {
70 super(webContents); 51 super(webContents);
71 mTab = tab; 52 mTab = tab;
72 mThemeColor = mTab.getDefaultThemeColor(); 53 mThemeColor = mTab.getDefaultThemeColor();
73 } 54 }
74 55
75 @Override 56 @Override
76 public void renderProcessGone(boolean processWasOomProtected) { 57 public void renderProcessGone(boolean processWasOomProtected) {
77 Log.i(TAG, "renderProcessGone() for tab id: " + mTab.getId() 58 Log.i(TAG, "renderProcessGone() for tab id: " + mTab.getId()
78 + ", oom protected: " + Boolean.toString(processWasOomProtected) 59 + ", oom protected: " + Boolean.toString(processWasOomProtected)
79 + ", already needs reload: " + Boolean.toString(mTab.needsReload ())); 60 + ", already needs reload: " + Boolean.toString(mTab.needsReload ()));
80 // Do nothing for subsequent calls that happen while the tab remains cra shed. This 61 // Do nothing for subsequent calls that happen while the tab remains cra shed. This
81 // can occur when the tab is in the background and it shares the rendere r with other 62 // can occur when the tab is in the background and it shares the rendere r with other
82 // tabs. After the renderer crashes, the WebContents of its tabs are sti ll around 63 // tabs. After the renderer crashes, the WebContents of its tabs are sti ll around
83 // and they still share the RenderProcessHost. When one of the tabs relo ads spawning 64 // and they still share the RenderProcessHost. When one of the tabs relo ads spawning
84 // a new renderer for the shared RenderProcessHost and the new renderer crashes 65 // a new renderer for the shared RenderProcessHost and the new renderer crashes
85 // again, all tabs sharing this renderer will be notified about the cras h (including 66 // again, all tabs sharing this renderer will be notified about the cras h (including
86 // potential background tabs that did not reload yet). 67 // potential background tabs that did not reload yet).
87 if (mTab.needsReload() || mTab.isShowingSadTab()) return; 68 if (mTab.needsReload() || mTab.isShowingSadTab()) return;
88 69
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
114 int activityState = ApplicationStatus.getStateForActivity( 70 int activityState = ApplicationStatus.getStateForActivity(
115 mTab.getWindowAndroid().getActivity().get()); 71 mTab.getWindowAndroid().getActivity().get());
116 int rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_MAX; 72 int rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_MAX;
117 if (!processWasOomProtected 73 if (!processWasOomProtected
118 || activityState == ActivityState.PAUSED 74 || activityState == ActivityState.PAUSED
119 || activityState == ActivityState.STOPPED 75 || activityState == ActivityState.STOPPED
120 || activityState == ActivityState.DESTROYED) { 76 || activityState == ActivityState.DESTROYED) {
121 // The tab crashed in background or was killed by the OS out-of-memo ry killer. 77 // The tab crashed in background or was killed by the OS out-of-memo ry killer.
122 //setNeedsReload(true); 78 //setNeedsReload(true);
123 mTab.setNeedsReload(true); 79 mTab.setNeedsReload(true);
124 if (applicationRunning) { 80 if (ApplicationStatus.getStateForApplication()
81 == ApplicationState.HAS_RUNNING_ACTIVITIES) {
125 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_FOREGR OUND_APP; 82 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_FOREGR OUND_APP;
126 } else { 83 } else {
127 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_BACKGR OUND_APP; 84 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_HIDDEN_IN_BACKGR OUND_APP;
128 } 85 }
129 } else { 86 } else {
130 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_SHOWN_IN_FOREGROUND_ APP; 87 rendererCrashStatus = TAB_RENDERER_CRASH_STATUS_SHOWN_IN_FOREGROUND_ APP;
131 mTab.showSadTab(); 88 mTab.showSadTab();
132 // This is necessary to correlate histogram data with stability coun ts. 89 // This is necessary to correlate histogram data with stability coun ts.
133 UmaSessionStats.logRendererCrash(); 90 UmaSessionStats.logRendererCrash();
134 } 91 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 * @return The theme-color for this web contents. 294 * @return The theme-color for this web contents.
338 */ 295 */
339 int getThemeColor() { 296 int getThemeColor() {
340 return mThemeColor; 297 return mThemeColor;
341 } 298 }
342 299
343 private static boolean isThemeColorEnabled(Context context) { 300 private static boolean isThemeColorEnabled(Context context) {
344 return !DeviceFormFactor.isTablet(context); 301 return !DeviceFormFactor.isTablet(context);
345 } 302 }
346 } 303 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698