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

Side by Side Diff: chrome/browser/metrics/metrics_service.cc

Issue 25484004: Don't commit prefs::kStabilitySessionEndCompleted change immediately on chromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 //------------------------------------------------------------------------------ 5 //------------------------------------------------------------------------------
6 // Description of the life cycle of a instance of MetricsService. 6 // Description of the life cycle of a instance of MetricsService.
7 // 7 //
8 // OVERVIEW 8 // OVERVIEW
9 // 9 //
10 // A MetricsService instance is typically created at application startup. It is 10 // A MetricsService instance is typically created at application startup. It is
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 void MetricsService::HandleIdleSinceLastTransmission(bool in_idle) { 730 void MetricsService::HandleIdleSinceLastTransmission(bool in_idle) {
731 // If there wasn't a lot of action, maybe the computer was asleep, in which 731 // If there wasn't a lot of action, maybe the computer was asleep, in which
732 // case, the log transmissions should have stopped. Here we start them up 732 // case, the log transmissions should have stopped. Here we start them up
733 // again. 733 // again.
734 if (!in_idle && idle_since_last_transmission_) 734 if (!in_idle && idle_since_last_transmission_)
735 StartSchedulerIfNecessary(); 735 StartSchedulerIfNecessary();
736 idle_since_last_transmission_ = in_idle; 736 idle_since_last_transmission_ = in_idle;
737 } 737 }
738 738
739 void MetricsService::RecordStartOfSessionEnd() { 739 void MetricsService::RecordStartOfSessionEnd() {
740 LogCleanShutdown(); 740 RecordStabilitySessionEndCompleted(false);
741 RecordBooleanPrefValue(prefs::kStabilitySessionEndCompleted, false);
742 } 741 }
743 742
744 void MetricsService::RecordCompletedSessionEnd() { 743 void MetricsService::RecordCompletedSessionEnd() {
745 LogCleanShutdown(); 744 RecordStabilitySessionEndCompleted(true);
746 RecordBooleanPrefValue(prefs::kStabilitySessionEndCompleted, true);
747 } 745 }
748 746
749 #if defined(OS_ANDROID) || defined(OS_IOS) 747 #if defined(OS_ANDROID) || defined(OS_IOS)
750 void MetricsService::OnAppEnterBackground() { 748 void MetricsService::OnAppEnterBackground() {
751 scheduler_->Stop(); 749 scheduler_->Stop();
752 750
753 MarkAppCleanShutdownAndCommit(); 751 MarkAppCleanShutdownAndCommit();
754 752
755 // At this point, there's no way of knowing when the process will be 753 // At this point, there's no way of knowing when the process will be
756 // killed, so this has to be treated similar to a shutdown, closing and 754 // killed, so this has to be treated similar to a shutdown, closing and
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { 1589 } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) {
1592 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", 1590 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive",
1593 was_extension_process ? 2 : 1); 1591 was_extension_process ? 2 : 1);
1594 } 1592 }
1595 } 1593 }
1596 1594
1597 void MetricsService::LogRendererHang() { 1595 void MetricsService::LogRendererHang() {
1598 IncrementPrefValue(prefs::kStabilityRendererHangCount); 1596 IncrementPrefValue(prefs::kStabilityRendererHangCount);
1599 } 1597 }
1600 1598
1599 void MetricsService::RecordStabilitySessionEndCompleted(bool value) {
1600 PrefService* pref = g_browser_process->local_state();
1601 DCHECK(pref);
1602 clean_shutdown_status_ = CLEANLY_SHUTDOWN;
1603 pref->SetBoolean(prefs::kStabilitySessionEndCompleted, value);
1604 RecordCurrentState(pref);
Ilya Sherman 2013/10/04 03:26:59 Btw, why did you inline the call to RecordBooleanP
oshima 2013/10/04 06:03:14 Because it's calling RecordCurrentState(pref) insi
1605 MarkAppCleanShutdownAndCommit();
1606 }
1607
1601 bool MetricsService::UmaMetricsProperlyShutdown() { 1608 bool MetricsService::UmaMetricsProperlyShutdown() {
1602 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || 1609 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN ||
1603 clean_shutdown_status_ == NEED_TO_SHUTDOWN); 1610 clean_shutdown_status_ == NEED_TO_SHUTDOWN);
1604 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; 1611 return clean_shutdown_status_ == CLEANLY_SHUTDOWN;
1605 } 1612 }
1606 1613
1607 void MetricsService::LogCleanShutdown() {
1608 // Redundant hack to write pref ASAP.
1609 MarkAppCleanShutdownAndCommit();
1610
1611 // Redundant setting to assure that we always reset this value at shutdown
1612 // (and that we don't use some alternate path, and not call LogCleanShutdown).
Ilya Sherman 2013/10/04 03:26:59 What happened to this comment? Is it no longer re
oshima 2013/10/04 06:03:14 Added back. Thank you for pointing out.
1613 clean_shutdown_status_ = CLEANLY_SHUTDOWN;
1614
1615 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true);
1616 }
1617
1618 #if defined(OS_CHROMEOS) 1614 #if defined(OS_CHROMEOS)
1619 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { 1615 void MetricsService::LogChromeOSCrash(const std::string &crash_type) {
1620 if (crash_type == "user") 1616 if (crash_type == "user")
1621 IncrementPrefValue(prefs::kStabilityOtherUserCrashCount); 1617 IncrementPrefValue(prefs::kStabilityOtherUserCrashCount);
1622 else if (crash_type == "kernel") 1618 else if (crash_type == "kernel")
1623 IncrementPrefValue(prefs::kStabilityKernelCrashCount); 1619 IncrementPrefValue(prefs::kStabilityKernelCrashCount);
1624 else if (crash_type == "uncleanshutdown") 1620 else if (crash_type == "uncleanshutdown")
1625 IncrementPrefValue(prefs::kStabilitySystemUncleanShutdownCount); 1621 IncrementPrefValue(prefs::kStabilitySystemUncleanShutdownCount);
1626 else 1622 else
1627 NOTREACHED() << "Unexpected Chrome OS crash type " << crash_type; 1623 NOTREACHED() << "Unexpected Chrome OS crash type " << crash_type;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 if (local_state) { 1787 if (local_state) {
1792 const PrefService::Preference* uma_pref = 1788 const PrefService::Preference* uma_pref =
1793 local_state->FindPreference(prefs::kMetricsReportingEnabled); 1789 local_state->FindPreference(prefs::kMetricsReportingEnabled);
1794 if (uma_pref) { 1790 if (uma_pref) {
1795 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 1791 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
1796 DCHECK(success); 1792 DCHECK(success);
1797 } 1793 }
1798 } 1794 }
1799 return result; 1795 return result;
1800 } 1796 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698