| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_POLICY_DELAYED_WORK_SCHEDULER_H_ | |
| 6 #define CHROME_BROWSER_POLICY_DELAYED_WORK_SCHEDULER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/callback.h" | |
| 10 #include "base/timer.h" | |
| 11 | |
| 12 namespace policy { | |
| 13 | |
| 14 // A mockable class for scheduling and cancelling a delayed task. | |
| 15 // This is only a thin wrapper around base::OneShotTimer. | |
| 16 // This class is not thread-safe: all its methods should be called on the same | |
| 17 // thread, and the callback will happen on that same thread. | |
| 18 class DelayedWorkScheduler { | |
| 19 public: | |
| 20 DelayedWorkScheduler(); | |
| 21 virtual ~DelayedWorkScheduler(); | |
| 22 | |
| 23 // Cancels the delayed work task. | |
| 24 virtual void CancelDelayedWork(); | |
| 25 | |
| 26 // Posts a new delayed task. | |
| 27 virtual void PostDelayedWork(const base::Closure& callback, int64 delay); | |
| 28 | |
| 29 private: | |
| 30 base::OneShotTimer<DelayedWorkScheduler> timer_; | |
| 31 base::Closure callback_; | |
| 32 | |
| 33 void DoDelayedWork(); | |
| 34 | |
| 35 DISALLOW_COPY_AND_ASSIGN(DelayedWorkScheduler); | |
| 36 }; | |
| 37 | |
| 38 } // namespace policy | |
| 39 | |
| 40 #endif // CHROME_BROWSER_POLICY_DELAYED_WORK_SCHEDULER_H_ | |
| OLD | NEW |