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

Side by Side Diff: chrome/browser/sync_file_system/task_logger.cc

Issue 291403004: [SyncFS] Add TaskLogger and wire up it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync_file_system/task_logger.h ('k') | chrome/chrome_browser.gypi » ('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 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.
4
5 #include "chrome/browser/sync_file_system/task_logger.h"
6
7 #include "base/stl_util.h"
8
9 namespace sync_file_system {
10
11 namespace {
12 const size_t kMaxLogSize = 500;
13 } // namespace
14
15 typedef TaskLogger::TaskLog TaskLog;
16
17 TaskLogger::TaskLog::TaskLog() {}
18 TaskLogger::TaskLog::~TaskLog() {}
19
20 TaskLogger::TaskLogger() {}
21
22 TaskLogger::~TaskLogger() {
23 ClearLog();
24 }
25
26 void TaskLogger::RecordLog(scoped_ptr<TaskLog> log) {
27 if (log_history_.size() >= kMaxLogSize) {
28 delete log_history_.front();
29 log_history_.pop_front();
30 }
31
32 log_history_.push_back(log.release());
33
34 FOR_EACH_OBSERVER(Observer, observers_,
35 OnLogRecorded(*log_history_.back()));
36 }
37
38 void TaskLogger::ClearLog() {
39 STLDeleteContainerPointers(log_history_.begin(), log_history_.end());
40 log_history_.clear();
41 }
42
43 void TaskLogger::AddObserver(Observer* observer) {
44 observers_.AddObserver(observer);
45 }
46
47 void TaskLogger::RemoveObserver(Observer* observer) {
48 observers_.RemoveObserver(observer);
49 }
50
51 const std::deque<TaskLog*>& TaskLogger::GetLog() const {
52 return log_history_;
53 }
54
55 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/task_logger.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698