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