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