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 <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "v8/include/v8.h" | 10 #include "v8/include/v8.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 inline v8::Local<v8::Value> GetPropertyUnsafe( | 93 inline v8::Local<v8::Value> GetPropertyUnsafe( |
94 v8::Local<v8::Context> context, | 94 v8::Local<v8::Context> context, |
95 v8::Local<v8::Object> object, | 95 v8::Local<v8::Object> object, |
96 const char* key, | 96 const char* key, |
97 v8::NewStringType string_type = v8::NewStringType::kNormal) { | 97 v8::NewStringType string_type = v8::NewStringType::kNormal) { |
98 return object->Get(context, | 98 return object->Get(context, |
99 ToV8StringUnsafe(context->GetIsolate(), key, string_type)) | 99 ToV8StringUnsafe(context->GetIsolate(), key, string_type)) |
100 .ToLocalChecked(); | 100 .ToLocalChecked(); |
101 } | 101 } |
102 | 102 |
| 103 // Wraps v8::Function::Call(). Returns true on success. |
| 104 inline bool CallFunction(v8::Local<v8::Context> context, |
| 105 v8::Local<v8::Function> function, |
| 106 v8::Local<v8::Value> recv, |
| 107 int argc, |
| 108 v8::Local<v8::Value> argv[], |
| 109 v8::Local<v8::Value>* out) { |
| 110 return function->Call(context, recv, argc, argv).ToLocal(out); |
| 111 } |
| 112 |
103 } // namespace v8_helpers | 113 } // namespace v8_helpers |
104 } // namespace extensions | 114 } // namespace extensions |
105 | 115 |
106 #endif // EXTENSIONS_RENDERER_V8_HELPERS_H_ | 116 #endif // EXTENSIONS_RENDERER_V8_HELPERS_H_ |
OLD | NEW |