summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaren@chromium.org <karen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 21:44:55 +0000
committerkaren@chromium.org <karen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 21:44:55 +0000
commit85802ab9b83fce71b5d7f41d64b3e293e8ea1155 (patch)
tree2d2c5c5e8794cedb34a16d89b240e70e6c3d0793
parent6c511a1ac27b511e94edfc900c8553216e39dd5a (diff)
downloadchromium_src-85802ab9b83fce71b5d7f41d64b3e293e8ea1155.zip
chromium_src-85802ab9b83fce71b5d7f41d64b3e293e8ea1155.tar.gz
chromium_src-85802ab9b83fce71b5d7f41d64b3e293e8ea1155.tar.bz2
Revert 217251 "Revert 185611 "On Android, the browser process ca..."
> Revert 185611 "On Android, the browser process can be killed any..." > > > On Android, the browser process can be killed anytime by the system. > > For stability purposes, we count a crash when the browser process dies when the app is in the foreground. We call MetricsService::OnAppEnterForeground (which sets kStabilityExitedCleanly to false) and OnAppEnterBackground (which sets it to true). > > If the process dies (for any reason) after OnAppEnterBackground has been called, it is not counted as a crash. > > > > The browser process can also be started while the app is in the background (to service a sync or bookmark widget request), we do not want to modify the kStabilityExitedCleanly in this case, because we won't get a chance to mark clean shutdown. > > > > BUG=179143 > > > > Review URL: https://chromiumcodereview.appspot.com/12326114 > > TBR=nileshagrawal@chromium.org > > Review URL: https://codereview.chromium.org/23052003 TBR=karen@chromium.org Review URL: https://codereview.chromium.org/23072006 git-svn-id: svn://svn.chromium.org/chrome/branches/1599/src@217351 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_browser_main.cc5
-rw-r--r--chrome/browser/metrics/metrics_service.cc34
-rw-r--r--chrome/browser/metrics/metrics_service.h8
3 files changed, 27 insertions, 20 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index e67d93b..e8612a1 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -1458,8 +1458,13 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// startup_watcher_ is deleted.
startup_watcher_->Arm(base::TimeDelta::FromSeconds(300));
+ // On mobile, need for clean shutdown arises only when the application comes
+ // to foreground (i.e. MetricsService::OnAppEnterForeground is called).
+ // http://crbug.com/179143
+#if !defined(OS_ANDROID)
// Start watching for a hang.
MetricsService::LogNeedForCleanShutdown();
+#endif
#if defined(ENABLE_FULL_PRINTING)
// Create the instance of the cloud print proxy service so that it can launch
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index a3dff43..5c6a8e2 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -321,6 +321,13 @@ int MapCrashExitCodeForHistogram(int exit_code) {
return std::abs(exit_code);
}
+void MarkAppCleanShutdownAndCommit() {
+ PrefService* pref = g_browser_process->local_state();
+ pref->SetBoolean(prefs::kStabilityExitedCleanly, true);
+ // Start writing right away (write happens on a different thread).
+ pref->CommitPendingWrite();
+}
+
} // namespace
// static
@@ -742,8 +749,7 @@ void MetricsService::RecordCompletedSessionEnd() {
void MetricsService::OnAppEnterBackground() {
scheduler_->Stop();
- PrefService* pref = g_browser_process->local_state();
- pref->SetBoolean(prefs::kStabilityExitedCleanly, true);
+ MarkAppCleanShutdownAndCommit();
// At this point, there's no way of knowing when the process will be
// killed, so this has to be treated similar to a shutdown, closing and
@@ -756,9 +762,6 @@ void MetricsService::OnAppEnterBackground() {
// process is killed.
OpenNewLog();
}
-
- // Start writing right away (write happens on a different thread).
- pref->CommitPendingWrite();
}
void MetricsService::OnAppEnterForeground() {
@@ -767,7 +770,14 @@ void MetricsService::OnAppEnterForeground() {
StartSchedulerIfNecessary();
}
-#endif
+#else
+void MetricsService::LogNeedForCleanShutdown() {
+ PrefService* pref = g_browser_process->local_state();
+ pref->SetBoolean(prefs::kStabilityExitedCleanly, false);
+ // Redundant setting to be sure we call for a clean shutdown.
+ clean_shutdown_status_ = NEED_TO_SHUTDOWN;
+}
+#endif // defined(OS_ANDROID) || defined(OS_IOS)
void MetricsService::RecordBreakpadRegistration(bool success) {
if (!success)
@@ -1542,13 +1552,6 @@ void MetricsService::LogRendererHang() {
IncrementPrefValue(prefs::kStabilityRendererHangCount);
}
-void MetricsService::LogNeedForCleanShutdown() {
- PrefService* pref = g_browser_process->local_state();
- pref->SetBoolean(prefs::kStabilityExitedCleanly, false);
- // Redundant setting to be sure we call for a clean shutdown.
- clean_shutdown_status_ = NEED_TO_SHUTDOWN;
-}
-
bool MetricsService::UmaMetricsProperlyShutdown() {
CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN ||
clean_shutdown_status_ == NEED_TO_SHUTDOWN);
@@ -1557,9 +1560,8 @@ bool MetricsService::UmaMetricsProperlyShutdown() {
void MetricsService::LogCleanShutdown() {
// Redundant hack to write pref ASAP.
- PrefService* pref = g_browser_process->local_state();
- pref->SetBoolean(prefs::kStabilityExitedCleanly, true);
- pref->CommitPendingWrite();
+ MarkAppCleanShutdownAndCommit();
+
// Redundant setting to assure that we always reset this value at shutdown
// (and that we don't use some alternate path, and not call LogCleanShutdown).
clean_shutdown_status_ = CLEANLY_SHUTDOWN;
diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h
index 9d75d28..27437ec 100644
--- a/chrome/browser/metrics/metrics_service.h
+++ b/chrome/browser/metrics/metrics_service.h
@@ -158,7 +158,10 @@ class MetricsService
// Called when the application is coming out of background mode.
void OnAppEnterForeground();
-#endif
+#else
+ // Set the dirty flag, which will require a later call to LogCleanShutdown().
+ static void LogNeedForCleanShutdown();
+#endif // defined(OS_ANDROID) || defined(OS_IOS)
// Saves in the preferences if the crash report registration was successful.
// This count is eventually send via UMA logs.
@@ -190,9 +193,6 @@ class MetricsService
// This value should be true when process has completed shutdown.
static bool UmaMetricsProperlyShutdown();
- // Set the dirty flag, which will require a later call to LogCleanShutdown().
- static void LogNeedForCleanShutdown();
-
private:
// The MetricsService has a lifecycle that is stored as a state.
// See metrics_service.cc for description of this lifecycle.