Commit 216b3a76 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

capture_mode: Record histogram for time from screen record length.

This gives a general idea of how long the videos saved on file are. I
looked into adding a test (ps1), but with the multi-threading and async
operations I'm afraid it would be flaky, plus it saved some recording
files locally.

Test: manual
Bug: 1140182
Change-Id: Ib471d6eae0a8c49321984d941fb0775f49ca11a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2519853Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824616}
parent aa8b4a65
...@@ -50,6 +50,9 @@ CaptureModeController* g_instance = nullptr; ...@@ -50,6 +50,9 @@ CaptureModeController* g_instance = nullptr;
constexpr char kEntryHistogramName[] = "Ash.CaptureModeController.EntryPoint"; constexpr char kEntryHistogramName[] = "Ash.CaptureModeController.EntryPoint";
constexpr char kRecordTimeHistogramName[] =
"Ash.CaptureModeController.ScreenRecordingLength";
constexpr char kScreenCaptureNotificationId[] = "capture_mode_notification"; constexpr char kScreenCaptureNotificationId[] = "capture_mode_notification";
constexpr char kScreenCaptureStoppedNotificationId[] = constexpr char kScreenCaptureStoppedNotificationId[] =
"capture_mode_stopped_notification"; "capture_mode_stopped_notification";
...@@ -494,12 +497,22 @@ void CaptureModeController::OnVideoFileSaved(bool success) { ...@@ -494,12 +497,22 @@ void CaptureModeController::OnVideoFileSaved(bool success) {
// TODO(afakhry): The file will be empty now until the recording service is // TODO(afakhry): The file will be empty now until the recording service is
// implemented. // implemented.
if (!success) if (!success) {
ShowFailureNotification(); ShowFailureNotification();
else } else {
ShowPreviewNotification(current_video_file_path_, gfx::Image(), ShowPreviewNotification(current_video_file_path_, gfx::Image(),
CaptureModeType::kVideo); CaptureModeType::kVideo);
DCHECK(!recording_start_time_.is_null());
// 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(
kRecordTimeHistogramName,
(base::TimeTicks::Now() - recording_start_time_).InSeconds(), /*min=*/1,
/*max=*/base::TimeDelta::FromHours(3).InSeconds(),
/*bucket_count=*/50);
}
recording_start_time_ = base::TimeTicks();
current_video_file_path_.clear(); current_video_file_path_.clear();
video_file_handler_.Reset(); video_file_handler_.Reset();
} }
...@@ -629,6 +642,7 @@ void CaptureModeController::OnVideoRecordCountDownFinished() { ...@@ -629,6 +642,7 @@ void CaptureModeController::OnVideoRecordCountDownFinished() {
// in. // in.
constexpr size_t kVideoBufferCapacityBytes = 20; constexpr size_t kVideoBufferCapacityBytes = 20;
DCHECK(current_video_file_path_.empty()); DCHECK(current_video_file_path_.empty());
recording_start_time_ = base::TimeTicks::Now();
current_video_file_path_ = BuildVideoPath(base::Time::Now()); current_video_file_path_ = BuildVideoPath(base::Time::Now());
video_file_handler_ = VideoFileHandler::Create( video_file_handler_ = VideoFileHandler::Create(
task_runner_, current_video_file_path_, kVideoBufferCapacityBytes); task_runner_, current_video_file_path_, kVideoBufferCapacityBytes);
......
...@@ -204,6 +204,11 @@ class ASH_EXPORT CaptureModeController { ...@@ -204,6 +204,11 @@ class ASH_EXPORT CaptureModeController {
int num_screenshots_taken_in_last_day_ = 0; int num_screenshots_taken_in_last_day_ = 0;
int num_screenshots_taken_in_last_week_ = 0; int num_screenshots_taken_in_last_week_ = 0;
// The time when OnVideoRecordCountDownFinished is called and video has
// started recording. It is used when video has finished recording for metrics
// collection.
base::TimeTicks recording_start_time_;
base::WeakPtrFactory<CaptureModeController> weak_ptr_factory_{this}; base::WeakPtrFactory<CaptureModeController> weak_ptr_factory_{this};
}; };
......
...@@ -198,6 +198,18 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -198,6 +198,18 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</token> </token>
</histogram> </histogram>
<histogram name="Ash.CaptureModeController.ScreenRecordingLength"
units="seconds" expires_after="2021-11-04">
<owner>afakhry@chromium.org</owner>
<owner>chinsenj@chromium.org</owner>
<owner>gzadina@google.com</owner>
<summary>
Records the time of a successful video recording in capture mode. This
metric will not be recorded if a file was not successfully saved. The upper
limit of this histogram is 3 hours.
</summary>
</histogram>
<histogram name="Ash.CaptureModeController.ScreenshotsPerDay" units="int" <histogram name="Ash.CaptureModeController.ScreenshotsPerDay" units="int"
expires_after="2021-09-29"> expires_after="2021-09-29">
<owner>afakhry@chromium.org</owner> <owner>afakhry@chromium.org</owner>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment