[Smart Lock] Measure clicks on the lock icon during Easy Unlock's trial run.
[chromium-blink-merge.git] / chromeos / device_event_log_impl.h
blobf18bff50d092778c51cd704e192a7c88e2ee871d
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 CHROMEOS_DEVICE_EVENT_LOG_IMPL_H_
6 #define CHROMEOS_DEVICE_EVENT_LOG_IMPL_H_
8 #include <list>
9 #include <string>
11 #include "base/time/time.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/device_event_log.h"
15 namespace chromeos {
17 namespace device_event_log {
19 class CHROMEOS_EXPORT DeviceEventLogImpl {
20 public:
21 struct LogEntry {
22 LogEntry(const char* filedesc,
23 int file_line,
24 LogType log_type,
25 LogLevel log_level,
26 const std::string& event);
28 std::string file;
29 int file_line;
30 LogType log_type;
31 LogLevel log_level;
32 std::string event;
33 base::Time time;
34 int count;
37 explicit DeviceEventLogImpl(size_t max_entries);
38 ~DeviceEventLogImpl();
40 // Implements device_event_log::AddEntry.
41 void AddEntry(const char* file,
42 int file_line,
43 LogType type,
44 LogLevel level,
45 const std::string& event);
47 // Implements device_event_log::GetAsString.
48 std::string GetAsString(StringOrder order,
49 const std::string& format,
50 const std::string& types,
51 LogLevel max_level,
52 size_t max_events);
54 // Called from device_event_log::AddEntry if the global instance has not been
55 // created (or has already been destroyed). Logs to LOG(ERROR) or VLOG(1).
56 static void SendToVLogOrErrorLog(const char* file,
57 int file_line,
58 LogType type,
59 LogLevel log_level,
60 const std::string& event);
62 private:
63 friend class DeviceEventLogTest;
65 typedef std::list<LogEntry> LogEntryList;
67 void AddLogEntry(const LogEntry& entry);
69 // For testing
70 size_t max_entries() const { return max_entries_; }
71 void set_max_entries_for_test(size_t entries) { max_entries_ = entries; }
73 size_t max_entries_;
74 LogEntryList entries_;
76 DISALLOW_COPY_AND_ASSIGN(DeviceEventLogImpl);
79 } // namespace device_event_log
81 } // namespace chromeos
83 #endif // CHROMEOS_DEVICE_EVENT_LOG_IMPL_H_