Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: chrome/browser/signin/easy_unlock_service.cc

Issue 799623003: Reimplement EasyUnlock.StartupTimeFromSuspend metric. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile on mac/win Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/signin/easy_unlock_service.cc
diff --git a/chrome/browser/signin/easy_unlock_service.cc b/chrome/browser/signin/easy_unlock_service.cc
index ffa2341aef02497adbe667017b62bd991f9e3fa9..aafc4f926c592cf51126618a21e8d2015ab1c267 100644
--- a/chrome/browser/signin/easy_unlock_service.cc
+++ b/chrome/browser/signin/easy_unlock_service.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/metrics/histogram_macros.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
@@ -147,6 +148,18 @@ class EasyUnlockService::PowerMonitor
RemoveObserver(this);
}
+ // Called when the remote device has been authenticated to record the time
+ // delta from waking up. No time will be recorded if the start-up time has
+ // already been recorded or if the system never went to sleep previously.
+ void RecordStartUpTime() {
+ if (wake_up_time_.is_null())
+ return;
+ UMA_HISTOGRAM_MEDIUM_TIMES(
+ "EasyUnlock.StartupTimeFromSuspend",
+ base::Time::Now() - wake_up_time_);
+ wake_up_time_ = base::Time();
+ }
+
bool waking_up() const { return waking_up_; }
private:
@@ -157,6 +170,7 @@ class EasyUnlockService::PowerMonitor
virtual void SuspendDone(const base::TimeDelta& sleep_duration) override {
waking_up_ = true;
+ wake_up_time_ = base::Time::Now();
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::Bind(&PowerMonitor::ResetWakingUp,
@@ -173,6 +187,7 @@ class EasyUnlockService::PowerMonitor
EasyUnlockService* service_;
bool waking_up_;
+ base::Time wake_up_time_;
base::WeakPtrFactory<PowerMonitor> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
@@ -333,8 +348,14 @@ bool EasyUnlockService::UpdateScreenlockState(
handler->ChangeState(state);
- if (state != EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED &&
- auth_attempt_.get()) {
+ if (state == EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED) {
+#if defined(OS_CHROMEOS)
+ if (power_monitor_)
+ power_monitor_->RecordStartUpTime();
+#endif
+ } else if (auth_attempt_.get()) {
+ // Clean up existing auth attempt if we can no longer authenticate the
+ // remote device.
auth_attempt_.reset();
if (!handler->InStateValidOnRemoteAuthFailure())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698