| 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/base/user_activity/user_activity_detector.h" | 5 #include "ui/base/user_activity/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 "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 observers_.RemoveObserver(observer); | 84 observers_.RemoveObserver(observer); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void UserActivityDetector::OnDisplayPowerChanging() { | 87 void UserActivityDetector::OnDisplayPowerChanging() { |
| 88 honor_mouse_events_time_ = GetCurrentTime() + | 88 honor_mouse_events_time_ = GetCurrentTime() + |
| 89 base::TimeDelta::FromMilliseconds(kDisplayPowerChangeIgnoreMouseMs); | 89 base::TimeDelta::FromMilliseconds(kDisplayPowerChangeIgnoreMouseMs); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void UserActivityDetector::DidProcessEvent( | 92 void UserActivityDetector::DidProcessEvent( |
| 93 const PlatformEvent& platform_event) { | 93 const PlatformEvent& platform_event) { |
| 94 scoped_ptr<ui::Event> event(ui::EventFromNative(platform_event)); | 94 std::unique_ptr<ui::Event> event(ui::EventFromNative(platform_event)); |
| 95 ProcessReceivedEvent(event.get()); | 95 ProcessReceivedEvent(event.get()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 base::TimeTicks UserActivityDetector::GetCurrentTime() const { | 98 base::TimeTicks UserActivityDetector::GetCurrentTime() const { |
| 99 return !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now(); | 99 return !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void UserActivityDetector::ProcessReceivedEvent(const ui::Event* event) { | 102 void UserActivityDetector::ProcessReceivedEvent(const ui::Event* event) { |
| 103 if (!event) | 103 if (!event) |
| 104 return; | 104 return; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 121 (now - last_observer_notification_time_).InMillisecondsF() >= | 121 (now - last_observer_notification_time_).InMillisecondsF() >= |
| 122 kNotifyIntervalMs) { | 122 kNotifyIntervalMs) { |
| 123 if (VLOG_IS_ON(1)) | 123 if (VLOG_IS_ON(1)) |
| 124 VLOG(1) << "Reporting user activity: " << GetEventDebugString(event); | 124 VLOG(1) << "Reporting user activity: " << GetEventDebugString(event); |
| 125 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity(event)); | 125 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity(event)); |
| 126 last_observer_notification_time_ = now; | 126 last_observer_notification_time_ = now; |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace ui | 130 } // namespace ui |
| OLD | NEW |