Chromium Code Reviews| Index: pdf/timer.h |
| diff --git a/pdf/timer.h b/pdf/timer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c9fba9d5191e1cb70df8a732245301dfd85980e7 |
| --- /dev/null |
| +++ b/pdf/timer.h |
| @@ -0,0 +1,52 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef PDF_TIMER_H_ |
| +#define PDF_TIMER_H_ |
| + |
| +#include <set> |
| + |
| +#include "base/macros.h" |
| +#include "ppapi/utility/completion_callback_factory.h" |
| + |
| +namespace chrome_pdf { |
| + |
| +class Timer { |
|
Lei Zhang
2016/10/05 07:18:08
I only see one class inherit from Timer. Is it goi
snake
2016/10/05 14:14:10
I want reuse it in next CLs for PDF plugin.
|
| + public: |
| + explicit Timer(int delay); |
| + virtual ~Timer(); |
| + |
| + virtual void OnTimer() = 0; |
| + |
| + private: |
| + friend class TestTimerRunner; |
| + void PostCallback(); |
| + void TimerProc(int32_t result); |
| + |
| + int delay_; |
| + pp::CompletionCallbackFactory<Timer> callback_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Timer); |
| +}; |
| + |
| +class TestTimerRunner { |
| + public: |
| + TestTimerRunner(); |
|
Lei Zhang
2016/10/05 07:18:08
I don't see this class getting instantiated anywhe
snake
2016/10/05 14:14:10
This will be needs for tests in next CLs.
Lei Zhang
2016/10/21 09:33:08
So can you add this in the next CL, when it is nee
|
| + virtual ~TestTimerRunner(); |
| + |
| + void RunUntilIdle(); |
| + void RunScheduled(); |
| + int scheduled_count() const; |
| + void RegisterTimer(Timer* timer); |
| + void UnregisterTimer(Timer* timer); |
| + |
| + private: |
| + std::set<Timer*> scheduled_timers_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TestTimerRunner); |
| +}; |
| + |
| +} // namespace chrome_pdf |
| + |
| +#endif // PDF_TIMER_H_ |