OLD | NEW |
(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 |
OLD | NEW |