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

Side by Side Diff: chrome/browser/chromeos/login/screens/reset_screen.cc

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: simplify type checking Created 3 years, 5 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
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 #include "chrome/browser/chromeos/login/screens/reset_screen.h" 5 #include "chrome/browser/chromeos/login/screens/reset_screen.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 ResetScreen::~ResetScreen() { 65 ResetScreen::~ResetScreen() {
66 if (view_) 66 if (view_)
67 view_->Unbind(); 67 view_->Unbind();
68 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); 68 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this);
69 } 69 }
70 70
71 void ResetScreen::Show() { 71 void ResetScreen::Show() {
72 if (view_) 72 if (view_)
73 view_->Show(); 73 view_->Show();
74 74
75 int dialog_type = -1; // used by UMA metrics. 75 reset::DialogViewType dialog_type =
76 reset::DIALOG_VIEW_TYPE_SIZE; // used by UMA metrics.
76 77
77 ContextEditor context_editor = GetContextEditor(); 78 ContextEditor context_editor = GetContextEditor();
78 79
79 bool restart_required = !base::CommandLine::ForCurrentProcess()->HasSwitch( 80 bool restart_required = !base::CommandLine::ForCurrentProcess()->HasSwitch(
80 switches::kFirstExecAfterBoot); 81 switches::kFirstExecAfterBoot);
81 if (restart_required) { 82 if (restart_required) {
82 context_editor.SetInteger(kContextKeyScreenState, STATE_RESTART_REQUIRED); 83 context_editor.SetInteger(kContextKeyScreenState, STATE_RESTART_REQUIRED);
83 dialog_type = reset::DIALOG_SHORTCUT_RESTART_REQUIRED; 84 dialog_type = reset::DIALOG_SHORTCUT_RESTART_REQUIRED;
84 } else { 85 } else {
85 context_editor.SetInteger(kContextKeyScreenState, STATE_POWERWASH_PROPOSAL); 86 context_editor.SetInteger(kContextKeyScreenState, STATE_POWERWASH_PROPOSAL);
86 } 87 }
87 88
88 // Set availability of Rollback feature. 89 // Set availability of Rollback feature.
89 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 90 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
90 switches::kDisableRollbackOption)) { 91 switches::kDisableRollbackOption)) {
91 context_editor.SetBoolean(kContextKeyIsRollbackAvailable, false); 92 context_editor.SetBoolean(kContextKeyIsRollbackAvailable, false);
92 dialog_type = reset::DIALOG_SHORTCUT_OFFERING_ROLLBACK_UNAVAILABLE; 93 dialog_type = reset::DIALOG_SHORTCUT_OFFERING_ROLLBACK_UNAVAILABLE;
93 } else { 94 } else {
94 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> 95 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->
95 CanRollbackCheck(base::Bind(&ResetScreen::OnRollbackCheck, 96 CanRollbackCheck(base::Bind(&ResetScreen::OnRollbackCheck,
96 weak_ptr_factory_.GetWeakPtr())); 97 weak_ptr_factory_.GetWeakPtr()));
97 } 98 }
98 99
99 if (dialog_type >= 0) { 100 if (dialog_type < reset::DIALOG_VIEW_TYPE_SIZE) {
100 UMA_HISTOGRAM_ENUMERATION("Reset.ChromeOS.PowerwashDialogShown", 101 UMA_HISTOGRAM_ENUMERATION("Reset.ChromeOS.PowerwashDialogShown",
101 dialog_type, 102 dialog_type,
102 reset::DIALOG_VIEW_TYPE_SIZE); 103 reset::DIALOG_VIEW_TYPE_SIZE);
103 } 104 }
104 105
105 PrefService* prefs = g_browser_process->local_state(); 106 PrefService* prefs = g_browser_process->local_state();
106 prefs->SetBoolean(prefs::kFactoryResetRequested, false); 107 prefs->SetBoolean(prefs::kFactoryResetRequested, false);
107 prefs->CommitPendingWrite(); 108 prefs->CommitPendingWrite();
108 } 109 }
109 110
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 !context_.GetBoolean(kContextKeyIsRollbackChecked)) { 198 !context_.GetBoolean(kContextKeyIsRollbackChecked)) {
198 UMA_HISTOGRAM_ENUMERATION( 199 UMA_HISTOGRAM_ENUMERATION(
199 "Reset.ChromeOS.PowerwashDialogShown", 200 "Reset.ChromeOS.PowerwashDialogShown",
200 reset::DIALOG_SHORTCUT_OFFERING_ROLLBACK_AVAILABLE, 201 reset::DIALOG_SHORTCUT_OFFERING_ROLLBACK_AVAILABLE,
201 reset::DIALOG_VIEW_TYPE_SIZE); 202 reset::DIALOG_VIEW_TYPE_SIZE);
202 GetContextEditor().SetBoolean(kContextKeyIsRollbackChecked, true); 203 GetContextEditor().SetBoolean(kContextKeyIsRollbackChecked, true);
203 } 204 }
204 } 205 }
205 206
206 void ResetScreen::OnShowConfirm() { 207 void ResetScreen::OnShowConfirm() {
207 int dialog_type = context_.GetBoolean(kContextKeyIsRollbackChecked) ? 208 reset::DialogViewType dialog_type =
208 reset::DIALOG_SHORTCUT_CONFIRMING_POWERWASH_AND_ROLLBACK : 209 context_.GetBoolean(kContextKeyIsRollbackChecked)
209 reset::DIALOG_SHORTCUT_CONFIRMING_POWERWASH_ONLY; 210 ? reset::DIALOG_SHORTCUT_CONFIRMING_POWERWASH_AND_ROLLBACK
211 : reset::DIALOG_SHORTCUT_CONFIRMING_POWERWASH_ONLY;
210 UMA_HISTOGRAM_ENUMERATION( 212 UMA_HISTOGRAM_ENUMERATION(
211 "Reset.ChromeOS.PowerwashDialogShown", 213 "Reset.ChromeOS.PowerwashDialogShown",
212 dialog_type, 214 dialog_type,
213 reset::DIALOG_VIEW_TYPE_SIZE); 215 reset::DIALOG_VIEW_TYPE_SIZE);
214 216
215 GetContextEditor().SetBoolean(kContextKeyIsConfirmational, true); 217 GetContextEditor().SetBoolean(kContextKeyIsConfirmational, true);
216 } 218 }
217 219
218 void ResetScreen::OnLearnMore() { 220 void ResetScreen::OnLearnMore() {
219 #if defined(OFFICIAL_BUILD) 221 #if defined(OFFICIAL_BUILD)
(...skipping 22 matching lines...) Expand all
242 get_base_screen_delegate()->ShowErrorScreen(); 244 get_base_screen_delegate()->ShowErrorScreen();
243 } else if (status.status == 245 } else if (status.status ==
244 UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) { 246 UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) {
245 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); 247 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
246 } 248 }
247 } 249 }
248 250
249 // Invoked from call to CanRollbackCheck upon completion of the DBus call. 251 // Invoked from call to CanRollbackCheck upon completion of the DBus call.
250 void ResetScreen::OnRollbackCheck(bool can_rollback) { 252 void ResetScreen::OnRollbackCheck(bool can_rollback) {
251 VLOG(1) << "Callback from CanRollbackCheck, result " << can_rollback; 253 VLOG(1) << "Callback from CanRollbackCheck, result " << can_rollback;
252 int dialog_type = can_rollback ? 254 reset::DialogViewType dialog_type =
253 reset::DIALOG_SHORTCUT_OFFERING_ROLLBACK_AVAILABLE : 255 can_rollback ? reset::DIALOG_SHORTCUT_OFFERING_ROLLBACK_AVAILABLE
254 reset::DIALOG_SHORTCUT_OFFERING_ROLLBACK_UNAVAILABLE; 256 : reset::DIALOG_SHORTCUT_OFFERING_ROLLBACK_UNAVAILABLE;
255 UMA_HISTOGRAM_ENUMERATION("Reset.ChromeOS.PowerwashDialogShown", 257 UMA_HISTOGRAM_ENUMERATION("Reset.ChromeOS.PowerwashDialogShown",
256 dialog_type, 258 dialog_type,
257 reset::DIALOG_VIEW_TYPE_SIZE); 259 reset::DIALOG_VIEW_TYPE_SIZE);
258 260
259 GetContextEditor().SetBoolean(kContextKeyIsRollbackAvailable, can_rollback); 261 GetContextEditor().SetBoolean(kContextKeyIsRollbackAvailable, can_rollback);
260 } 262 }
261 263
262 ErrorScreen* ResetScreen::GetErrorScreen() { 264 ErrorScreen* ResetScreen::GetErrorScreen() {
263 return get_base_screen_delegate()->GetErrorScreen(); 265 return get_base_screen_delegate()->GetErrorScreen();
264 } 266 }
265 267
266 } // namespace chromeos 268 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/reauth_stats.cc ('k') | chrome/browser/chromeos/policy/upload_job_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698