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

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: +comment 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
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 typedef TaskLogger::TaskLog TaskLog;
12
13 TaskLogger::TaskLog::TaskLog() {}
14 TaskLogger::TaskLog::~TaskLog() {}
15
16 TaskLogger::TaskLogger() : log_size_(500) {}
17
18 TaskLogger::~TaskLogger() {
19 ClearLog();
20 }
21
22 void TaskLogger::RecordLog(scoped_ptr<TaskLog> log) {
23 if (log_history_.size() >= log_size_) {
24 delete log_history_.front();
25 log_history_.pop_front();
26 }
27
28 log_history_.push_back(log.release());
29
30 FOR_EACH_OBSERVER(Observer, observers_,
31 OnLogRecorded(*log_history_.back()));
32 }
33
34 void TaskLogger::ClearLog() {
35 STLDeleteContainerPointers(log_history_.begin(), log_history_.end());
36 log_history_.clear();
37 }
38
39 void TaskLogger::AddObserver(Observer* observer) {
40 observers_.AddObserver(observer);
41 }
42
43 void TaskLogger::RemoveObserver(Observer* observer) {
44 observers_.RemoveObserver(observer);
45 }
46
47 const std::deque<TaskLog*>& TaskLogger::GetLog() const {
48 return log_history_;
49 }
50
51 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698