Index: gin/run_microtasks_observer.h |
diff --git a/gin/run_microtasks_observer.h b/gin/run_microtasks_observer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e848239ef2f62aaf6db5a9b452e0aac64c8793f0 |
--- /dev/null |
+++ b/gin/run_microtasks_observer.h |
@@ -0,0 +1,30 @@ |
+// Copyright 2014 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 GIN_RUN_MICROTASKS_OBSERVER_H_ |
+#define GIN_RUN_MICROTASKS_OBSERVER_H_ |
+ |
+#include "base/message_loop/message_loop.h" |
+#include "v8/include/v8.h" |
+ |
+namespace gin { |
+ |
+// Runs any pending v8 Microtasks each time a task is completed. |
+// TODO(hansmuller); At some point perhaps this can be replaced with |
+// the (currently experimental) Isolate::SetAutorunMicrotasks() method. |
+ |
+class RunMicrotasksObserver : public base::MessageLoop::TaskObserver { |
+ public: |
+ RunMicrotasksObserver(v8::Isolate* isolate); |
+ |
+ virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE; |
+ virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE; |
+ |
+ private: |
+ v8::Isolate* isolate_; |
+}; |
+ |
+} // namespace gin |
+ |
+#endif // GIN_RUN_MICROTASKS_OBSERVER_H_ |