| 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" | 
|   11 #include "ui/base/user_activity/user_activity_observer.h" |   11 #include "ui/base/user_activity/user_activity_observer.h" | 
|   12 #include "ui/events/event_utils.h" |   12 #include "ui/events/event_utils.h" | 
|   13 #include "ui/events/platform/platform_event_source.h" |   13 #include "ui/events/platform/platform_event_source.h" | 
|   14  |   14  | 
|   15 namespace ui { |   15 namespace ui { | 
|   16  |   16  | 
|   17 namespace { |   17 namespace { | 
|   18  |   18  | 
|   19 UserActivityDetector* g_instance = nullptr; |   19 UserActivityDetector* g_instance = nullptr; | 
|   20  |   20  | 
|   21 // Returns a string describing |event|. |   21 // Returns a string describing |event|. | 
|   22 std::string GetEventDebugString(const ui::Event* event) { |   22 std::string GetEventDebugString(const ui::Event* event) { | 
|   23   std::string details = base::StringPrintf( |   23   std::string details = base::StringPrintf( | 
|   24       "type=%d name=%s flags=%d time=%" PRId64, |   24       "type=%d name=%s flags=%d time=%" PRId64, event->type(), | 
|   25       event->type(), event->name().c_str(), event->flags(), |   25       event->name().c_str(), event->flags(), | 
|   26       event->time_stamp().InMilliseconds()); |   26       (event->time_stamp() - base::TimeTicks()).InMilliseconds()); | 
|   27  |   27  | 
|   28   if (event->IsKeyEvent()) { |   28   if (event->IsKeyEvent()) { | 
|   29     details += base::StringPrintf(" key_code=%d", |   29     details += base::StringPrintf(" key_code=%d", | 
|   30         static_cast<const ui::KeyEvent*>(event)->key_code()); |   30         static_cast<const ui::KeyEvent*>(event)->key_code()); | 
|   31   } else if (event->IsMouseEvent() || event->IsTouchEvent() || |   31   } else if (event->IsMouseEvent() || event->IsTouchEvent() || | 
|   32              event->IsGestureEvent()) { |   32              event->IsGestureEvent()) { | 
|   33     details += base::StringPrintf(" location=%s", |   33     details += base::StringPrintf(" location=%s", | 
|   34         static_cast<const ui::LocatedEvent*>( |   34         static_cast<const ui::LocatedEvent*>( | 
|   35             event)->location().ToString().c_str()); |   35             event)->location().ToString().c_str()); | 
|   36   } |   36   } | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  122       (now - last_observer_notification_time_).InMillisecondsF() >= |  122       (now - last_observer_notification_time_).InMillisecondsF() >= | 
|  123       kNotifyIntervalMs) { |  123       kNotifyIntervalMs) { | 
|  124     if (VLOG_IS_ON(1)) |  124     if (VLOG_IS_ON(1)) | 
|  125       VLOG(1) << "Reporting user activity: " << GetEventDebugString(event); |  125       VLOG(1) << "Reporting user activity: " << GetEventDebugString(event); | 
|  126     FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity(event)); |  126     FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity(event)); | 
|  127     last_observer_notification_time_ = now; |  127     last_observer_notification_time_ = now; | 
|  128   } |  128   } | 
|  129 } |  129 } | 
|  130  |  130  | 
|  131 }  // namespace ui |  131 }  // namespace ui | 
| OLD | NEW |