Commit 7f60d255 authored by hirono's avatar hirono Committed by Commit bot

Files.app: Add UMA for HardUnplugged events.

The CL adds UMA for the number of seconds:

 * between HardUnplugged event and Suspend event
 * between SuspendDone event and HardUnplugged event

The numbers are needed for setting the best suppresing time for the hard
unplugged event.

BUG=433734
TEST=None

Review URL: https://codereview.chromium.org/723923004

Cr-Commit-Position: refs/heads/master@{#306523}
parent 40fe0302
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/thread_task_runner_handle.h"
#include "chrome/browser/chromeos/extensions/file_manager/device_event_router.h"
#include "chrome/browser/chromeos/file_manager/volume_manager.h"
......@@ -80,6 +81,13 @@ void DeviceEventRouter::OnDiskRemoved(
const std::string& device_path = disk.system_path_prefix();
if (!disk.mount_path().empty() &&
GetDeviceState(device_path) != DEVICE_HARD_UNPLUGGED_AND_REPORTED) {
// TODO(hirono): Remove the temporary UMA. crbug.com/433734
if (!last_suspend_done_.is_null()) {
UMA_HISTOGRAM_MEDIUM_TIMES(
"FileBrowser.HardUnpluggedAroundSuspend.TimeSinceResume",
base::Time::Now() - last_suspend_done_);
}
last_hard_unplugged_ = base::Time::Now();
OnDeviceEvent(file_manager_private::DEVICE_EVENT_TYPE_HARD_UNPLUGGED,
device_path);
SetDeviceState(device_path, DEVICE_HARD_UNPLUGGED_AND_REPORTED);
......@@ -124,11 +132,18 @@ void DeviceEventRouter::OnFormatCompleted(const std::string& device_path,
void DeviceEventRouter::SuspendImminent() {
DCHECK(thread_checker_.CalledOnValidThread());
// TODO(hirono): Remove the temporary UMA. crbug.com/433734
if (!last_hard_unplugged_.is_null()) {
UMA_HISTOGRAM_MEDIUM_TIMES(
"FileBrowser.HardUnpluggedAroundSuspend.TimeUntilSuspend",
base::Time::Now() - last_hard_unplugged_);
}
is_resuming_ = true;
}
void DeviceEventRouter::SuspendDone(const base::TimeDelta& sleep_duration) {
DCHECK(thread_checker_.CalledOnValidThread());
last_suspend_done_ = base::Time::Now();
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::Bind(&DeviceEventRouter::SuspendDoneDelayed,
......
......@@ -98,6 +98,11 @@ class DeviceEventRouter : public VolumeManagerObserver,
// Thread checker.
base::ThreadChecker thread_checker_;
// Last event time for UMA.
// TODO(hirono): Remove the temporarily UMA. crbug.com/433734
base::Time last_hard_unplugged_;
base::Time last_suspend_done_;
// Note: This should remain the last member so it'll be destroyed and
// invalidate the weak pointers before any other members are destroyed.
base::WeakPtrFactory<DeviceEventRouter> weak_factory_;
......
......@@ -9138,6 +9138,24 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary>
</histogram>
<histogram name="FileBrowser.HardUnpluggedAroundSuspend.TimeSinceResume"
units="milliseconds">
<owner>hirono@chromium.org</owner>
<summary>
Chrome OS File Browser: time from the SuspendDone event to the DiskRemoved
event. The UMA is added temporarily for crbug.com/433734.
</summary>
</histogram>
<histogram name="FileBrowser.HardUnpluggedAroundSuspend.TimeUntilSuspend"
units="milliseconds">
<owner>hirono@chromium.org</owner>
<summary>
Chrome OS File Browser: time from the DiskRemoved event to the Suspend
event. The UMA is added temporarily for crbug.com/433734.
</summary>
</histogram>
<histogram name="FileBrowser.Load" units="milliseconds">
<owner>joshwoodward@google.com</owner>
<summary>
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