File: arc_optin_uma.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (344 lines) | stat: -rw-r--r-- 11,261 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_ASH_ARC_ARC_OPTIN_UMA_H_
#define CHROME_BROWSER_ASH_ARC_ARC_OPTIN_UMA_H_

#include <ostream>

#include "chromeos/ash/experiences/arc/mojom/app.mojom-forward.h"
#include "chromeos/ash/experiences/arc/mojom/auth.mojom-forward.h"

class Profile;

namespace base {
class TimeDelta;
}

namespace arc {

class ArcProvisioningResult;

// These enums are used to define the buckets for an enumerated UMA histogram
// and need to be synced with tools/metrics/histograms/enums.xml. Note that
// values 0, 1, 2, 3 and 4 are now deprecated.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class OptInActionType : int {
  // User asked to retry OptIn.
  RETRY = 5,

  // ARC was opted in by user from OOBE flow.
  OOBE_OPTED_IN = 6,

  // ARC was opted out by user from OOBE flow.
  OOBE_OPTED_OUT = 7,

  // ARC was opted in by user from session.
  SESSION_OPTED_IN = 8,

  // ARC was opted out by user from session.
  SESSION_OPTED_OUT = 9,

  // ARC was opted in due to configuration in OOBE flow.
  OOBE_OPTED_IN_CONFIGURATION = 10,

  kMaxValue = OOBE_OPTED_IN_CONFIGURATION,
};

enum class OptInCancelReason {
  // Canceled by user.
  USER_CANCEL = 0,

  // Unclassified failure.
  UNKNOWN_ERROR = 1,

  // Network failure.
  NETWORK_ERROR = 2,

  DEPRECATED_SERVICE_UNAVAILABLE = 3,
  DEPRECATED_BAD_AUTHENTICATION = 4,
  DEPRECATED_GMS_CORE_NOT_AVAILABLE = 5,

  // Provision failed.
  PROVISIONING_FAILED = 6,

  // Android management is required for user.
  ANDROID_MANAGEMENT_REQUIRED = 7,

  // Cannot start ARC because it is busy.
  SESSION_BUSY = 8,

  kMaxValue = SESSION_BUSY,
};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class OptInNetworkErrorActionType {
  // User closed the optin dialog.
  WINDOW_CLOSED = 0,

  // User asked to retry optin.
  RETRY = 1,

  // User asked to send feedback.
  SEND_FEEDBACK = 2,

  // User wants to diagnose network.
  CHECK_NETWORK = 3,

  // Network error page was shown. This bucket encompasses all others and works
  // as a total count for network-related errors (instead of the histogram's
  // total sample count which doesn't reflect that information). This enum
  // value was added on 2023 Dec 21. The data before this date is missing.
  ERROR_SHOWN = 4,

  kMaxValue = ERROR_SHOWN,
};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class OptInSilentAuthCode {
  // Silent auth code feature is disabled.
  DISABLED = 0,

  // Silent auth code fetched normally.
  SUCCESS = 1,

  // HTTP Context cannot be prepared.
  CONTEXT_NOT_READY = 2,

  // No LST token is available.
  NO_LST_TOKEN = 3,

  // Silent auth code failed due sever HTTP error 5XX.
  HTTP_SERVER_FAILURE = 4,

  // Silent auth code failed due client HTTP error 4XX.
  HTTP_CLIENT_FAILURE = 5,

  // Silent auth code failed due unknown HTTP error.
  HTTP_UNKNOWN_FAILURE = 6,

  // Cannot parse HTTP response.
  RESPONSE_PARSE_FAILURE = 7,

  // No Auth code in response.
  NO_AUTH_CODE_IN_RESPONSE = 8,

  // The network was configured with a mandatory PAC script that could not be
  // fetched, parsed or executed.
  MANDATORY_PROXY_CONFIGURATION_FAILED = 9,

  kMaxValue = MANDATORY_PROXY_CONFIGURATION_FAILED,
};

// The values should be listed in ascending order. They are also persisted to
// logs, and their values should therefore never be renumbered nor reused.
enum class ProvisioningStatus {
  // Provisioning was successful.
  SUCCESS = 0,

  // Unclassified failure.
  UNKNOWN_ERROR = 1,

  // Unmanaged sign-in error.
  GMS_SIGN_IN_ERROR = 2,

  // Check in error.
  GMS_CHECK_IN_ERROR = 3,

  // Managed sign-in error.
  CLOUD_PROVISION_FLOW_ERROR = 4,

  // Mojo errors.
  MOJO_VERSION_MISMATCH = 5,

  // ARC did not finish provisioning within a reasonable amount of time.
  GENERIC_PROVISIONING_TIMEOUT = 6,

  // ARC instance did not report provisioning status within a reasonable amount
  // of time.
  CHROME_PROVISIONING_TIMEOUT = 7,

  // ARC instance is stopped during the sign in procedure.
  ARC_STOPPED = 8,

  // ARC is not enabled.
  ARC_DISABLED = 9,

  // In Chrome, server communication error occurs.
  // For backward compatibility, the UMA is handled differently. Please see
  // ArcSessionManager::OnProvisioningFinished for details.
  CHROME_SERVER_COMMUNICATION_ERROR = 10,

  // Network connection is unavailable in ARC.
  NO_NETWORK_CONNECTION = 11,

  // Account type is not supported for authorization.
  UNSUPPORTED_ACCOUNT_TYPE = 12,

  // Account is not present in Chrome OS Account Manager.
  CHROME_ACCOUNT_NOT_FOUND = 13,

  kMaxValue = CHROME_ACCOUNT_NOT_FOUND,
};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class OptInFlowResult : int {
  // OptIn has started.
  STARTED = 0,

  // OptIn has been succeeded, this also includes succeeded with error cases.
  SUCCEEDED = 1,

  // OptIn has been succeeded but with retry after an error.
  SUCCEEDED_AFTER_RETRY = 2,

  // OptIn has been canceled, this also includes canceled after error cases.
  CANCELED = 3,

  // OptIn has been canceled after an error was reported.
  CANCELED_AFTER_ERROR = 4,

  kMaxValue = CANCELED_AFTER_ERROR,
};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class ArcProvisioningCheckinResult {
  kSuccess = 0,
  kUnknownError = 1,
  kTimeout = 2,
  kMaxValue = kTimeout,
};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class ArcProvisioningDpcResult {
  kSuccess = 0,
  kUnknownError = 1,
  kInvalidToken = 2,
  kAccountAddFail = 3,
  kTimeout = 4,
  kNetworkError = 5,
  kOAuthAuthException = 6,
  kOAuthIOException = 7,
  kMaxValue = kOAuthIOException,
};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class ArcProvisioningSigninResult {
  kSuccess = 0,
  kUnknownError = 1,
  kNetworkError = 2,
  kServiceUnavailable = 3,
  kAuthFailure = 4,
  kTimeout = 5,
  kMaxValue = kTimeout,
};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class ArcEnabledState {
  // ARC++ is enabled for non-managed case.
  ENABLED_NOT_MANAGED = 0,

  // ARC++ is disabled for non-managed case.
  DISABLED_NOT_MANAGED = 1,

  // ARC++ is enabled for managed case when ARC++ is forced on.
  ENABLED_MANAGED_ON = 2,

  // ARC++ is disabled for managed case when ARC++ is forced on. This can happen
  // when user declines ToS even if ARC++ is forced on.
  DISABLED_MANAGED_ON = 3,

  // ARC++ is disabled for managed case when ARC++ is forced off.
  DISABLED_MANAGED_OFF = 4,

  // ARC++ is enabled in case ARC++ is not allowed for the device. This can
  // happen for ARC++ kiosk mode.
  ENABLED_NOT_ALLOWED = 5,

  // ARC++ is disabled and ARC++ is not allowed for the device.
  DISABLED_NOT_ALLOWED = 6,

  kMaxValue = DISABLED_NOT_ALLOWED,
};

// Called from the Chrome OS metrics provider to record Arc.StateByUserType
// strictly once per every metrics recording interval. This way they are in
// every record uploaded to the server and therefore can be used to split and
// compare analysis data for all other metrics.
// TODO(shaochuan): Decouple profile-related logic and move recording to
// components/arc.
void UpdateEnabledStateByUserTypeUMA();

void UpdateOptInActionUMA(OptInActionType type);
void UpdateOptInCancelUMA(OptInCancelReason reason);
void UpdateOptInFlowResultUMA(OptInFlowResult result);
void UpdateProvisioningStatusUMA(ProvisioningStatus status,
                                 const Profile* profile);
void UpdateProvisioningDpcResultUMA(ArcProvisioningDpcResult result,
                                    const Profile* profile);
void UpdateProvisioningSigninResultUMA(ArcProvisioningSigninResult result,
                                       const Profile* profile);
void UpdateProvisioningCheckinResultUMA(ArcProvisioningCheckinResult result,
                                        const Profile* profile);
void UpdateSecondarySigninResultUMA(ProvisioningStatus status);
void UpdateProvisioningTiming(const base::TimeDelta& elapsed_time,
                              bool success,
                              const Profile* profile);
void UpdateReauthorizationResultUMA(ProvisioningStatus status,
                                    const Profile* profile);
void UpdatePlayAutoInstallRequestState(mojom::PaiFlowState state,
                                       const Profile* profile);
void UpdatePlayAutoInstallRequestTime(const base::TimeDelta& elapsed_time,
                                      const Profile* profile);
void UpdateArcUiAvailableTime(const base::TimeDelta& elapsed_time,
                              const std::string& mode,
                              const Profile* profile);
void UpdatePlayStoreLaunchTime(const base::TimeDelta& elapsed_time);
void UpdateDeferredLaunchTime(const base::TimeDelta& elapsed_time);
void UpdateOptinTosLoadResultUMA(bool success);
void UpdateSilentAuthCodeUMA(OptInSilentAuthCode state);
void UpdateSupervisionTransitionResultUMA(mojom::ManagementChangeStatus result);
void UpdateReauthorizationSilentAuthCodeUMA(OptInSilentAuthCode state);
void UpdateSecondaryAccountSilentAuthCodeUMA(OptInSilentAuthCode state);
void UpdateAuthTiming(const char* histogram_name,
                      base::TimeDelta elapsed_time,
                      const Profile* profile);
void UpdateAuthCheckinAttempts(int32_t num_attempts, const Profile* profile);
void UpdateAuthAccountCheckStatus(mojom::AccountCheckStatus status,
                                  const Profile* profile);
void UpdateAccountReauthReason(mojom::ReauthReason reason,
                               const Profile* profile);
void UpdateMainAccountResolutionStatus(
    const Profile* profile,
    mojom::MainAccountResolutionStatus status);

// Returns the enum for use in UMA stat for reporting DPC errors.
ArcProvisioningDpcResult GetDpcErrorResult(
    mojom::CloudProvisionFlowError error);
// Returns the enum for use in UMA stat for reporting signin errors.
ArcProvisioningSigninResult GetSigninErrorResult(mojom::GMSSignInError error);
// Returns the enum for use in UMA stat for reporting checkin errors.
ArcProvisioningCheckinResult GetCheckinErrorResult(
    mojom::GMSCheckInError error);

// Returns the enum for use in UMA stat and displaying error code on the UI.
// This enum should not be used anywhere else. Please work with the object
// instead.
ProvisioningStatus GetProvisioningStatus(
    const ArcProvisioningResult& provisioning_result);

// Outputs the stringified |result| to |os|. This is only for logging purposes.
std::ostream& operator<<(std::ostream& os, const ProvisioningStatus& status);

}  // namespace arc

#endif  // CHROME_BROWSER_ASH_ARC_ARC_OPTIN_UMA_H_