Commit 4e5544c5 authored by Jesse Schettler's avatar Jesse Schettler Committed by Chromium LUCI CQ

scanning: Create histogram for ready time

The histogram records the time between sending a request for scanners
and receiving capabilities for the selected scanner (i.e. the time that
passes before being able to perform a scan).

Bug: 1059779
Change-Id: I8be9453945054848d1b534bf43ba29e2653731da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2597656Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Reviewed-by: default avatarWeilun Shi <sweilun@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Jesse Schettler <jschettler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841078}
parent c36e1f85
......@@ -245,6 +245,7 @@ ScanService::ScanService(LorgnetteScannerManager* lorgnette_scanner_manager,
ScanService::~ScanService() = default;
void ScanService::GetScanners(GetScannersCallback callback) {
get_scanners_time_ = base::TimeTicks::Now();
lorgnette_scanner_manager_->GetScannerNames(
base::BindOnce(&ScanService::OnScannerNamesReceived,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
......@@ -351,6 +352,18 @@ void ScanService::OnScannerCapabilitiesReceived(
return;
}
// If this is the first time capabilities have been received since the last
// call to GetScanners(), record the time between the two events to capture
// the time between the Scan app launching and the user being able to interact
// with the app (e.g. select a scanner, change scan settings, or start a
// scan). If the user selects a different scanner and new capabilities are
// received, don't record the metric again.
if (!get_scanners_time_.is_null()) {
base::UmaHistogramMediumTimes("Scanning.ReadyTime",
base::TimeTicks::Now() - get_scanners_time_);
get_scanners_time_ = base::TimeTicks();
}
std::move(callback).Run(
mojo::ConvertTo<mojo_ipc::ScannerCapabilitiesPtr>(capabilities.value()));
}
......
......@@ -157,6 +157,10 @@ class ScanService : public scanning::mojom::ScanService, public KeyedService {
// Tracks the number of pages scanned for histogram recording.
int num_pages_scanned_;
// The time at which GetScanners() is called. Used to record the time between
// a user launching the Scan app and being able to interact with it.
base::TimeTicks get_scanners_time_;
base::WeakPtrFactory<ScanService> weak_ptr_factory_{this};
};
......
......@@ -40,6 +40,18 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
<summary>Records the number of pages scanned in a successful scan.</summary>
</histogram>
<histogram name="Scanning.ReadyTime" units="ms" expires_after="2021-12-04">
<owner>gavinwill@chromium.org</owner>
<owner>jschettler@chromium.org</owner>
<owner>cros-peripherals@google.com</owner>
<summary>
Records the time between sending a request for scanners and receiving
capabilities for the selected scanner, which is essentially the time between
the user launching the Scan app and being able to interact with it to select
a scanner, change scan settings, or start a scan.
</summary>
</histogram>
<histogram name="Scanning.ScanAppEntryPoint" enum="ScanAppEntryPoint"
expires_after="2021-12-04">
<owner>gavinwill@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