Commit 74817ba2 authored by derat@chromium.org's avatar derat@chromium.org

ash: Add VLOG(1) to UserActivityDetector.

Add a VLOG(1) message containing event details to
UserActivityDetector. This makes it easier to debug
unexpected user activity, which we've seen in the past.

BUG=none
TBR=nkostylev@chromium.org

Review URL: https://codereview.chromium.org/58293003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232985 0039d316-1c4b-4281-b951-d872f2087c98
parent c73b53cc
...@@ -5,10 +5,37 @@ ...@@ -5,10 +5,37 @@
#include "ash/wm/user_activity_detector.h" #include "ash/wm/user_activity_detector.h"
#include "ash/wm/user_activity_observer.h" #include "ash/wm/user_activity_observer.h"
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "ui/events/event.h" #include "ui/events/event.h"
namespace ash { namespace ash {
namespace {
// Returns a string describing |event|.
std::string GetEventDebugString(const ui::Event* event) {
std::string details = base::StringPrintf(
"type=%d name=%s flags=%d time=%" PRId64,
event->type(), event->name().c_str(), event->flags(),
event->time_stamp().InMilliseconds());
if (event->IsKeyEvent()) {
details += base::StringPrintf(" key_code=%d",
static_cast<const ui::KeyEvent*>(event)->key_code());
} else if (event->IsMouseEvent() || event->IsTouchEvent() ||
event->IsGestureEvent()) {
details += base::StringPrintf(" location=%s",
static_cast<const ui::LocatedEvent*>(
event)->location().ToString().c_str());
}
return details;
}
} // namespace
const int UserActivityDetector::kNotifyIntervalMs = 200; const int UserActivityDetector::kNotifyIntervalMs = 200;
// Too low and mouse events generated at the tail end of reconfiguration // Too low and mouse events generated at the tail end of reconfiguration
...@@ -75,6 +102,8 @@ void UserActivityDetector::HandleActivity(const ui::Event* event) { ...@@ -75,6 +102,8 @@ void UserActivityDetector::HandleActivity(const ui::Event* event) {
if (last_observer_notification_time_.is_null() || if (last_observer_notification_time_.is_null() ||
(now - last_observer_notification_time_).InMillisecondsF() >= (now - last_observer_notification_time_).InMillisecondsF() >=
kNotifyIntervalMs) { kNotifyIntervalMs) {
if (VLOG_IS_ON(1))
VLOG(1) << "Reporting user activity: " << GetEventDebugString(event);
FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity(event)); FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity(event));
last_observer_notification_time_ = now; last_observer_notification_time_ = now;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment