| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_DEADLINE_TASK_RUNN
ER_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_DEADLINE_TASK_RUNN
ER_H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_DEADLINE_TASK_RUNN
ER_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_DEADLINE_TASK_RUNN
ER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "platform/PlatformExport.h" |
| 13 #include "platform/scheduler/base/cancelable_closure_holder.h" | 14 #include "platform/scheduler/base/cancelable_closure_holder.h" |
| 14 #include "public/platform/WebCommon.h" | |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 namespace scheduler { | 17 namespace scheduler { |
| 18 | 18 |
| 19 // Runs a posted task at latest by a given deadline, but possibly sooner. | 19 // Runs a posted task at latest by a given deadline, but possibly sooner. |
| 20 class BLINK_PLATFORM_EXPORT DeadlineTaskRunner { | 20 class PLATFORM_EXPORT DeadlineTaskRunner { |
| 21 public: | 21 public: |
| 22 DeadlineTaskRunner(const base::Closure& callback, | 22 DeadlineTaskRunner(const base::Closure& callback, |
| 23 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 23 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 24 | 24 |
| 25 ~DeadlineTaskRunner(); | 25 ~DeadlineTaskRunner(); |
| 26 | 26 |
| 27 // If there is no outstanding task then a task is posted to run after |delay|. | 27 // If there is no outstanding task then a task is posted to run after |delay|. |
| 28 // If there is an outstanding task which is scheduled to run: | 28 // If there is an outstanding task which is scheduled to run: |
| 29 // a) sooner - then this is a NOP. | 29 // a) sooner - then this is a NOP. |
| 30 // b) later - then the outstanding task is cancelled and a new task is | 30 // b) later - then the outstanding task is cancelled and a new task is |
| (...skipping 12 matching lines...) Expand all Loading... |
| 43 base::TimeTicks deadline_; | 43 base::TimeTicks deadline_; |
| 44 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 44 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 45 | 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(DeadlineTaskRunner); | 46 DISALLOW_COPY_AND_ASSIGN(DeadlineTaskRunner); |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 } // namespace scheduler | 49 } // namespace scheduler |
| 50 } // namespace blink | 50 } // namespace blink |
| 51 | 51 |
| 52 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_DEADLINE_TASK_R
UNNER_H_ | 52 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_DEADLINE_TASK_R
UNNER_H_ |
| OLD | NEW |