summaryrefslogtreecommitdiffstats
path: root/gin
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-17 07:54:30 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-17 07:54:30 +0000
commit9e5a71e5ac484388288bc314910c27f94e3f8301 (patch)
tree0a591f08375a011fbcd8d8e20dc93f421ea7658d /gin
parent99cafcb7d2bdf2543744de6bab6ae30f9070a5c5 (diff)
downloadchromium_src-9e5a71e5ac484388288bc314910c27f94e3f8301.zip
chromium_src-9e5a71e5ac484388288bc314910c27f94e3f8301.tar.gz
chromium_src-9e5a71e5ac484388288bc314910c27f94e3f8301.tar.bz2
[gin] Use ObjectTemplateBuilder instead of ObjectTemplate::New
With https://codereview.chromium.org/113893005/ this will make sure that all ObjectTemplates have the correct number of internal fields. BUG=none R=aa@chromium.org, abarth@chromium.org Review URL: https://codereview.chromium.org/116203004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241197 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gin')
-rw-r--r--gin/modules/console.cc15
-rw-r--r--gin/modules/module_runner_delegate.cc4
2 files changed, 8 insertions, 11 deletions
diff --git a/gin/modules/console.cc b/gin/modules/console.cc
index 1484994..84c620a 100644
--- a/gin/modules/console.cc
+++ b/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,7 @@ namespace gin {
namespace {
-void Log(const v8::FunctionCallbackInfo<v8::Value>& info) {
- Arguments args(info);
-
- std::vector<std::string> messages;
- if (!args.GetRemaining(&messages))
- return args.ThrowTypeError("Expected strings.");
-
+void Log(const std::vector<std::string>& messages) {
std::cout << JoinString(messages, ' ') << std::endl;
}
@@ -38,9 +33,9 @@ v8::Local<ObjectTemplate> Console::GetTemplate(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;
diff --git a/gin/modules/module_runner_delegate.cc b/gin/modules/module_runner_delegate.cc
index 9bf2863..404f5dc 100644
--- a/gin/modules/module_runner_delegate.cc
+++ b/gin/modules/module_runner_delegate.cc
@@ -5,6 +5,7 @@
#include "gin/modules/module_runner_delegate.h"
#include "gin/modules/module_registry.h"
+#include "gin/object_template_builder.h"
namespace gin {
@@ -30,7 +31,8 @@ void ModuleRunnerDelegate::AttemptToLoadMoreModules(Runner* runner) {
v8::Handle<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate(
Runner* runner) {
- v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
+ v8::Handle<v8::ObjectTemplate> templ =
+ ObjectTemplateBuilder(runner->isolate()).Build();
ModuleRegistry::RegisterGlobals(runner->isolate(), templ);
return templ;
}