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

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

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/event_logger.h ('k') | chrome/browser/drive/event_logger_unittest.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 #include "chrome/browser/drive/event_logger.h"
6
7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h"
9
10 namespace drive {
11
12 EventLogger::Event::Event(
13 int id, logging::LogSeverity severity, const std::string& what)
14 : id(id),
15 severity(severity),
16 when(base::Time::Now()),
17 what(what) {
18 }
19
20 EventLogger::EventLogger()
21 : history_size_(kDefaultHistorySize),
22 next_event_id_(0) {
23 }
24
25 EventLogger::~EventLogger() {
26 }
27
28 void EventLogger::LogRawString(logging::LogSeverity severity,
29 const std::string& what) {
30 base::AutoLock auto_lock(lock_);
31 history_.push_back(Event(next_event_id_, severity, what));
32 ++next_event_id_;
33 if (history_.size() > history_size_)
34 history_.pop_front();
35 }
36
37 void EventLogger::Log(logging::LogSeverity severity, const char* format, ...) {
38 std::string what;
39
40 va_list args;
41 va_start(args, format);
42 base::StringAppendV(&what, format, args);
43 va_end(args);
44
45 DVLOG(1) << what;
46 LogRawString(severity, what);
47 }
48
49 void EventLogger::SetHistorySize(size_t history_size) {
50 base::AutoLock auto_lock(lock_);
51 history_.clear();
52 history_size_ = history_size;
53 }
54
55 std::vector<EventLogger::Event> EventLogger::GetHistory() {
56 base::AutoLock auto_lock(lock_);
57 std::vector<Event> output;
58 output.assign(history_.begin(), history_.end());
59 return output;
60 }
61
62
63 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/drive/event_logger.h ('k') | chrome/browser/drive/event_logger_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698