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"
14 namespace device_event_log
{
16 class DeviceEventLogImpl
{
19 LogEntry(const char* filedesc
,
23 const std::string
& event
);
34 explicit DeviceEventLogImpl(size_t max_entries
);
35 ~DeviceEventLogImpl();
37 // Implements device_event_log::AddEntry.
38 void AddEntry(const char* file
,
42 const std::string
& event
);
44 // Implements device_event_log::GetAsString.
45 std::string
GetAsString(StringOrder order
,
46 const std::string
& format
,
47 const std::string
& types
,
51 // Called from device_event_log::AddEntry if the global instance has not been
52 // created (or has already been destroyed). Logs to LOG(ERROR) or VLOG(1).
53 static void SendToVLogOrErrorLog(const char* file
,
57 const std::string
& event
);
60 friend class DeviceEventLogTest
;
62 typedef std::list
<LogEntry
> LogEntryList
;
64 void AddLogEntry(const LogEntry
& entry
);
67 size_t max_entries() const { return max_entries_
; }
68 void set_max_entries_for_test(size_t entries
) { max_entries_
= entries
; }
71 LogEntryList entries_
;
73 DISALLOW_COPY_AND_ASSIGN(DeviceEventLogImpl
);
76 } // namespace device_event_log
78 #endif // COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_IMPL_H_