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

Side by Side Diff: chrome/browser/chromeos/app_mode/kiosk_app_launch_error.cc

Issue 2699833005: kiosk: UMA for launch error (Closed)
Patch Set: Created 3 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_mode/kiosk_app_launch_error.h" 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
6 6
7 #include "base/metrics/histogram_macros.h"
7 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" 9 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
9 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
11 #include "chromeos/login/auth/auth_status_consumer.h"
10 #include "components/prefs/scoped_user_pref_update.h" 12 #include "components/prefs/scoped_user_pref_update.h"
11 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
12 14
13 namespace chromeos { 15 namespace chromeos {
14 16
15 namespace { 17 namespace {
16 18
17 // Key under "kiosk" dictionary to store last launch error. 19 // Key under "kiosk" dictionary to store the last launch error.
18 const char kKeyLaunchError[] = "launch_error"; 20 constexpr char kKeyLaunchError[] = "launch_error";
21
22 // Key under "kiosk" dictionary to store the last cryptohome error.
23 constexpr char kKeyCryptohomeFailure[] = "cryptohome_failure";
19 24
20 } // namespace 25 } // namespace
21 26
22 // static 27 // static
23 std::string KioskAppLaunchError::GetErrorMessage(Error error) { 28 std::string KioskAppLaunchError::GetErrorMessage(Error error) {
24 switch (error) { 29 switch (error) {
25 case NONE: 30 case NONE:
31 case ERROR_COUNT:
26 return std::string(); 32 return std::string();
tbarzic 2017/02/28 19:18:55 I'd treat ERROR_COUNT as an unknown error - NOTREA
xiyuan 2017/02/28 21:14:57 Done.
27 33
28 case HAS_PENDING_LAUNCH: 34 case HAS_PENDING_LAUNCH:
29 case NOT_KIOSK_ENABLED: 35 case NOT_KIOSK_ENABLED:
30 case UNABLE_TO_RETRIEVE_HASH: 36 case UNABLE_TO_RETRIEVE_HASH:
31 case POLICY_LOAD_FAILED: 37 case POLICY_LOAD_FAILED:
32 case ARC_AUTH_FAILED: 38 case ARC_AUTH_FAILED:
33 return l10n_util::GetStringUTF8(IDS_KIOSK_APP_FAILED_TO_LAUNCH); 39 return l10n_util::GetStringUTF8(IDS_KIOSK_APP_FAILED_TO_LAUNCH);
34 40
35 case CRYPTOHOMED_NOT_RUNNING: 41 case CRYPTOHOMED_NOT_RUNNING:
36 case ALREADY_MOUNTED: 42 case ALREADY_MOUNTED:
(...skipping 20 matching lines...) Expand all
57 63
58 // static 64 // static
59 void KioskAppLaunchError::Save(KioskAppLaunchError::Error error) { 65 void KioskAppLaunchError::Save(KioskAppLaunchError::Error error) {
60 PrefService* local_state = g_browser_process->local_state(); 66 PrefService* local_state = g_browser_process->local_state();
61 DictionaryPrefUpdate dict_update(local_state, 67 DictionaryPrefUpdate dict_update(local_state,
62 KioskAppManager::kKioskDictionaryName); 68 KioskAppManager::kKioskDictionaryName);
63 dict_update->SetInteger(kKeyLaunchError, error); 69 dict_update->SetInteger(kKeyLaunchError, error);
64 } 70 }
65 71
66 // static 72 // static
73 void KioskAppLaunchError::SaveCryptohomeFailure(
74 const AuthFailure& auth_failure) {
75 PrefService* local_state = g_browser_process->local_state();
76 DictionaryPrefUpdate dict_update(local_state,
77 KioskAppManager::kKioskDictionaryName);
78 dict_update->SetInteger(kKeyCryptohomeFailure, auth_failure.reason());
79 }
80
81 // static
67 KioskAppLaunchError::Error KioskAppLaunchError::Get() { 82 KioskAppLaunchError::Error KioskAppLaunchError::Get() {
68 PrefService* local_state = g_browser_process->local_state(); 83 PrefService* local_state = g_browser_process->local_state();
69 const base::DictionaryValue* dict = 84 const base::DictionaryValue* dict =
70 local_state->GetDictionary(KioskAppManager::kKioskDictionaryName); 85 local_state->GetDictionary(KioskAppManager::kKioskDictionaryName);
71 86
72 int error; 87 int error;
73 if (dict->GetInteger(kKeyLaunchError, &error)) 88 if (dict->GetInteger(kKeyLaunchError, &error))
74 return static_cast<KioskAppLaunchError::Error>(error); 89 return static_cast<KioskAppLaunchError::Error>(error);
75 90
76 return KioskAppLaunchError::NONE; 91 return KioskAppLaunchError::NONE;
77 } 92 }
78 93
79 // static 94 // static
80 void KioskAppLaunchError::Clear() { 95 void KioskAppLaunchError::RecordMetricAndClear() {
81 PrefService* local_state = g_browser_process->local_state(); 96 PrefService* local_state = g_browser_process->local_state();
82 DictionaryPrefUpdate dict_update(local_state, 97 DictionaryPrefUpdate dict_update(local_state,
83 KioskAppManager::kKioskDictionaryName); 98 KioskAppManager::kKioskDictionaryName);
99
100 int error;
101 if (dict_update->GetInteger(kKeyLaunchError, &error))
102 UMA_HISTOGRAM_ENUMERATION("Kiosk.Launch.Error", error, ERROR_COUNT);
84 dict_update->Remove(kKeyLaunchError, NULL); 103 dict_update->Remove(kKeyLaunchError, NULL);
104
105 int cryptohome_failure;
106 if (dict_update->GetInteger(kKeyCryptohomeFailure, &cryptohome_failure)) {
107 UMA_HISTOGRAM_ENUMERATION("Kiosk.Launch.CryptohomeFailure",
108 cryptohome_failure,
109 AuthFailure::NUM_FAILURE_REASONS);
110 }
111 dict_update->Remove(kKeyCryptohomeFailure, NULL);
85 } 112 }
86 113
87 } // namespace chromeos 114 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698