Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_TASK_LOGGER_H_ | |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_TASK_LOGGER_H_ | |
| 7 | |
| 8 #include <deque> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "base/observer_list.h" | |
| 14 #include "base/time/time.h" | |
| 15 | |
| 16 namespace sync_file_system { | |
| 17 | |
| 18 class TaskLogger : public base::SupportsWeakPtr<TaskLogger> { | |
| 19 public: | |
| 20 struct TaskLog { | |
| 21 base::TimeDelta duration; | |
| 22 std::string type; | |
| 23 std::string summary; | |
| 24 std::vector<std::string> details; | |
| 25 | |
| 26 TaskLog(); | |
| 27 ~TaskLog(); | |
| 28 }; | |
| 29 | |
| 30 class Observer { | |
| 31 public: | |
| 32 virtual void OnLogRecorded(const TaskLog& task_log) = 0; | |
| 33 | |
| 34 protected: | |
| 35 Observer() {} | |
| 36 virtual ~Observer() {} | |
| 37 | |
| 38 private: | |
| 39 DISALLOW_COPY_AND_ASSIGN(Observer); | |
| 40 }; | |
| 41 | |
| 42 TaskLogger(); | |
| 43 ~TaskLogger(); | |
| 44 | |
| 45 void RecordLog(scoped_ptr<TaskLog> log); | |
| 46 void ClearLog(); | |
| 47 | |
| 48 void AddObserver(Observer* observer); | |
| 49 void RemoveObserver(Observer* observer); | |
| 50 | |
| 51 const std::deque<TaskLog*>& GetLog() const; | |
| 52 | |
| 53 private: | |
| 54 size_t log_size_; | |
|
nhiroki
2014/05/26 01:30:37
How about renaming this with "max_log_size_"?
And
tzik
2014/05/26 04:08:06
Done.
| |
| 55 std::deque<TaskLog*> log_history_; | |
| 56 | |
| 57 ObserverList<Observer> observers_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(TaskLogger); | |
| 60 }; | |
| 61 | |
| 62 } // namespace sync_file_system | |
| 63 | |
| 64 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_TASK_LOGGER_H_ | |
| OLD | NEW |