| 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 | 10 // A MetricsService instance is typically created at application startup. It |
| (...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 // Redundant setting to be sure we call for a clean shutdown. | 1672 // Redundant setting to be sure we call for a clean shutdown. |
| 1673 clean_shutdown_status_ = NEED_TO_SHUTDOWN; | 1673 clean_shutdown_status_ = NEED_TO_SHUTDOWN; |
| 1674 } | 1674 } |
| 1675 | 1675 |
| 1676 bool MetricsService::UmaMetricsProperlyShutdown() { | 1676 bool MetricsService::UmaMetricsProperlyShutdown() { |
| 1677 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || | 1677 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || |
| 1678 clean_shutdown_status_ == NEED_TO_SHUTDOWN); | 1678 clean_shutdown_status_ == NEED_TO_SHUTDOWN); |
| 1679 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; | 1679 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; |
| 1680 } | 1680 } |
| 1681 | 1681 |
| 1682 // For use in hack in LogCleanShutdown. | |
| 1683 static void Signal(base::WaitableEvent* event) { | |
| 1684 event->Signal(); | |
| 1685 } | |
| 1686 | |
| 1687 void MetricsService::LogCleanShutdown() { | 1682 void MetricsService::LogCleanShutdown() { |
| 1688 // Redundant hack to write pref ASAP. | 1683 // Redundant hack to write pref ASAP. |
| 1689 PrefService* pref = g_browser_process->local_state(); | 1684 PrefService* pref = g_browser_process->local_state(); |
| 1690 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); | 1685 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); |
| 1691 pref->CommitPendingWrite(); | 1686 pref->CommitPendingWrite(); |
| 1692 // Hack: TBD: Remove this wait. | |
| 1693 // We are so concerned that the pref gets written, we are now willing to stall | |
| 1694 // the UI thread until we get assurance that a pref-writing task has | |
| 1695 // completed. | |
| 1696 base::WaitableEvent done_writing(false, false); | |
| 1697 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
| 1698 base::Bind(Signal, &done_writing)); | |
| 1699 // http://crbug.com/124954 | |
| 1700 base::ThreadRestrictions::ScopedAllowWait allow_wait; | |
| 1701 done_writing.TimedWait(base::TimeDelta::FromHours(1)); | |
| 1702 | |
| 1703 // Redundant setting to assure that we always reset this value at shutdown | 1687 // Redundant setting to assure that we always reset this value at shutdown |
| 1704 // (and that we don't use some alternate path, and not call LogCleanShutdown). | 1688 // (and that we don't use some alternate path, and not call LogCleanShutdown). |
| 1705 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | 1689 clean_shutdown_status_ = CLEANLY_SHUTDOWN; |
| 1706 | 1690 |
| 1707 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); | 1691 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); |
| 1708 } | 1692 } |
| 1709 | 1693 |
| 1710 #if defined(OS_CHROMEOS) | 1694 #if defined(OS_CHROMEOS) |
| 1711 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { | 1695 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { |
| 1712 if (crash_type == "user") | 1696 if (crash_type == "user") |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 if (local_state) { | 1943 if (local_state) { |
| 1960 const PrefService::Preference* uma_pref = | 1944 const PrefService::Preference* uma_pref = |
| 1961 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1945 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
| 1962 if (uma_pref) { | 1946 if (uma_pref) { |
| 1963 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1947 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
| 1964 DCHECK(success); | 1948 DCHECK(success); |
| 1965 } | 1949 } |
| 1966 } | 1950 } |
| 1967 return result; | 1951 return result; |
| 1968 } | 1952 } |
| OLD | NEW |