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

Side by Side Diff: chromeos/device_event_log_impl.h

Issue 919183002: Move chromeos::device_event_log into components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Shut down in PostDestroyThreads. Created 5 years, 10 months 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
« no previous file with comments | « chromeos/device_event_log.cc ('k') | chromeos/device_event_log_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef CHROMEOS_DEVICE_EVENT_LOG_IMPL_H_
6 #define CHROMEOS_DEVICE_EVENT_LOG_IMPL_H_
7
8 #include <list>
9 #include <string>
10
11 #include "base/time/time.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/device_event_log.h"
14
15 namespace chromeos {
16
17 namespace device_event_log {
18
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);
27
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;
35 };
36
37 explicit DeviceEventLogImpl(size_t max_entries);
38 ~DeviceEventLogImpl();
39
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);
46
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);
53
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);
61
62 private:
63 friend class DeviceEventLogTest;
64
65 typedef std::list<LogEntry> LogEntryList;
66
67 void AddLogEntry(const LogEntry& entry);
68
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; }
72
73 size_t max_entries_;
74 LogEntryList entries_;
75
76 DISALLOW_COPY_AND_ASSIGN(DeviceEventLogImpl);
77 };
78
79 } // namespace device_event_log
80
81 } // namespace chromeos
82
83 #endif // CHROMEOS_DEVICE_EVENT_LOG_IMPL_H_
OLDNEW
« no previous file with comments | « chromeos/device_event_log.cc ('k') | chromeos/device_event_log_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698