Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_COMMON_WORKER_THREAD_TICKER_H_ | 5 #ifndef CHROME_COMMON_WORKER_THREAD_TICKER_H_ |
| 6 #define CHROME_COMMON_WORKER_THREAD_TICKER_H_ | 6 #define CHROME_COMMON_WORKER_THREAD_TICKER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 // Returns false is the ticker is not running | 53 // Returns false is the ticker is not running |
| 54 bool Stop(); | 54 bool Stop(); |
| 55 bool IsRunning() const { | 55 bool IsRunning() const { |
| 56 return is_running_; | 56 return is_running_; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void set_tick_interval(int tick_interval) { | 59 void set_tick_interval(int tick_interval) { |
| 60 tick_interval_ = base::TimeDelta::FromMilliseconds(tick_interval); | 60 tick_interval_ = base::TimeDelta::FromMilliseconds(tick_interval); |
| 61 } | 61 } |
| 62 | 62 |
| 63 int tick_interval() const { | |
|
Peter Kasting
2014/12/06 00:12:18
Unused.
| |
| 64 return tick_interval_.InMilliseconds(); | |
| 65 } | |
| 66 | |
| 67 private: | 63 private: |
| 68 void ScheduleTimerTask(); | 64 void ScheduleTimerTask(); |
| 69 | 65 |
| 70 void TimerTask(); | 66 void TimerTask(); |
| 71 | 67 |
| 72 // A list type that holds all registered callback interfaces | 68 // A list type that holds all registered callback interfaces |
| 73 typedef std::vector<Callback*> TickHandlerListType; | 69 typedef std::vector<Callback*> TickHandlerListType; |
| 74 | 70 |
| 75 // Lock to protect is_running_ and tick_handler_list_ | 71 // Lock to protect is_running_ and tick_handler_list_ |
| 76 base::Lock lock_; | 72 base::Lock lock_; |
| 77 | 73 |
| 78 base::Thread timer_thread_; | 74 base::Thread timer_thread_; |
| 79 bool is_running_; | 75 bool is_running_; |
| 80 | 76 |
| 81 // The interval at which the callbacks are to be invoked | 77 // The interval at which the callbacks are to be invoked |
| 82 base::TimeDelta tick_interval_; | 78 base::TimeDelta tick_interval_; |
| 83 | 79 |
| 84 // A list that holds all registered callback interfaces | 80 // A list that holds all registered callback interfaces |
| 85 TickHandlerListType tick_handler_list_; | 81 TickHandlerListType tick_handler_list_; |
| 86 | 82 |
| 87 DISALLOW_COPY_AND_ASSIGN(WorkerThreadTicker); | 83 DISALLOW_COPY_AND_ASSIGN(WorkerThreadTicker); |
| 88 }; | 84 }; |
| 89 | 85 |
| 90 #endif // CHROME_COMMON_WORKER_THREAD_TICKER_H_ | 86 #endif // CHROME_COMMON_WORKER_THREAD_TICKER_H_ |
| OLD | NEW |