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

Unified Diff: mojo/edk/js/support.cc

Issue 1777673003: [mojo-bindings] Use Watcher API for JS bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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 | « no previous file | mojo/edk/js/waiting_callback.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/js/support.cc
diff --git a/mojo/edk/js/support.cc b/mojo/edk/js/support.cc
index 66d84a082c975a526ae192a04c19bfffd2e8df99..404cb9b786651c90fbfc527f6404547e81955ad4 100644
--- a/mojo/edk/js/support.cc
+++ b/mojo/edk/js/support.cc
@@ -26,14 +26,26 @@ WaitingCallback* AsyncWait(const gin::Arguments& args,
gin::Handle<HandleWrapper> handle,
MojoHandleSignals signals,
v8::Handle<v8::Function> callback) {
- return WaitingCallback::Create(args.isolate(), callback, handle, signals)
- .get();
+ return WaitingCallback::Create(
+ args.isolate(), callback, handle, signals, true /* one_shot */).get();
}
void CancelWait(WaitingCallback* waiting_callback) {
waiting_callback->Cancel();
}
+WaitingCallback* Watch(const gin::Arguments& args,
+ gin::Handle<HandleWrapper> handle,
+ MojoHandleSignals signals,
+ v8::Handle<v8::Function> callback) {
+ return WaitingCallback::Create(
+ args.isolate(), callback, handle, signals, false /* one_shot */).get();
+}
+
+void CancelWatch(WaitingCallback* waiting_callback) {
+ waiting_callback->Cancel();
+}
+
gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin };
} // namespace
@@ -47,8 +59,11 @@ v8::Local<v8::Value> Support::GetModule(v8::Isolate* isolate) {
if (templ.IsEmpty()) {
templ = gin::ObjectTemplateBuilder(isolate)
+ // TODO(rockot): Remove asyncWait and cancelWait.
.SetMethod("asyncWait", AsyncWait)
.SetMethod("cancelWait", CancelWait)
+ .SetMethod("watch", Watch)
+ .SetMethod("cancelWatch", CancelWatch)
.Build();
data->SetObjectTemplate(&g_wrapper_info, templ);
« no previous file with comments | « no previous file | mojo/edk/js/waiting_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698