| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/wm/core/user_activity_detector.h" | 5 #include "ui/wm/core/user_activity_detector.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 UserActivityDetector::~UserActivityDetector() { | 53 UserActivityDetector::~UserActivityDetector() { |
| 54 g_instance = nullptr; | 54 g_instance = nullptr; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 UserActivityDetector* UserActivityDetector::Get() { | 58 UserActivityDetector* UserActivityDetector::Get() { |
| 59 return g_instance; | 59 return g_instance; |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool UserActivityDetector::HasObserver(UserActivityObserver* observer) const { | 62 bool UserActivityDetector::HasObserver( |
| 63 const UserActivityObserver* observer) const { |
| 63 return observers_.HasObserver(observer); | 64 return observers_.HasObserver(observer); |
| 64 } | 65 } |
| 65 | 66 |
| 66 void UserActivityDetector::AddObserver(UserActivityObserver* observer) { | 67 void UserActivityDetector::AddObserver(UserActivityObserver* observer) { |
| 67 observers_.AddObserver(observer); | 68 observers_.AddObserver(observer); |
| 68 } | 69 } |
| 69 | 70 |
| 70 void UserActivityDetector::RemoveObserver(UserActivityObserver* observer) { | 71 void UserActivityDetector::RemoveObserver(UserActivityObserver* observer) { |
| 71 observers_.RemoveObserver(observer); | 72 observers_.RemoveObserver(observer); |
| 72 } | 73 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 (now - last_observer_notification_time_).InMillisecondsF() >= | 114 (now - last_observer_notification_time_).InMillisecondsF() >= |
| 114 kNotifyIntervalMs) { | 115 kNotifyIntervalMs) { |
| 115 if (VLOG_IS_ON(1)) | 116 if (VLOG_IS_ON(1)) |
| 116 VLOG(1) << "Reporting user activity: " << GetEventDebugString(event); | 117 VLOG(1) << "Reporting user activity: " << GetEventDebugString(event); |
| 117 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity(event)); | 118 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity(event)); |
| 118 last_observer_notification_time_ = now; | 119 last_observer_notification_time_ = now; |
| 119 } | 120 } |
| 120 } | 121 } |
| 121 | 122 |
| 122 } // namespace wm | 123 } // namespace wm |
| OLD | NEW |