ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / components / device_event_log / device_event_log_impl.h
blob8b7e11a188fae2e2f57969ad6f98cb070e40eada
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_IMPL_H_
6 #define COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_IMPL_H_
8 #include <list>
9 #include <string>
11 #include "base/time/time.h"
12 #include "components/device_event_log/device_event_log.h"
13 #include "components/device_event_log/device_event_log_export.h"
15 namespace device_event_log {
17 class DEVICE_EVENT_LOG_EXPORT DeviceEventLogImpl {
18 public:
19 struct LogEntry {
20 LogEntry(const char* filedesc,
21 int file_line,
22 LogType log_type,
23 LogLevel log_level,
24 const std::string& event);
26 std::string file;
27 int file_line;
28 LogType log_type;
29 LogLevel log_level;
30 std::string event;
31 base::Time time;
32 int count;
35 explicit DeviceEventLogImpl(size_t max_entries);
36 ~DeviceEventLogImpl();
38 // Implements device_event_log::AddEntry.
39 void AddEntry(const char* file,
40 int file_line,
41 LogType type,
42 LogLevel level,
43 const std::string& event);
45 // Implements device_event_log::GetAsString.
46 std::string GetAsString(StringOrder order,
47 const std::string& format,
48 const std::string& types,
49 LogLevel max_level,
50 size_t max_events);
52 // Called from device_event_log::AddEntry if the global instance has not been
53 // created (or has already been destroyed). Logs to LOG(ERROR) or VLOG(1).
54 static void SendToVLogOrErrorLog(const char* file,
55 int file_line,
56 LogType type,
57 LogLevel log_level,
58 const std::string& event);
60 private:
61 friend class DeviceEventLogTest;
63 typedef std::list<LogEntry> LogEntryList;
65 void AddLogEntry(const LogEntry& entry);
67 // For testing
68 size_t max_entries() const { return max_entries_; }
69 void set_max_entries_for_test(size_t entries) { max_entries_ = entries; }
71 size_t max_entries_;
72 LogEntryList entries_;
74 DISALLOW_COPY_AND_ASSIGN(DeviceEventLogImpl);
77 } // namespace device_event_log
79 #endif // COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_IMPL_H_