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/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h" | 5 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <libevdev/libevdev.h> | 8 #include <libevdev/libevdev.h> |
9 #include <linux/input.h> | 9 #include <linux/input.h> |
10 | 10 |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/trace_event/trace_event.h" |
14 | 15 |
15 namespace ui { | 16 namespace ui { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 std::string FormatLog(const char* fmt, va_list args) { | 20 std::string FormatLog(const char* fmt, va_list args) { |
20 std::string msg = base::StringPrintV(fmt, args); | 21 std::string msg = base::StringPrintV(fmt, args); |
21 if (!msg.empty() && msg[msg.size() - 1] == '\n') | 22 if (!msg.empty() && msg[msg.size() - 1] == '\n') |
22 msg.erase(msg.end() - 1, msg.end()); | 23 msg.erase(msg.end() - 1, msg.end()); |
23 return msg; | 24 return msg; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 64 } |
64 | 65 |
65 EventReaderLibevdevCros::~EventReaderLibevdevCros() { | 66 EventReaderLibevdevCros::~EventReaderLibevdevCros() { |
66 Stop(); | 67 Stop(); |
67 EvdevClose(&evdev_); | 68 EvdevClose(&evdev_); |
68 } | 69 } |
69 | 70 |
70 EventReaderLibevdevCros::Delegate::~Delegate() {} | 71 EventReaderLibevdevCros::Delegate::~Delegate() {} |
71 | 72 |
72 void EventReaderLibevdevCros::OnFileCanReadWithoutBlocking(int fd) { | 73 void EventReaderLibevdevCros::OnFileCanReadWithoutBlocking(int fd) { |
| 74 TRACE_EVENT1("evdev", "EventReaderLibevdevCros::OnFileCanReadWithoutBlocking", |
| 75 "fd", fd); |
| 76 |
73 if (EvdevRead(&evdev_)) { | 77 if (EvdevRead(&evdev_)) { |
74 if (errno == EINTR || errno == EAGAIN) | 78 if (errno == EINTR || errno == EAGAIN) |
75 return; | 79 return; |
76 if (errno != ENODEV) | 80 if (errno != ENODEV) |
77 PLOG(ERROR) << "error reading device " << path_.value(); | 81 PLOG(ERROR) << "error reading device " << path_.value(); |
78 Stop(); | 82 Stop(); |
79 return; | 83 return; |
80 } | 84 } |
81 } | 85 } |
82 | 86 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 if (level >= LOGLEVEL_ERROR) | 125 if (level >= LOGLEVEL_ERROR) |
122 LOG(ERROR) << "libevdev: " << FormatLog(fmt, args); | 126 LOG(ERROR) << "libevdev: " << FormatLog(fmt, args); |
123 else if (level >= LOGLEVEL_WARNING) | 127 else if (level >= LOGLEVEL_WARNING) |
124 LOG(WARNING) << "libevdev: " << FormatLog(fmt, args); | 128 LOG(WARNING) << "libevdev: " << FormatLog(fmt, args); |
125 else | 129 else |
126 VLOG(3) << "libevdev: " << FormatLog(fmt, args); | 130 VLOG(3) << "libevdev: " << FormatLog(fmt, args); |
127 va_end(args); | 131 va_end(args); |
128 } | 132 } |
129 | 133 |
130 } // namespace ui | 134 } // namespace ui |
OLD | NEW |