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_
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
{
20 LogEntry(const char* filedesc
,
24 const std::string
& event
);
35 explicit DeviceEventLogImpl(size_t max_entries
);
36 ~DeviceEventLogImpl();
38 // Implements device_event_log::AddEntry.
39 void AddEntry(const char* file
,
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
,
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
,
58 const std::string
& event
);
61 friend class DeviceEventLogTest
;
63 typedef std::list
<LogEntry
> LogEntryList
;
65 void AddLogEntry(const LogEntry
& entry
);
68 size_t max_entries() const { return max_entries_
; }
69 void set_max_entries_for_test(size_t entries
) { max_entries_
= 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_