| 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" | |
| 13 #include "v8/include/v8.h" | 12 #include "v8/include/v8.h" |
| 14 | 13 |
| 15 namespace extensions { | 14 namespace extensions { |
| 16 namespace v8_helpers { | 15 namespace v8_helpers { |
| 17 | 16 |
| 18 // Helper functions for V8 APIs. | 17 // Helper functions for V8 APIs. |
| 19 | 18 |
| 20 // Converts |str| to a V8 string. Returns true on success. | 19 // Converts |str| to a V8 string. Returns true on success. |
| 21 inline bool ToV8String(v8::Isolate* isolate, | 20 inline bool ToV8String(v8::Isolate* isolate, |
| 22 const char* str, | 21 const char* str, |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 .ToLocalChecked(); | 148 .ToLocalChecked(); |
| 150 } | 149 } |
| 151 | 150 |
| 152 // Wraps v8::Function::Call(). Returns true on success. | 151 // Wraps v8::Function::Call(). Returns true on success. |
| 153 inline bool CallFunction(v8::Local<v8::Context> context, | 152 inline bool CallFunction(v8::Local<v8::Context> context, |
| 154 v8::Local<v8::Function> function, | 153 v8::Local<v8::Function> function, |
| 155 v8::Local<v8::Value> recv, | 154 v8::Local<v8::Value> recv, |
| 156 int argc, | 155 int argc, |
| 157 v8::Local<v8::Value> argv[], | 156 v8::Local<v8::Value> argv[], |
| 158 v8::Local<v8::Value>* out) { | 157 v8::Local<v8::Value>* out) { |
| 159 blink::WebScopedMicrotaskSuppression microtasks_scope; | 158 v8::MicrotasksScope 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 |