File: media_router_metrics.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (254 lines) | stat: -rw-r--r-- 9,439 bytes parent folder | download | duplicates (8)
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
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_MEDIA_ROUTER_BROWSER_MEDIA_ROUTER_METRICS_H_
#define COMPONENTS_MEDIA_ROUTER_BROWSER_MEDIA_ROUTER_METRICS_H_

#include <optional>

#include "base/gtest_prod_util.h"
#include "base/time/time.h"
#include "components/media_router/common/media_route_provider_helper.h"
#include "components/media_router/common/media_source.h"
#include "components/media_router/common/mojom/media_router.mojom-forward.h"
#include "components/media_router/common/route_request_result.h"
#include "media/base/container_names.h"

class GURL;

namespace media_router {

enum class SinkIconType;

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused. When making changes, also update the
// enum list in tools/metrics/histograms/enums.xml to keep it in sync.

// NOTE: For metrics specific to the Media Router component extension, see
// mojo/media_router_mojo_metrics.h.

// This enum is a cartesian product of dialog activation locations and Cast
// modes. Per tools/metrics/histograms/README.md, a multidimensional histogram
// must be flattened into one dimension.
enum class DialogActivationLocationAndCastMode {
  kPinnedIconAndPresentation,
  kPinnedIconAndTabMirror,
  kPinnedIconAndDesktopMirror,
  kPinnedIconAndLocalFile,  // Obsolete.
  // One can start casting from an ephemeral icon by stopping a session, then
  // starting another from the same dialog.
  kEphemeralIconAndPresentation,
  kEphemeralIconAndTabMirror,
  kEphemeralIconAndDesktopMirror,
  kEphemeralIconAndLocalFile,  // Obsolete.
  kContextMenuAndPresentation,
  kContextMenuAndTabMirror,
  kContextMenuAndDesktopMirror,
  kContextMenuAndLocalFile,  // Obsolete.
  kPageAndPresentation,
  kPageAndTabMirror,
  kPageAndDesktopMirror,
  kPageAndLocalFile,  // Obsolete.
  kAppMenuAndPresentation,
  kAppMenuAndTabMirror,
  kAppMenuAndDesktopMirror,
  kAppMenuAndLocalFile,  // Obsolete.
  kSharingHubAndPresentation,
  kSharingHubAndTabMirror,
  kSharingHubAndDesktopMirror,
  kPinnedIconAndRemotePlayback,
  kEphemeralIconAndRemotePlayback,
  kContextMenuAndRemotePlayback,
  kPageAndRemotePlayback,
  kAppMenuAndRemotePlayback,
  kSharingHubAndRemotePlayback,

  // NOTE: Do not reorder existing entries, and add entries only immediately
  // above this line. Remember to also update
  // tools/metrics/histograms/enums.xml.
  kMaxValue = kSharingHubAndRemotePlayback,
};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// Where the user clicked to open the Media Router dialog.
enum class MediaRouterDialogActivationLocation {
  TOOLBAR = 0,
  OVERFLOW_MENU = 1,
  CONTEXTUAL_MENU = 2,
  PAGE = 3,
  APP_MENU = 4,
  SYSTEM_TRAY = 5,
  SHARING_HUB = 6,

  // NOTE: Add entries only immediately above this line. Remember to also update
  // tools/metrics/histograms/enums.xml.
  TOTAL_COUNT = 7
};

enum class PresentationUrlType {
  kOther,
  kCast,            // cast:
  kCastDial,        // cast-dial:
  kCastLegacy,      // URLs that start with |kLegacyCastPresentationUrlPrefix|.
  kDial,            // dial:
  kHttp,            // http:
  kHttps,           // https:
  kRemotePlayback,  // remote-playback:
  // Add new types only immediately above this line. Remember to also update
  // tools/metrics/histograms/enums.xml.
  kPresentationUrlTypeCount
};

enum class UiType {
  kCastDialog,
  kGlobalMediaControls,
};

enum class MediaRouterAndroidDialogType {
  kRouteController = 0,
  kRouteChooser = 1,
  kMaxValue = kRouteChooser,
};

enum class MediaRouterAndroidDialogAction {
  kTerminateRoute = 0,
  kStartRoute = 1,
  kMaxValue = kStartRoute,
};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class MediaRouterUserPromptWhenLaunchingCast {
  kPendingUserAuth = 0,
  kUserNotAllowed = 1,

  // Add new types only immediately above this line. Remember to also update
  // tools/metrics/histograms/enums.xml.
  kMaxValue = kUserNotAllowed,
};

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class MediaRouterUiPermissionRejectedViewEvents {
  kCastDialogErrorShown = 0,
  kCastDialogLinkClicked = 1,
  kGmcDialogErrorShown = 2,
  kGmcDialogLinkClicked = 3,
  kGmcDialogErrorDismissed = 4,

  kMaxValue = kGmcDialogErrorDismissed,
};

class MediaRouterMetrics {
 public:
  MediaRouterMetrics();
  ~MediaRouterMetrics();

  // UMA histogram names.
  static const char kHistogramIconClickLocation[];
  static const char kHistogramMediaRouterFileFormat[];
  static const char kHistogramMediaRouterFileSize[];
  static const char kHistogramMediaSinkType[];
  static const char kHistogramPresentationUrlType[];
  static const char kHistogramUiDeviceCount[];
  static const char kHistogramUiDialogActivationLocationAndCastMode[];
  static const char kHistogramUiDialogIconStateAtOpen[];
  static const char kHistogramUiCastDialogLoadedWithData[];
  static const char kHistogramUiGmcDialogLoadedWithData[];
  static const char kHistogramUiFirstAction[];
  static const char kHistogramUiIconStateAtInit[];
  static const char kHistogramUiAndroidDialogType[];
  static const char kHistogramUiAndroidDialogAction[];
  static const char kHistogramUiPermissionRejectedViewAction[];
  static const char kHistogramUserPromptWhenLaunchingCast[];
  static const char kHistogramPendingUserAuthLatency[];

  // When recording the number of devices shown in UI we record after a delay
  // because discovering devices can take some time after the UI is shown.
  static const base::TimeDelta kDeviceCountMetricDelay;

  // Records where the user clicked to open the Media Router dialog.
  static void RecordMediaRouterDialogActivationLocation(
      MediaRouterDialogActivationLocation activation_location);

  // Records the duration it takes for the Cast or GMC dialog to load its
  // initial data after a user clicks to open the dialog.
  static void RecordCastDialogLoaded(const base::TimeDelta& delta);
  static void RecordGmcDialogLoaded(const base::TimeDelta& delta);

  // Records the format of a cast file.
  static void RecordMediaRouterFileFormat(
      media::container_names::MediaContainerName format);

  // Records the size of a cast file.
  static void RecordMediaRouterFileSize(int64_t size);

  // Records the type of Presentation URL used by a web page.
  static void RecordPresentationUrlType(const GURL& url);

  // Records the type of the sink that media is being Cast to.
  static void RecordMediaSinkType(SinkIconType sink_icon_type);
  static void RecordMediaSinkTypeForGlobalMediaControls(
      SinkIconType sink_icon_type);
  static void RecordMediaSinkTypeForCastDialog(SinkIconType sink_icon_type);

  // Records the number of devices shown in the Cast dialog. The device count
  // may be 0.
  static void RecordDeviceCount(int device_count);

  // Records the index of the device the user has started casting to on the
  // devices list. The index starts at 0.
  static void RecordStartRouteDeviceIndex(int index);

  // Records whether or not an attempt to start casting was successful.
  static void RecordStartLocalSessionSuccessful(bool success);

  // Records whether the toolbar icon is pinned by the user pref / admin policy.
  // Recorded whenever the Cast dialog is opened.
  static void RecordIconStateAtDialogOpen(bool is_pinned);

  // Records the outcome of a create route request to a Media Route Provider.
  // This and the following methods that record ResultCode use per-provider
  // histograms.
  static void RecordCreateRouteResultCode(
      mojom::RouteRequestResultCode result_code,
      std::optional<mojom::MediaRouteProviderId> provider_id = std::nullopt);

  // Records the outcome of a join route request to a Media Route Provider.
  static void RecordJoinRouteResultCode(
      mojom::RouteRequestResultCode result_code,
      std::optional<mojom::MediaRouteProviderId> provider_id = std::nullopt);

  // Records the outcome of a call to terminateRoute() on a Media Route
  // Provider.
  static void RecordMediaRouteProviderTerminateRoute(
      mojom::RouteRequestResultCode result_code,
      std::optional<mojom::MediaRouteProviderId> provider_id = std::nullopt);

  // Records the type of the MediaRouter dialog opened. Android only.
  static void RecordMediaRouterAndroidDialogType(
      MediaRouterAndroidDialogType type);

  // Records the action taken on the MediaRouter dialog. Android only.
  static void RecordMediaRouterAndroidDialogAction(
      MediaRouterAndroidDialogAction action);

  // Records the number of times the user was asked to allow casting and the
  // number of times the user didn't allow it
  static void RecordMediaRouterUserPromptWhenLaunchingCast(
      MediaRouterUserPromptWhenLaunchingCast user_prompt);

  // Records the duration it takes between sending cast request and receiving a
  // response of UserPendingAuthorization
  static void RecordMediaRouterPendingUserAuthLatency(
      const base::TimeDelta& delta);

  static void RecordMediaRouterUiPermissionRejectedViewEvents(
      MediaRouterUiPermissionRejectedViewEvents event);
};

}  // namespace media_router

#endif  // COMPONENTS_MEDIA_ROUTER_BROWSER_MEDIA_ROUTER_METRICS_H_