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

Unified Diff: mojo/edk/js/waiting_callback.h

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 | « mojo/edk/js/support.cc ('k') | mojo/edk/js/waiting_callback.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/js/waiting_callback.h
diff --git a/mojo/edk/js/waiting_callback.h b/mojo/edk/js/waiting_callback.h
index f2554bc293ac3b7e360c97d0d5834d9b7421ecea..0225034e57a412c6ee544eed7a04d84509d8082c 100644
--- a/mojo/edk/js/waiting_callback.h
+++ b/mojo/edk/js/waiting_callback.h
@@ -14,6 +14,7 @@
#include "mojo/edk/js/handle_close_observer.h"
#include "mojo/message_pump/handle_watcher.h"
#include "mojo/public/cpp/system/core.h"
+#include "mojo/public/cpp/system/watcher.h"
namespace mojo {
namespace edk {
@@ -25,11 +26,16 @@ class WaitingCallback : public gin::Wrappable<WaitingCallback>,
static gin::WrapperInfo kWrapperInfo;
// Creates a new WaitingCallback.
+ //
+ // If |one_shot| is true, the callback will only ever be called at most once.
+ // If false, the callback may be called any number of times until the
+ // WaitingCallback is explicitly cancelled.
static gin::Handle<WaitingCallback> Create(
v8::Isolate* isolate,
v8::Handle<v8::Function> callback,
gin::Handle<HandleWrapper> handle_wrapper,
- MojoHandleSignals signals);
+ MojoHandleSignals signals,
+ bool one_shot);
// Cancels the callback. Does nothing if a callback is not pending. This is
// implicitly invoked from the destructor but can be explicitly invoked as
@@ -39,7 +45,8 @@ class WaitingCallback : public gin::Wrappable<WaitingCallback>,
private:
WaitingCallback(v8::Isolate* isolate,
v8::Handle<v8::Function> callback,
- gin::Handle<HandleWrapper> handle_wrapper);
+ gin::Handle<HandleWrapper> handle_wrapper,
+ bool one_shot);
~WaitingCallback() override;
// Callback from common::HandleWatcher.
@@ -52,9 +59,15 @@ class WaitingCallback : public gin::Wrappable<WaitingCallback>,
void RemoveHandleCloseObserver();
void CallCallback(MojoResult result);
+ // Indicates whether this is a one-shot callback or not. If so, it uses the
yzshen1 2016/03/08 22:37:25 It seems straightforward to use the new Watcher AP
+ // deprecated HandleWatcher to wait for signals; otherwise it uses the new
+ // system Watcher API.
+ const bool one_shot_;
+
base::WeakPtr<gin::Runner> runner_;
common::HandleWatcher handle_watcher_;
+ Watcher watcher_;
HandleWrapper* handle_wrapper_;
base::WeakPtrFactory<WaitingCallback> weak_factory_;
« no previous file with comments | « mojo/edk/js/support.cc ('k') | mojo/edk/js/waiting_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698