OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_DRIVE_EVENT_LOGGER_H_ | 5 #ifndef COMPONENTS_DRIVE_EVENT_LOGGER_H_ |
6 #define COMPONENTS_DRIVE_EVENT_LOGGER_H_ | 6 #define COMPONENTS_DRIVE_EVENT_LOGGER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 26 matching lines...) Expand all Loading... |
37 // Creates an event logger that keeps the latest kDefaultHistorySize events. | 37 // Creates an event logger that keeps the latest kDefaultHistorySize events. |
38 EventLogger(); | 38 EventLogger(); |
39 ~EventLogger(); | 39 ~EventLogger(); |
40 | 40 |
41 // Logs a message and its severity. | 41 // Logs a message and its severity. |
42 // Can be called from any thread as long as the object is alive. | 42 // Can be called from any thread as long as the object is alive. |
43 void LogRawString(logging::LogSeverity severity, const std::string& what); | 43 void LogRawString(logging::LogSeverity severity, const std::string& what); |
44 | 44 |
45 // Logs a message with formatting. | 45 // Logs a message with formatting. |
46 // Can be called from any thread as long as the object is alive. | 46 // Can be called from any thread as long as the object is alive. |
47 void Log(logging::LogSeverity severity, const char* format, ...) | 47 void Log(logging::LogSeverity severity, |
48 PRINTF_FORMAT(3, 4); | 48 _Printf_format_string_ const char* format, |
| 49 ...) PRINTF_FORMAT(3, 4); |
49 | 50 |
50 // Sets the history size. The existing history is cleared. | 51 // Sets the history size. The existing history is cleared. |
51 // Can be called from any thread as long as the object is alive. | 52 // Can be called from any thread as long as the object is alive. |
52 void SetHistorySize(size_t history_size); | 53 void SetHistorySize(size_t history_size); |
53 | 54 |
54 // Gets the list of latest events (the oldest event comes first). | 55 // Gets the list of latest events (the oldest event comes first). |
55 // Can be called from any thread as long as the object is alive. | 56 // Can be called from any thread as long as the object is alive. |
56 std::vector<Event> GetHistory(); | 57 std::vector<Event> GetHistory(); |
57 | 58 |
58 private: | 59 private: |
59 std::deque<Event> history_; // guarded by lock_. | 60 std::deque<Event> history_; // guarded by lock_. |
60 size_t history_size_; // guarded by lock_. | 61 size_t history_size_; // guarded by lock_. |
61 int next_event_id_; // guarded by lock_. | 62 int next_event_id_; // guarded by lock_. |
62 base::Lock lock_; | 63 base::Lock lock_; |
63 | 64 |
64 DISALLOW_COPY_AND_ASSIGN(EventLogger); | 65 DISALLOW_COPY_AND_ASSIGN(EventLogger); |
65 }; | 66 }; |
66 | 67 |
67 } // namespace drive | 68 } // namespace drive |
68 | 69 |
69 #endif // COMPONENTS_DRIVE_EVENT_LOGGER_H_ | 70 #endif // COMPONENTS_DRIVE_EVENT_LOGGER_H_ |
OLD | NEW |