Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Unified Diff: mojo/public/bindings/js/support.cc

Issue 93813002: Implement gin::ObjectTemplateBuilder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asdf Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/bindings/js/core.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/bindings/js/support.cc
diff --git a/mojo/public/bindings/js/support.cc b/mojo/public/bindings/js/support.cc
index 7430bfce810b1fbca178487b8bd913c659f8da7e..cf2f1c86ad7d4dd429216957159b4cf053468b08 100644
--- a/mojo/public/bindings/js/support.cc
+++ b/mojo/public/bindings/js/support.cc
@@ -8,6 +8,7 @@
#include "gin/arguments.h"
#include "gin/converter.h"
#include "gin/function_template.h"
+#include "gin/object_template_builder.h"
#include "gin/per_isolate_data.h"
#include "gin/public/wrapper_info.h"
#include "gin/wrappable.h"
@@ -20,18 +21,9 @@ namespace js {
namespace {
-void AsyncWait(const v8::FunctionCallbackInfo<v8::Value>& info) {
- gin::Arguments args(info);
-
- mojo::Handle handle;
- MojoWaitFlags flags = MOJO_WAIT_FLAG_NONE;
- v8::Handle<v8::Function> callback;
-
- if (!args.GetNext(&handle) ||
- !args.GetNext(&flags) ||
- !args.GetNext(&callback))
- return args.ThrowError();
-
+WaitingCallback* AsyncWait(const gin::Arguments& args, mojo::Handle handle,
+ MojoWaitFlags flags,
+ v8::Handle<v8::Function> callback) {
scoped_refptr<WaitingCallback> waiting_callback =
WaitingCallback::Create(args.isolate(), callback);
@@ -40,7 +32,7 @@ void AsyncWait(const v8::FunctionCallbackInfo<v8::Value>& info) {
waiting_callback->set_wait_id(wait_id);
- args.Return(waiting_callback.get());
+ return waiting_callback.get();
}
void CancelWait(WaitingCallback* waiting_callback) {
@@ -64,12 +56,10 @@ v8::Local<v8::ObjectTemplate> Support::GetTemplate(v8::Isolate* isolate) {
if (templ.IsEmpty()) {
WaitingCallback::EnsureRegistered(isolate);
- templ = v8::ObjectTemplate::New(isolate);
-
- templ->Set(gin::StringToSymbol(isolate, "asyncWait"),
- v8::FunctionTemplate::New(isolate, AsyncWait));
- templ->Set(gin::StringToSymbol(isolate, "cancelWait"),
- gin::CreateFunctionTemplate(isolate, base::Bind(CancelWait)));
+ templ = gin::ObjectTemplateBuilder(isolate)
+ .SetMethod("asyncWait", AsyncWait)
+ .SetMethod("cancelWait", CancelWait)
+ .Build();
data->SetObjectTemplate(&g_wrapper_info, templ);
}
« no previous file with comments | « mojo/public/bindings/js/core.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698