OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_EVENT_LOGGER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_EVENT_LOGGER_H_ | |
7 | |
8 #include <string> | |
9 #include <deque> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/time.h" | |
13 | |
14 namespace drive { | |
15 | |
16 // EventLogger is used to expose text messages to chrome:drive-internals, | |
17 // for diagnosing the behavior of the Drive client. | |
18 class EventLogger { | |
19 public: | |
20 // Represents a single event log. | |
21 struct Event { | |
22 Event(int id, const std::string& what); | |
23 int id; | |
satorux1
2012/11/14 07:59:30
Please document that this is a monotonically incre
kinaba
2012/11/14 08:13:36
Done.
| |
24 base::Time when; | |
satorux1
2012/11/14 07:59:30
; // When the event occurred.
kinaba
2012/11/14 08:13:36
Done.
| |
25 std::string what; | |
satorux1
2012/11/14 07:59:30
; // What happened.
kinaba
2012/11/14 08:13:36
Done.
| |
26 }; | |
27 | |
28 // Creates an event logger that keeps the latest |history_size| events. | |
29 explicit EventLogger(size_t history_size); | |
30 ~EventLogger(); | |
31 | |
32 // Logs a message. | |
33 void Log(const std::string& what); | |
34 | |
35 // Gets the list of latest events (the oldest event comes first). | |
36 const std::deque<Event>& history() const { return history_; } | |
37 | |
38 private: | |
39 std::deque<Event> history_; | |
40 const size_t history_size_; | |
41 int next_event_id_; | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(EventLogger); | |
44 }; | |
45 | |
46 } // namespace drive | |
47 | |
48 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_EVENT_LOGGER_H_ | |
OLD | NEW |