summaryrefslogtreecommitdiffstats
path: root/gin/run_microtasks_observer.h
blob: 7f1431fb2ec253f579e1f487aa9ffc2759d9c6d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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);

  void WillProcessTask(const base::PendingTask& pending_task) override;
  void DidProcessTask(const base::PendingTask& pending_task) override;

 private:
  v8::Isolate* isolate_;
};

}  // namespace gin

#endif  // GIN_RUN_MICROTASKS_OBSERVER_H_