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

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

Issue 11027070: Moved JsonPrefStore to use SequencedWorkerPool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
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 10 // A MetricsService instance is typically created at application startup. It
(...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 // Redundant setting to be sure we call for a clean shutdown. 1662 // Redundant setting to be sure we call for a clean shutdown.
1663 clean_shutdown_status_ = NEED_TO_SHUTDOWN; 1663 clean_shutdown_status_ = NEED_TO_SHUTDOWN;
1664 } 1664 }
1665 1665
1666 bool MetricsService::UmaMetricsProperlyShutdown() { 1666 bool MetricsService::UmaMetricsProperlyShutdown() {
1667 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || 1667 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN ||
1668 clean_shutdown_status_ == NEED_TO_SHUTDOWN); 1668 clean_shutdown_status_ == NEED_TO_SHUTDOWN);
1669 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; 1669 return clean_shutdown_status_ == CLEANLY_SHUTDOWN;
1670 } 1670 }
1671 1671
1672 // For use in hack in LogCleanShutdown.
1673 static void Signal(base::WaitableEvent* event) {
1674 event->Signal();
1675 }
1676
1677 void MetricsService::LogCleanShutdown() { 1672 void MetricsService::LogCleanShutdown() {
1678 // Redundant hack to write pref ASAP. 1673 // Redundant hack to write pref ASAP.
1679 PrefService* pref = g_browser_process->local_state(); 1674 PrefService* pref = g_browser_process->local_state();
1680 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); 1675 pref->SetBoolean(prefs::kStabilityExitedCleanly, true);
1681 pref->CommitPendingWrite(); 1676 pref->CommitPendingWrite();
1682 // Hack: TBD: Remove this wait.
1683 // We are so concerned that the pref gets written, we are now willing to stall
1684 // the UI thread until we get assurance that a pref-writing task has
1685 // completed.
1686 base::WaitableEvent done_writing(false, false);
1687 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
1688 base::Bind(Signal, &done_writing));
1689 // http://crbug.com/124954
1690 base::ThreadRestrictions::ScopedAllowWait allow_wait;
1691 done_writing.TimedWait(base::TimeDelta::FromHours(1));
1692
1693 // Redundant setting to assure that we always reset this value at shutdown 1677 // Redundant setting to assure that we always reset this value at shutdown
1694 // (and that we don't use some alternate path, and not call LogCleanShutdown). 1678 // (and that we don't use some alternate path, and not call LogCleanShutdown).
1695 clean_shutdown_status_ = CLEANLY_SHUTDOWN; 1679 clean_shutdown_status_ = CLEANLY_SHUTDOWN;
1696 1680
1697 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true); 1681 RecordBooleanPrefValue(prefs::kStabilityExitedCleanly, true);
1698 } 1682 }
1699 1683
1700 #if defined(OS_CHROMEOS) 1684 #if defined(OS_CHROMEOS)
1701 void MetricsService::LogChromeOSCrash(const std::string &crash_type) { 1685 void MetricsService::LogChromeOSCrash(const std::string &crash_type) {
1702 if (crash_type == "user") 1686 if (crash_type == "user")
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 if (local_state) { 1933 if (local_state) {
1950 const PrefService::Preference* uma_pref = 1934 const PrefService::Preference* uma_pref =
1951 local_state->FindPreference(prefs::kMetricsReportingEnabled); 1935 local_state->FindPreference(prefs::kMetricsReportingEnabled);
1952 if (uma_pref) { 1936 if (uma_pref) {
1953 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 1937 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
1954 DCHECK(success); 1938 DCHECK(success);
1955 } 1939 }
1956 } 1940 }
1957 return result; 1941 return result;
1958 } 1942 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698