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 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1716 // Redundant setting to be sure we call for a clean shutdown. | 1716 // Redundant setting to be sure we call for a clean shutdown. |
1717 clean_shutdown_status_ = NEED_TO_SHUTDOWN; | 1717 clean_shutdown_status_ = NEED_TO_SHUTDOWN; |
1718 } | 1718 } |
1719 | 1719 |
1720 bool MetricsService::UmaMetricsProperlyShutdown() { | 1720 bool MetricsService::UmaMetricsProperlyShutdown() { |
1721 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || | 1721 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || |
1722 clean_shutdown_status_ == NEED_TO_SHUTDOWN); | 1722 clean_shutdown_status_ == NEED_TO_SHUTDOWN); |
1723 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; | 1723 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; |
1724 } | 1724 } |
1725 | 1725 |
1726 // For use in hack in LogCleanShutdown. | |
1727 static void Signal(base::WaitableEvent* event) { | |
1728 event->Signal(); | |
1729 } | |
1730 | |
1731 void MetricsService::LogCleanShutdown() { | 1726 void MetricsService::LogCleanShutdown() { |
1732 // Redundant hack to write pref ASAP. | 1727 // Redundant hack to write pref ASAP. |
1733 PrefService* pref = g_browser_process->local_state(); | 1728 PrefService* pref = g_browser_process->local_state(); |
1734 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); | 1729 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); |
1735 pref->CommitPendingWrite(); | 1730 pref->CommitPendingWrite(); |
1736 // Hack: TBD: Remove this wait. | |
1737 // We are so concerned that the pref gets written, we are now willing to stall | |
1738 // the UI thread until we get assurance that a pref-writing task has | |
1739 // completed. | |
1740 base::WaitableEvent done_writing(false, false); | |
1741 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
1742 base::Bind(Signal, &done_writing)); | |
1743 // http://crbug.com/124954 | |
1744 base::ThreadRestrictions::ScopedAllowWait allow_wait; | |
1745 done_writing.TimedWait(base::TimeDelta::FromHours(1)); | |
1746 | |
1747 // Redundant setting to assure that we always reset this value at shutdown | 1731 // Redundant setting to assure that we always reset this value at shutdown |
1748 // (and that we don't use some alternate path, and not call LogCleanShutdown). | 1732 // (and that we don't use some alternate path, and not call LogCleanShutdown). |
1749 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | 1733 clean_shutdown_status_ = CLEANLY_SHUTDOWN; |
1750 | 1734 |
1751 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); | 1735 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); |
1752 } | 1736 } |
1753 | 1737 |
1754 #if defined(OS_CHROMEOS) | 1738 #if defined(OS_CHROMEOS) |
1755 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { | 1739 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { |
1756 if (crash_type == "user") | 1740 if (crash_type == "user") |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2003 if (local_state) { | 1987 if (local_state) { |
2004 const PrefService::Preference* uma_pref = | 1988 const PrefService::Preference* uma_pref = |
2005 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1989 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
2006 if (uma_pref) { | 1990 if (uma_pref) { |
2007 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1991 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
2008 DCHECK(success); | 1992 DCHECK(success); |
2009 } | 1993 } |
2010 } | 1994 } |
2011 return result; | 1995 return result; |
2012 } | 1996 } |
OLD | NEW |