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

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

Issue 8198007: Remove PrefService::ScheduleSavePersistentPrefs and SavePersistentPrefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 } 763 }
764 764
765 void MetricsService::SaveLocalState() { 765 void MetricsService::SaveLocalState() {
766 PrefService* pref = g_browser_process->local_state(); 766 PrefService* pref = g_browser_process->local_state();
767 if (!pref) { 767 if (!pref) {
768 NOTREACHED(); 768 NOTREACHED();
769 return; 769 return;
770 } 770 }
771 771
772 RecordCurrentState(pref); 772 RecordCurrentState(pref);
773 pref->ScheduleSavePersistentPrefs();
774 773
775 // TODO(jar): Does this run down the batteries???? 774 // TODO(jar): Does this run down the batteries????
776 ScheduleNextStateSave(); 775 ScheduleNextStateSave();
777 } 776 }
778 777
779 778
780 //------------------------------------------------------------------------------ 779 //------------------------------------------------------------------------------
781 // Recording control methods 780 // Recording control methods
782 781
783 void MetricsService::StartRecording() { 782 void MetricsService::StartRecording() {
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 1113
1115 case SENDING_CURRENT_LOGS: 1114 case SENDING_CURRENT_LOGS:
1116 break; 1115 break;
1117 1116
1118 default: 1117 default:
1119 NOTREACHED(); 1118 NOTREACHED();
1120 break; 1119 break;
1121 } 1120 }
1122 1121
1123 log_manager_.DiscardStagedLog(); 1122 log_manager_.DiscardStagedLog();
1124 // Since we sent a log, make sure our in-memory state is recorded to disk.
1125 PrefService* local_state = g_browser_process->local_state();
1126 DCHECK(local_state);
1127 if (local_state)
1128 local_state->ScheduleSavePersistentPrefs();
1129 1123
1130 if (log_manager_.has_unsent_logs()) 1124 if (log_manager_.has_unsent_logs())
1131 DCHECK(state_ < SENDING_CURRENT_LOGS); 1125 DCHECK(state_ < SENDING_CURRENT_LOGS);
1132 } 1126 }
1133 1127
1134 // Error 400 indicates a problem with the log, not with the server, so 1128 // Error 400 indicates a problem with the log, not with the server, so
1135 // don't consider that a sign that the server is in trouble. 1129 // don't consider that a sign that the server is in trouble.
1136 bool server_is_healthy = upload_succeeded || response_code == 400; 1130 bool server_is_healthy = upload_succeeded || response_code == 400;
1137 1131
1138 scheduler_->UploadFinished(server_is_healthy, 1132 scheduler_->UploadFinished(server_is_healthy,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 1280
1287 // For use in hack in LogCleanShutdown. 1281 // For use in hack in LogCleanShutdown.
1288 static void Signal(base::WaitableEvent* event) { 1282 static void Signal(base::WaitableEvent* event) {
1289 event->Signal(); 1283 event->Signal();
1290 } 1284 }
1291 1285
1292 void MetricsService::LogCleanShutdown() { 1286 void MetricsService::LogCleanShutdown() {
1293 // Redundant hack to write pref ASAP. 1287 // Redundant hack to write pref ASAP.
1294 PrefService* pref = g_browser_process->local_state(); 1288 PrefService* pref = g_browser_process->local_state();
1295 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); 1289 pref->SetBoolean(prefs::kStabilityExitedCleanly, true);
1296 pref->SavePersistentPrefs(); 1290 pref->CommitPendingWrite();
1297 // Hack: TBD: Remove this wait. 1291 // Hack: TBD: Remove this wait.
1298 // We are so concerned that the pref gets written, we are now willing to stall 1292 // We are so concerned that the pref gets written, we are now willing to stall
1299 // the UI thread until we get assurance that a pref-writing task has 1293 // the UI thread until we get assurance that a pref-writing task has
1300 // completed. 1294 // completed.
1301 base::WaitableEvent done_writing(false, false); 1295 base::WaitableEvent done_writing(false, false);
1302 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 1296 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
1303 NewRunnableFunction(Signal, &done_writing)); 1297 NewRunnableFunction(Signal, &done_writing));
1304 done_writing.TimedWait(base::TimeDelta::FromHours(1)); 1298 done_writing.TimedWait(base::TimeDelta::FromHours(1));
1305 1299
1306 // Redundant setting to assure that we always reset this value at shutdown 1300 // Redundant setting to assure that we always reset this value at shutdown
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 if (local_state) { 1530 if (local_state) {
1537 const PrefService::Preference* uma_pref = 1531 const PrefService::Preference* uma_pref =
1538 local_state->FindPreference(prefs::kMetricsReportingEnabled); 1532 local_state->FindPreference(prefs::kMetricsReportingEnabled);
1539 if (uma_pref) { 1533 if (uma_pref) {
1540 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 1534 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
1541 DCHECK(success); 1535 DCHECK(success);
1542 } 1536 }
1543 } 1537 }
1544 return result; 1538 return result;
1545 } 1539 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698