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

Unified Diff: ui/wm/core/user_activity_detector.cc

Issue 693643004: Make UserActivityDetector a singleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@athena_do_not_use_ash45
Patch Set: Created 6 years, 2 months 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
« ui/wm/core/user_activity_detector.h ('K') | « ui/wm/core/user_activity_detector.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/wm/core/user_activity_detector.cc
diff --git a/ui/wm/core/user_activity_detector.cc b/ui/wm/core/user_activity_detector.cc
index 56bf563b3d032f11b34b87a5af295b78f11c4b7e..666cc3164080f9d42fc4701820535b7386d9d624 100644
--- a/ui/wm/core/user_activity_detector.cc
+++ b/ui/wm/core/user_activity_detector.cc
@@ -14,6 +14,8 @@ namespace wm {
namespace {
+UserActivityDetector* g_instance = NULL;
oshima 2014/10/31 16:53:31 My preference is no g_ for file scoped variable as
+
// Returns a string describing |event|.
std::string GetEventDebugString(const ui::Event* event) {
std::string details = base::StringPrintf(
@@ -43,10 +45,22 @@ const int UserActivityDetector::kNotifyIntervalMs = 200;
// and we'll ignore legitimate activity.
const int UserActivityDetector::kDisplayPowerChangeIgnoreMouseMs = 1000;
-UserActivityDetector::UserActivityDetector() {
+// static
+void UserActivityDetector::Create() {
+ CHECK(!g_instance);
+ g_instance = new UserActivityDetector();
oshima 2014/10/31 16:53:31 Initialize in ctor/dtor.
}
-UserActivityDetector::~UserActivityDetector() {
+// static
+void UserActivityDetector::Shutdown() {
+ CHECK(g_instance);
+ delete g_instance;
+ g_instance = NULL;
+}
+
+// static
+UserActivityDetector* UserActivityDetector::Get() {
+ return g_instance;
}
bool UserActivityDetector::HasObserver(UserActivityObserver* observer) const {
@@ -92,6 +106,12 @@ void UserActivityDetector::OnGestureEvent(ui::GestureEvent* event) {
HandleActivity(event);
}
+UserActivityDetector::UserActivityDetector() {
+}
+
+UserActivityDetector::~UserActivityDetector() {
+}
+
base::TimeTicks UserActivityDetector::GetCurrentTime() const {
return !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now();
}
« ui/wm/core/user_activity_detector.h ('K') | « ui/wm/core/user_activity_detector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698