hansmuller | 5a5cb9e | 2014-09-25 18:41:18 | [diff] [blame] | 1 | // Copyright 2014 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 GIN_RUN_MICROTASKS_OBSERVER_H_ |
| 6 | #define GIN_RUN_MICROTASKS_OBSERVER_H_ |
| 7 | |
| 8 | #include "base/message_loop/message_loop.h" |
| 9 | #include "v8/include/v8.h" |
| 10 | |
| 11 | namespace gin { |
| 12 | |
| 13 | // Runs any pending v8 Microtasks each time a task is completed. |
| 14 | // TODO(hansmuller); At some point perhaps this can be replaced with |
dgozman | fdfd5d1 | 2016-03-11 07:50:47 | [diff] [blame] | 15 | // the (currently experimental) v8::MicrotasksPolicy::kAuto method. |
hansmuller | 5a5cb9e | 2014-09-25 18:41:18 | [diff] [blame] | 16 | |
| 17 | class RunMicrotasksObserver : public base::MessageLoop::TaskObserver { |
| 18 | public: |
| 19 | RunMicrotasksObserver(v8::Isolate* isolate); |
| 20 | |
dcheng | 074c039 | 2014-10-23 19:08:25 | [diff] [blame] | 21 | void WillProcessTask(const base::PendingTask& pending_task) override; |
| 22 | void DidProcessTask(const base::PendingTask& pending_task) override; |
hansmuller | 5a5cb9e | 2014-09-25 18:41:18 | [diff] [blame] | 23 | |
| 24 | private: |
| 25 | v8::Isolate* isolate_; |
| 26 | }; |
| 27 | |
| 28 | } // namespace gin |
| 29 | |
| 30 | #endif // GIN_RUN_MICROTASKS_OBSERVER_H_ |