Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BROWSER_POLICY_DELAYED_WORK_SCHEDULER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_DELAYED_WORK_SCHEDULER_H_ |
| 6 #define CHROME_BROWSER_POLICY_DELAYED_WORK_SCHEDULER_H_ | 6 #define CHROME_BROWSER_POLICY_DELAYED_WORK_SCHEDULER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/timer.h" | 10 #include "base/timer.h" |
| 11 | 11 |
| 12 namespace policy { | 12 namespace policy { |
| 13 | 13 |
| 14 // A mockable class for scheduling and cancelling a delayed task. | 14 // A mockable class for scheduling and cancelling a delayed task. |
| 15 // This is only a thin wrapper around base::OneShotTimer. | 15 // This is only a thin wrapper around base::OneShotTimer. |
| 16 class DelayedWorkScheduler { | 16 class DelayedWorkScheduler { |
| 17 public: | 17 public: |
| 18 DelayedWorkScheduler(); | 18 DelayedWorkScheduler(); |
| 19 virtual ~DelayedWorkScheduler(); | 19 virtual ~DelayedWorkScheduler(); |
| 20 | 20 |
| 21 // Cancels the delayed work task. | 21 // Cancels the delayed work task. |
| 22 virtual void CancelDelayedWork(); | 22 virtual void CancelDelayedWork(); |
| 23 | 23 |
| 24 // Posts a new delayed task. | 24 // Posts a new delayed task. |
| 25 virtual void PostDelayedWork(const base::Closure& callback, int64 delay); | 25 virtual void PostDelayedWork(const base::Closure& callback, int64 delay); |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 base::OneShotTimer<DelayedWorkScheduler> timer_; | 28 base::OneShotTimer<DelayedWorkScheduler> timer_; |
| 29 base::Closure callback_; | 29 base::Closure callback_; |
|
zunger
2011/07/19 19:41:46
I'm confused by this. Callbacks are designed to be
gfeher
2011/07/20 16:36:30
Callbacks in the Chromium codebase seem to work di
| |
| 30 | 30 |
| 31 void DoDelayedWork(); | 31 void DoDelayedWork(); |
| 32 | 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(DelayedWorkScheduler); | 33 DISALLOW_COPY_AND_ASSIGN(DelayedWorkScheduler); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 } // namespace policy | 36 } // namespace policy |
| 37 | 37 |
| 38 #endif // CHROME_BROWSER_POLICY_DELAYED_WORK_SCHEDULER_H_ | 38 #endif // CHROME_BROWSER_POLICY_DELAYED_WORK_SCHEDULER_H_ |
| 39 | |
| OLD | NEW |