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

Side by Side Diff: ash/wm/user_activity_detector.cc

Issue 58293003: ash: Add VLOG(1) to UserActivityDetector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/wm/user_activity_detector.h" 5 #include "ash/wm/user_activity_detector.h"
6 6
7 #include "ash/wm/user_activity_observer.h" 7 #include "ash/wm/user_activity_observer.h"
8 #include "base/format_macros.h"
9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h"
8 #include "ui/events/event.h" 11 #include "ui/events/event.h"
9 12
10 namespace ash { 13 namespace ash {
11 14
15 namespace {
16
17 // Returns a string describing |event|.
18 std::string GetEventDebugString(const ui::Event* event) {
19 std::string details = base::StringPrintf(
20 "type=%d name=%s flags=%d time=%" PRId64,
21 event->type(), event->name().c_str(), event->flags(),
22 event->time_stamp().InMilliseconds());
23
24 if (event->IsKeyEvent()) {
25 details += base::StringPrintf(" key_code=%d",
26 static_cast<const ui::KeyEvent*>(event)->key_code());
27 } else if (event->IsMouseEvent() || event->IsTouchEvent() ||
28 event->IsGestureEvent()) {
29 details += base::StringPrintf(" location=%s",
30 static_cast<const ui::LocatedEvent*>(
31 event)->location().ToString().c_str());
32 }
33
34 return details;
35 }
36
37 } // namespace
38
12 const int UserActivityDetector::kNotifyIntervalMs = 200; 39 const int UserActivityDetector::kNotifyIntervalMs = 200;
13 40
14 // Too low and mouse events generated at the tail end of reconfiguration 41 // Too low and mouse events generated at the tail end of reconfiguration
15 // will be reported as user activity and turn the screen back on; too high 42 // will be reported as user activity and turn the screen back on; too high
16 // and we'll ignore legitimate activity. 43 // and we'll ignore legitimate activity.
17 const int UserActivityDetector::kDisplayPowerChangeIgnoreMouseMs = 1000; 44 const int UserActivityDetector::kDisplayPowerChangeIgnoreMouseMs = 1000;
18 45
19 UserActivityDetector::UserActivityDetector() { 46 UserActivityDetector::UserActivityDetector() {
20 } 47 }
21 48
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 base::TimeTicks UserActivityDetector::GetCurrentTime() const { 95 base::TimeTicks UserActivityDetector::GetCurrentTime() const {
69 return !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now(); 96 return !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now();
70 } 97 }
71 98
72 void UserActivityDetector::HandleActivity(const ui::Event* event) { 99 void UserActivityDetector::HandleActivity(const ui::Event* event) {
73 base::TimeTicks now = GetCurrentTime(); 100 base::TimeTicks now = GetCurrentTime();
74 last_activity_time_ = now; 101 last_activity_time_ = now;
75 if (last_observer_notification_time_.is_null() || 102 if (last_observer_notification_time_.is_null() ||
76 (now - last_observer_notification_time_).InMillisecondsF() >= 103 (now - last_observer_notification_time_).InMillisecondsF() >=
77 kNotifyIntervalMs) { 104 kNotifyIntervalMs) {
105 if (VLOG_IS_ON(1))
106 VLOG(1) << "Reporting user activity: " << GetEventDebugString(event);
78 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity(event)); 107 FOR_EACH_OBSERVER(UserActivityObserver, observers_, OnUserActivity(event));
79 last_observer_notification_time_ = now; 108 last_observer_notification_time_ = now;
80 } 109 }
81 } 110 }
82 111
83 } // namespace ash 112 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698