OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 // Redundant setting to assure that we always reset this value at shutdown | |
1603 // (and that we don't use some alternate path, and not call | |
1604 // RecordStartOfEndSession/RecordCompletedSessionEnd) | |
1605 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | |
1606 pref->SetBoolean(prefs::kStabilitySessionEndCompleted, value); | |
1607 RecordCurrentState(pref); | |
1608 MarkAppCleanShutdownAndCommit(); | |
jar (doing other things)
2013/10/11 22:55:44
I'm trying to understand what you are doing here,
| |
1609 } | |
1610 | |
1601 bool MetricsService::UmaMetricsProperlyShutdown() { | 1611 bool MetricsService::UmaMetricsProperlyShutdown() { |
1602 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || | 1612 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || |
1603 clean_shutdown_status_ == NEED_TO_SHUTDOWN); | 1613 clean_shutdown_status_ == NEED_TO_SHUTDOWN); |
1604 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; | 1614 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; |
1605 } | 1615 } |
1606 | 1616 |
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). | |
1613 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | |
1614 | |
1615 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); | |
1616 } | |
1617 | |
1618 #if defined(OS_CHROMEOS) | 1617 #if defined(OS_CHROMEOS) |
1619 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { | 1618 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { |
1620 if (crash_type == "user") | 1619 if (crash_type == "user") |
1621 IncrementPrefValue(prefs::kStabilityOtherUserCrashCount); | 1620 IncrementPrefValue(prefs::kStabilityOtherUserCrashCount); |
1622 else if (crash_type == "kernel") | 1621 else if (crash_type == "kernel") |
1623 IncrementPrefValue(prefs::kStabilityKernelCrashCount); | 1622 IncrementPrefValue(prefs::kStabilityKernelCrashCount); |
1624 else if (crash_type == "uncleanshutdown") | 1623 else if (crash_type == "uncleanshutdown") |
1625 IncrementPrefValue(prefs::kStabilitySystemUncleanShutdownCount); | 1624 IncrementPrefValue(prefs::kStabilitySystemUncleanShutdownCount); |
1626 else | 1625 else |
1627 NOTREACHED() << "Unexpected Chrome OS crash type " << crash_type; | 1626 NOTREACHED() << "Unexpected Chrome OS crash type " << crash_type; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1747 child_process_stats_buffer_.clear(); | 1746 child_process_stats_buffer_.clear(); |
1748 } | 1747 } |
1749 | 1748 |
1750 bool MetricsService::CanLogNotification() { | 1749 bool MetricsService::CanLogNotification() { |
1751 // We simply don't log anything to UMA if there is a single incognito | 1750 // We simply don't log anything to UMA if there is a single incognito |
1752 // session visible. The problem is that we always notify using the orginal | 1751 // session visible. The problem is that we always notify using the orginal |
1753 // profile in order to simplify notification processing. | 1752 // profile in order to simplify notification processing. |
1754 return !chrome::IsOffTheRecordSessionActive(); | 1753 return !chrome::IsOffTheRecordSessionActive(); |
1755 } | 1754 } |
1756 | 1755 |
1757 void MetricsService::RecordBooleanPrefValue(const char* path, bool value) { | |
1758 DCHECK(IsSingleThreaded()); | |
1759 | |
1760 PrefService* pref = g_browser_process->local_state(); | |
1761 DCHECK(pref); | |
1762 | |
1763 pref->SetBoolean(path, value); | |
1764 RecordCurrentState(pref); | |
1765 } | |
1766 | |
1767 void MetricsService::RecordCurrentState(PrefService* pref) { | 1756 void MetricsService::RecordCurrentState(PrefService* pref) { |
1768 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); | 1757 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); |
1769 | 1758 |
1770 RecordPluginChanges(pref); | 1759 RecordPluginChanges(pref); |
1771 } | 1760 } |
1772 | 1761 |
1773 // static | 1762 // static |
1774 bool MetricsService::IsPluginProcess(int process_type) { | 1763 bool MetricsService::IsPluginProcess(int process_type) { |
1775 return (process_type == content::PROCESS_TYPE_PLUGIN || | 1764 return (process_type == content::PROCESS_TYPE_PLUGIN || |
1776 process_type == content::PROCESS_TYPE_PPAPI_PLUGIN || | 1765 process_type == content::PROCESS_TYPE_PPAPI_PLUGIN || |
(...skipping 14 matching lines...) Expand all Loading... | |
1791 if (local_state) { | 1780 if (local_state) { |
1792 const PrefService::Preference* uma_pref = | 1781 const PrefService::Preference* uma_pref = |
1793 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1782 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
1794 if (uma_pref) { | 1783 if (uma_pref) { |
1795 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1784 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
1796 DCHECK(success); | 1785 DCHECK(success); |
1797 } | 1786 } |
1798 } | 1787 } |
1799 return result; | 1788 return result; |
1800 } | 1789 } |
OLD | NEW |