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 EXTENSIONS_RENDERER_V8_HELPERS_H_ | 5 #ifndef EXTENSIONS_RENDERER_V8_HELPERS_H_ |
6 #define EXTENSIONS_RENDERER_V8_HELPERS_H_ | 6 #define EXTENSIONS_RENDERER_V8_HELPERS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" |
12 #include "v8/include/v8.h" | 13 #include "v8/include/v8.h" |
13 | 14 |
14 namespace extensions { | 15 namespace extensions { |
15 namespace v8_helpers { | 16 namespace v8_helpers { |
16 | 17 |
17 // Helper functions for V8 APIs. | 18 // Helper functions for V8 APIs. |
18 | 19 |
19 // Converts |str| to a V8 string. Returns true on success. | 20 // Converts |str| to a V8 string. Returns true on success. |
20 inline bool ToV8String(v8::Isolate* isolate, | 21 inline bool ToV8String(v8::Isolate* isolate, |
21 const char* str, | 22 const char* str, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 .ToLocalChecked(); | 149 .ToLocalChecked(); |
149 } | 150 } |
150 | 151 |
151 // Wraps v8::Function::Call(). Returns true on success. | 152 // Wraps v8::Function::Call(). Returns true on success. |
152 inline bool CallFunction(v8::Local<v8::Context> context, | 153 inline bool CallFunction(v8::Local<v8::Context> context, |
153 v8::Local<v8::Function> function, | 154 v8::Local<v8::Function> function, |
154 v8::Local<v8::Value> recv, | 155 v8::Local<v8::Value> recv, |
155 int argc, | 156 int argc, |
156 v8::Local<v8::Value> argv[], | 157 v8::Local<v8::Value> argv[], |
157 v8::Local<v8::Value>* out) { | 158 v8::Local<v8::Value>* out) { |
158 v8::MicrotasksScope microtasks_scope( | 159 blink::WebScopedMicrotaskSuppression microtasks_scope; |
159 context->GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); | |
160 return function->Call(context, recv, argc, argv).ToLocal(out); | 160 return function->Call(context, recv, argc, argv).ToLocal(out); |
161 } | 161 } |
162 | 162 |
163 } // namespace v8_helpers | 163 } // namespace v8_helpers |
164 } // namespace extensions | 164 } // namespace extensions |
165 | 165 |
166 #endif // EXTENSIONS_RENDERER_V8_HELPERS_H_ | 166 #endif // EXTENSIONS_RENDERER_V8_HELPERS_H_ |
OLD | NEW |