OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/common/worker_thread_ticker.h" | 5 #include "chrome/common/worker_thread_ticker.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/task.h" | 11 #include "base/task.h" |
12 #include "base/thread.h" | 12 #include "base/threading/thread.h" |
13 | 13 |
14 class WorkerThreadTicker::TimerTask : public Task { | 14 class WorkerThreadTicker::TimerTask : public Task { |
15 public: | 15 public: |
16 explicit TimerTask(WorkerThreadTicker* ticker) : ticker_(ticker) { | 16 explicit TimerTask(WorkerThreadTicker* ticker) : ticker_(ticker) { |
17 } | 17 } |
18 | 18 |
19 virtual void Run() { | 19 virtual void Run() { |
20 // When the ticker is running, the handler list CANNOT be modified. | 20 // When the ticker is running, the handler list CANNOT be modified. |
21 // So we can do the enumeration safely without a lock | 21 // So we can do the enumeration safely without a lock |
22 TickHandlerListType* handlers = &ticker_->tick_handler_list_; | 22 TickHandlerListType* handlers = &ticker_->tick_handler_list_; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return false; | 92 return false; |
93 is_running_ = false; | 93 is_running_ = false; |
94 timer_thread_.Stop(); | 94 timer_thread_.Stop(); |
95 return true; | 95 return true; |
96 } | 96 } |
97 | 97 |
98 void WorkerThreadTicker::ScheduleTimerTask() { | 98 void WorkerThreadTicker::ScheduleTimerTask() { |
99 timer_thread_.message_loop()->PostDelayedTask(FROM_HERE, new TimerTask(this), | 99 timer_thread_.message_loop()->PostDelayedTask(FROM_HERE, new TimerTask(this), |
100 tick_interval_); | 100 tick_interval_); |
101 } | 101 } |
OLD | NEW |