diff options
Diffstat (limited to 'chromium/gin/modules/console.cc')
-rw-r--r-- | chromium/gin/modules/console.cc | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/chromium/gin/modules/console.cc b/chromium/gin/modules/console.cc index 14849944bfa..d172373f01d 100644 --- a/chromium/gin/modules/console.cc +++ b/chromium/gin/modules/console.cc @@ -9,6 +9,7 @@ #include "base/strings/string_util.h" #include "gin/arguments.h" #include "gin/converter.h" +#include "gin/object_template_builder.h" #include "gin/per_isolate_data.h" #include "gin/public/wrapper_info.h" @@ -18,13 +19,12 @@ namespace gin { namespace { -void Log(const v8::FunctionCallbackInfo<v8::Value>& info) { - Arguments args(info); - +void Log(Arguments* args) { std::vector<std::string> messages; - if (!args.GetRemaining(&messages)) - return args.ThrowTypeError("Expected strings."); - + if (!args->GetRemaining(&messages)) { + args->ThrowError(); + return; + } std::cout << JoinString(messages, ' ') << std::endl; } @@ -34,16 +34,16 @@ WrapperInfo g_wrapper_info = { kEmbedderNativeGin }; const char Console::kModuleName[] = "console"; -v8::Local<ObjectTemplate> Console::GetTemplate(v8::Isolate* isolate) { +v8::Local<v8::Value> Console::GetModule(v8::Isolate* isolate) { PerIsolateData* data = PerIsolateData::From(isolate); v8::Local<ObjectTemplate> templ = data->GetObjectTemplate(&g_wrapper_info); if (templ.IsEmpty()) { - templ = ObjectTemplate::New(); - templ->Set(StringToSymbol(isolate, "log"), - v8::FunctionTemplate::New(isolate, Log)); + templ = ObjectTemplateBuilder(isolate) + .SetMethod("log", Log) + .Build(); data->SetObjectTemplate(&g_wrapper_info, templ); } - return templ; + return templ->NewInstance(); } } // namespace gin |