Commit bdd4720d authored by Michael Bai's avatar Michael Bai Committed by Commit Bot

ContentCapture: Fix the wrong TaskDelayTimeInMs

Starts recording when the task is actually scheduled.

Currently the recording is reset for every change, it caused
the task delay time is shorter than it should to be.

Test: passing existing test.
Bug: 112742
Change-Id: I5c31a286b483d4f68ee892b9aa850aadaf62dc49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404799Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806310}
parent 990a1c6d
......@@ -278,6 +278,10 @@ void ContentCaptureTask::ScheduleInternal(ScheduleReason reason) {
delay_task_->StartOneShot(delay, FROM_HERE);
TRACE_EVENT_INSTANT1("content_capture", "ScheduleTask",
TRACE_EVENT_SCOPE_THREAD, "reason", reason);
if (histogram_reporter_) {
histogram_reporter_->OnTaskScheduled(/* record_task_delay = */ reason !=
ScheduleReason::kRetryTask);
}
}
void ContentCaptureTask::Schedule(ScheduleReason reason) {
......
......@@ -29,14 +29,18 @@ ContentCaptureTaskHistogramReporter::~ContentCaptureTaskHistogramReporter() =
default;
void ContentCaptureTaskHistogramReporter::OnContentChanged() {
// Always save the latest schedule time.
task_scheduled_time_ = base::TimeTicks::Now();
if (content_change_time_)
return;
content_change_time_ = base::TimeTicks::Now();
}
void ContentCaptureTaskHistogramReporter::OnTaskScheduled(
bool record_task_delay) {
// Always save the latest schedule time.
task_scheduled_time_ =
record_task_delay ? base::TimeTicks::Now() : base::TimeTicks();
}
void ContentCaptureTaskHistogramReporter::OnTaskRun() {
if (!task_scheduled_time_.is_null()) {
task_delay_time_in_ms_histogram_.CountMilliseconds(base::TimeTicks::Now() -
......
......@@ -29,6 +29,7 @@ class CORE_EXPORT ContentCaptureTaskHistogramReporter
~ContentCaptureTaskHistogramReporter();
void OnContentChanged();
void OnTaskScheduled(bool record_task_delay);
void OnTaskRun();
void OnCaptureContentStarted();
void OnCaptureContentEnded(size_t captured_content_count);
......@@ -47,7 +48,8 @@ class CORE_EXPORT ContentCaptureTaskHistogramReporter
base::TimeTicks capture_content_start_time_;
// The time to start sending content.
base::TimeTicks send_content_start_time_;
// The time when the task is scheduled.
// The time when the task is scheduled, is valid if kTaskDelayInMs needs to be
// recorded.
base::TimeTicks task_scheduled_time_;
// Records time from first content change to content that has been sent, its
......
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