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

Side by Side Diff: chrome/browser/drive/event_logger.h

Issue 1190203002: Move (most of) chrome/browser/drive into components/drive/service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... Created 5 years, 5 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 | « chrome/browser/drive/dummy_drive_service.cc ('k') | chrome/browser/drive/event_logger.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 (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_DRIVE_EVENT_LOGGER_H_
6 #define CHROME_BROWSER_DRIVE_EVENT_LOGGER_H_
7
8 #include <deque>
9 #include <string>
10 #include <vector>
11
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/logging.h"
15 #include "base/synchronization/lock.h"
16 #include "base/time/time.h"
17
18 namespace drive {
19
20 // The default history size used by EventLogger.
21 const int kDefaultHistorySize = 1000;
22
23 // EventLogger is used to collect and expose text messages for diagnosing
24 // behaviors of Google APIs stuff. For instance, the collected messages are
25 // exposed to chrome:drive-internals.
26 class EventLogger {
27 public:
28 // Represents a single event log.
29 struct Event {
30 Event(int id, logging::LogSeverity severity, const std::string& what);
31 int id; // Monotonically increasing ID starting from 0.
32 logging::LogSeverity severity; // Severity of the event.
33 base::Time when; // When the event occurred.
34 std::string what; // What happened.
35 };
36
37 // Creates an event logger that keeps the latest kDefaultHistorySize events.
38 EventLogger();
39 ~EventLogger();
40
41 // Logs a message and its severity.
42 // Can be called from any thread as long as the object is alive.
43 void LogRawString(logging::LogSeverity severity, const std::string& what);
44
45 // Logs a message with formatting.
46 // Can be called from any thread as long as the object is alive.
47 void Log(logging::LogSeverity severity, const char* format, ...)
48 PRINTF_FORMAT(3, 4);
49
50 // Sets the history size. The existing history is cleared.
51 // Can be called from any thread as long as the object is alive.
52 void SetHistorySize(size_t history_size);
53
54 // 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 std::vector<Event> GetHistory();
57
58 private:
59 std::deque<Event> history_; // guarded by lock_.
60 size_t history_size_; // guarded by lock_.
61 int next_event_id_; // guarded by lock_.
62 base::Lock lock_;
63
64 DISALLOW_COPY_AND_ASSIGN(EventLogger);
65 };
66
67 } // namespace drive
68
69 #endif // CHROME_BROWSER_DRIVE_EVENT_LOGGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/drive/dummy_drive_service.cc ('k') | chrome/browser/drive/event_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698