forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapture_mode_metrics.cc
217 lines (186 loc) · 8.97 KB
/
capture_mode_metrics.cc
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
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/capture_mode/capture_mode_metrics.h"
#include "ash/shell.h"
#include "base/metrics/histogram_functions.h"
namespace ash {
namespace {
constexpr char kEndRecordingReasonHistogramName[] =
"Ash.CaptureModeController.EndRecordingReason";
constexpr char kBarButtonHistogramName[] =
"Ash.CaptureModeController.BarButtons";
constexpr char kCaptureAudioOnHistogramName[] =
"Ash.CaptureModeController.CaptureAudioOnMetric";
constexpr char kCaptureConfigurationHistogramName[] =
"Ash.CaptureModeController.CaptureConfiguration";
constexpr char kCaptureRegionAdjustmentHistogramName[] =
"Ash.CaptureModeController.CaptureRegionAdjusted";
constexpr char kConsecutiveScreenshotHistogramName[] =
"Ash.CaptureModeController.ConsecutiveScreenshots";
constexpr char kEntryHistogramName[] = "Ash.CaptureModeController.EntryPoint";
constexpr char kQuickActionHistogramName[] =
"Ash.CaptureModeController.QuickAction";
constexpr char kRecordTimeHistogramName[] =
"Ash.CaptureModeController.ScreenRecordingLength";
constexpr char kSaveToLocationHistogramName[] =
"Ash.CaptureModeController.SaveLocation";
constexpr char kScreenshotsPerDayHistogramName[] =
"Ash.CaptureModeController.ScreenshotsPerDay";
constexpr char kScreenshotsPerWeekHistogramName[] =
"Ash.CaptureModeController.ScreenshotsPerWeek";
constexpr char kSwitchesFromInitialModeHistogramName[] =
"Ash.CaptureModeController.SwitchesFromInitialCaptureMode";
constexpr char kSwitchToDefaultFolderReasonHistogramName[] =
"Ash.CaptureModeController.SwitchToDefaultReason";
constexpr char kProjectorCaptureConfigurationHistogramName[] =
"Ash.CaptureModeController.Projector.CaptureConfiguration";
constexpr char kProjectorCaptureRegionAdjustmentHistogramName[] =
"Ash.CaptureModeController.Projector.CaptureRegionAdjusted";
constexpr char kProjectorRecordTimeHistogramName[] =
"Ash.CaptureModeController.Projector.ScreenRecordingLength";
constexpr char kRecordingStartsWithCamera[] =
"Ash.CaptureModeController.RecordingStartsWithCamera";
constexpr char kProjectorRecordingStartsWithCamera[] =
"Ash.CaptureModeController.Projector.RecordingStartsWithCamera";
constexpr char kCameraDisconnectionsDuringRecordings[] =
"Ash.CaptureModeController.CameraDisconnectionsDuringRecordings";
constexpr char kCameraReconnectDuration[] =
"Ash.CaptureModeController.CameraReconnectDuration";
constexpr char kRecordingCameraSizeOnStart[] =
"Ash.CaptureModeController.RecordingCameraSizeOnStart";
constexpr char kRecordingCameraPositionOnStart[] =
"Ash.CaptureModeController.RecordingCameraPositionOnStart";
constexpr char kNumberOfConnectedCameras[] =
"Ash.CaptureModeController.NumberOfConnectedCameras";
} // namespace
void RecordEndRecordingReason(EndRecordingReason reason) {
base::UmaHistogramEnumeration(
GetCaptureModeHistogramName(kEndRecordingReasonHistogramName), reason);
}
void RecordCaptureModeBarButtonType(CaptureModeBarButtonType button_type) {
base::UmaHistogramEnumeration(
GetCaptureModeHistogramName(kBarButtonHistogramName), button_type);
}
void RecordCaptureModeConfiguration(CaptureModeType type,
CaptureModeSource source,
bool audio_on,
bool is_in_projector_mode) {
const std::string histogram_name = GetCaptureModeHistogramName(
is_in_projector_mode ? kProjectorCaptureConfigurationHistogramName
: kCaptureConfigurationHistogramName);
base::UmaHistogramEnumeration(histogram_name, GetConfiguration(type, source));
if (type == CaptureModeType::kVideo) {
base::UmaHistogramBoolean(
GetCaptureModeHistogramName(kCaptureAudioOnHistogramName), audio_on);
}
}
void RecordCaptureModeEntryType(CaptureModeEntryType entry_type) {
base::UmaHistogramEnumeration(
GetCaptureModeHistogramName(kEntryHistogramName), entry_type);
}
void RecordCaptureModeRecordTime(int64_t length_in_seconds,
bool is_in_projector_mode) {
const std::string histogram_name = GetCaptureModeHistogramName(
is_in_projector_mode ? kProjectorRecordTimeHistogramName
: kRecordTimeHistogramName);
// Use custom counts macro instead of custom times so we can record in
// seconds instead of milliseconds. The max bucket is 3 hours.
base::UmaHistogramCustomCounts(histogram_name, length_in_seconds,
/*min=*/1,
/*max=*/base::Hours(3).InSeconds(),
/*bucket_count=*/50);
}
void RecordCaptureModeSwitchesFromInitialMode(bool switched) {
base::UmaHistogramBoolean(kSwitchesFromInitialModeHistogramName, switched);
}
void RecordNumberOfCaptureRegionAdjustments(int num_adjustments,
bool is_in_projector_mode) {
const std::string histogram_name = GetCaptureModeHistogramName(
is_in_projector_mode ? kProjectorCaptureRegionAdjustmentHistogramName
: kCaptureRegionAdjustmentHistogramName);
base::UmaHistogramCounts100(histogram_name, num_adjustments);
}
void RecordNumberOfConsecutiveScreenshots(int num_consecutive_screenshots) {
if (num_consecutive_screenshots > 1) {
base::UmaHistogramCounts100(kConsecutiveScreenshotHistogramName,
num_consecutive_screenshots);
}
}
void RecordNumberOfScreenshotsTakenInLastDay(
int num_screenshots_taken_in_last_day) {
base::UmaHistogramCounts100(kScreenshotsPerDayHistogramName,
num_screenshots_taken_in_last_day);
}
void RecordNumberOfScreenshotsTakenInLastWeek(
int num_screenshots_taken_in_last_week) {
base::UmaHistogramCounts100(kScreenshotsPerWeekHistogramName,
num_screenshots_taken_in_last_week);
}
void RecordScreenshotNotificationQuickAction(CaptureQuickAction action) {
base::UmaHistogramEnumeration(kQuickActionHistogramName, action);
}
void RecordSaveToLocation(CaptureModeSaveToLocation save_location) {
base::UmaHistogramEnumeration(
GetCaptureModeHistogramName(kSaveToLocationHistogramName), save_location);
}
void RecordSwitchToDefaultFolderReason(
CaptureModeSwitchToDefaultReason reason) {
base::UmaHistogramEnumeration(
GetCaptureModeHistogramName(kSwitchToDefaultFolderReasonHistogramName),
reason);
}
CaptureModeConfiguration GetConfiguration(CaptureModeType type,
CaptureModeSource source) {
switch (source) {
case CaptureModeSource::kFullscreen:
return type == CaptureModeType::kImage
? CaptureModeConfiguration::kFullscreenScreenshot
: CaptureModeConfiguration::kFullscreenRecording;
case CaptureModeSource::kRegion:
return type == CaptureModeType::kImage
? CaptureModeConfiguration::kRegionScreenshot
: CaptureModeConfiguration::kRegionRecording;
case CaptureModeSource::kWindow:
return type == CaptureModeType::kImage
? CaptureModeConfiguration::kWindowScreenshot
: CaptureModeConfiguration::kWindowRecording;
}
}
void RecordRecordingStartsWithCamera(bool starts_with_camera,
bool is_in_projector_mode) {
const std::string histogram_name = is_in_projector_mode
? kProjectorRecordingStartsWithCamera
: kRecordingStartsWithCamera;
base::UmaHistogramBoolean(GetCaptureModeHistogramName(histogram_name),
starts_with_camera);
}
void RecordCameraDisconnectionsDuringRecordings(int num_camera_disconnections) {
base::UmaHistogramCounts100(
GetCaptureModeHistogramName(kCameraDisconnectionsDuringRecordings),
num_camera_disconnections);
}
void RecordNumberOfConnectedCameras(int num_camera_connected) {
base::UmaHistogramCounts100(kNumberOfConnectedCameras, num_camera_connected);
}
void RecordCameraReconnectDuration(int length_in_seconds,
int grace_period_in_seconds) {
base::UmaHistogramCustomCounts(
GetCaptureModeHistogramName(kCameraReconnectDuration), length_in_seconds,
0, grace_period_in_seconds, grace_period_in_seconds);
}
void RecordCameraSizeOnStart(CaptureModeCameraSize camera_size) {
base::UmaHistogramEnumeration(
GetCaptureModeHistogramName(kRecordingCameraSizeOnStart), camera_size);
}
void RecordCameraPositionOnStart(CameraPreviewSnapPosition camera_position) {
base::UmaHistogramEnumeration(
GetCaptureModeHistogramName(kRecordingCameraPositionOnStart),
camera_position);
}
std::string GetCaptureModeHistogramName(std::string prefix) {
prefix.append(Shell::Get()->IsInTabletMode() ? ".TabletMode"
: ".ClamshellMode");
return prefix;
}
} // namespace ash