| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project 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 V8_CANCELABLE_TASK_H_ | 5 #ifndef V8_CANCELABLE_TASK_H_ |
| 6 #define V8_CANCELABLE_TASK_H_ | 6 #define V8_CANCELABLE_TASK_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "include/v8-platform.h" | 10 #include "include/v8-platform.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 friend class CancelableTaskManager; | 119 friend class CancelableTaskManager; |
| 120 | 120 |
| 121 DISALLOW_COPY_AND_ASSIGN(Cancelable); | 121 DISALLOW_COPY_AND_ASSIGN(Cancelable); |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 | 124 |
| 125 // Multiple inheritance can be used because Task is a pure interface. | 125 // Multiple inheritance can be used because Task is a pure interface. |
| 126 class CancelableTask : public Cancelable, public Task { | 126 class CancelableTask : public Cancelable, public Task { |
| 127 public: | 127 public: |
| 128 explicit CancelableTask(Isolate* isolate); | 128 explicit CancelableTask(Isolate* isolate); |
| 129 CancelableTask(Isolate* isolate, CancelableTaskManager* manager); |
| 129 | 130 |
| 130 // Task overrides. | 131 // Task overrides. |
| 131 void Run() final { | 132 void Run() final { |
| 132 if (TryRun()) { | 133 if (TryRun()) { |
| 133 RunInternal(); | 134 RunInternal(); |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 | 137 |
| 137 virtual void RunInternal() = 0; | 138 virtual void RunInternal() = 0; |
| 138 | 139 |
| 139 Isolate* isolate() { return isolate_; } | 140 Isolate* isolate() { return isolate_; } |
| 140 | 141 |
| 141 private: | 142 private: |
| 142 Isolate* isolate_; | 143 Isolate* isolate_; |
| 143 DISALLOW_COPY_AND_ASSIGN(CancelableTask); | 144 DISALLOW_COPY_AND_ASSIGN(CancelableTask); |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 | 147 |
| 147 // Multiple inheritance can be used because IdleTask is a pure interface. | 148 // Multiple inheritance can be used because IdleTask is a pure interface. |
| 148 class CancelableIdleTask : public Cancelable, public IdleTask { | 149 class CancelableIdleTask : public Cancelable, public IdleTask { |
| 149 public: | 150 public: |
| 150 explicit CancelableIdleTask(Isolate* isolate); | 151 explicit CancelableIdleTask(Isolate* isolate); |
| 152 CancelableIdleTask(Isolate* isolate, CancelableTaskManager* manager); |
| 151 | 153 |
| 152 // IdleTask overrides. | 154 // IdleTask overrides. |
| 153 void Run(double deadline_in_seconds) final { | 155 void Run(double deadline_in_seconds) final { |
| 154 if (TryRun()) { | 156 if (TryRun()) { |
| 155 RunInternal(deadline_in_seconds); | 157 RunInternal(deadline_in_seconds); |
| 156 } | 158 } |
| 157 } | 159 } |
| 158 | 160 |
| 159 virtual void RunInternal(double deadline_in_seconds) = 0; | 161 virtual void RunInternal(double deadline_in_seconds) = 0; |
| 160 | 162 |
| 161 Isolate* isolate() { return isolate_; } | 163 Isolate* isolate() { return isolate_; } |
| 162 | 164 |
| 163 private: | 165 private: |
| 164 Isolate* isolate_; | 166 Isolate* isolate_; |
| 165 DISALLOW_COPY_AND_ASSIGN(CancelableIdleTask); | 167 DISALLOW_COPY_AND_ASSIGN(CancelableIdleTask); |
| 166 }; | 168 }; |
| 167 | 169 |
| 168 | 170 |
| 169 } // namespace internal | 171 } // namespace internal |
| 170 } // namespace v8 | 172 } // namespace v8 |
| 171 | 173 |
| 172 #endif // V8_CANCELABLE_TASK_H_ | 174 #endif // V8_CANCELABLE_TASK_H_ |
| OLD | NEW |