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