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

Side by Side Diff: mojo/bindings/js/waiting_callback.h

Issue 276093002: Two fixes for mojo JS bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: alias Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/bindings/js/support.cc ('k') | mojo/bindings/js/waiting_callback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_BINDINGS_JS_WAITING_CALLBACK_H_ 5 #ifndef MOJO_BINDINGS_JS_WAITING_CALLBACK_H_
6 #define MOJO_BINDINGS_JS_WAITING_CALLBACK_H_ 6 #define MOJO_BINDINGS_JS_WAITING_CALLBACK_H_
7 7
8 #include "gin/handle.h" 8 #include "gin/handle.h"
9 #include "gin/runner.h" 9 #include "gin/runner.h"
10 #include "gin/wrappable.h" 10 #include "gin/wrappable.h"
11 #include "mojo/public/c/environment/async_waiter.h" 11 #include "mojo/public/c/environment/async_waiter.h"
12 #include "mojo/public/cpp/system/core.h"
12 13
13 namespace mojo { 14 namespace mojo {
14 namespace js { 15 namespace js {
15 16
16 class WaitingCallback : public gin::Wrappable<WaitingCallback> { 17 class WaitingCallback : public gin::Wrappable<WaitingCallback> {
17 public: 18 public:
18 static gin::WrapperInfo kWrapperInfo; 19 static gin::WrapperInfo kWrapperInfo;
19 20
21 // Creates a new WaitingCallback.
20 static gin::Handle<WaitingCallback> Create( 22 static gin::Handle<WaitingCallback> Create(
21 v8::Isolate* isolate, v8::Handle<v8::Function> callback); 23 v8::Isolate* isolate,
24 v8::Handle<v8::Function> callback,
25 mojo::Handle handle,
26 MojoWaitFlags flags);
22 27
23 MojoAsyncWaitID wait_id() const { 28 // Cancels the callback. Does nothing if a callback is not pending. This is
24 return wait_id_; 29 // implicitly invoked from the destructor but can be explicitly invoked as
25 } 30 // necessary.
26 31 void Cancel();
27 void set_wait_id(MojoAsyncWaitID wait_id) {
28 wait_id_ = wait_id;
29 }
30
31 // MojoAsyncWaitCallback
32 static void CallOnHandleReady(void* closure, MojoResult result);
33 32
34 private: 33 private:
35 WaitingCallback(v8::Isolate* isolate, v8::Handle<v8::Function> callback); 34 WaitingCallback(v8::Isolate* isolate, v8::Handle<v8::Function> callback);
36 virtual ~WaitingCallback(); 35 virtual ~WaitingCallback();
37 36
37 // Callback from MojoAsyncWaiter. |closure| is the WaitingCallback.
38 static void CallOnHandleReady(void* closure, MojoResult result);
39
40 // Invoked from CallOnHandleReady() (CallOnHandleReady() must be static).
38 void OnHandleReady(MojoResult result); 41 void OnHandleReady(MojoResult result);
39 42
40 base::WeakPtr<gin::Runner> runner_; 43 base::WeakPtr<gin::Runner> runner_;
41 MojoAsyncWaitID wait_id_; 44 MojoAsyncWaitID wait_id_;
42 45
43 DISALLOW_COPY_AND_ASSIGN(WaitingCallback); 46 DISALLOW_COPY_AND_ASSIGN(WaitingCallback);
44 }; 47 };
45 48
46 } // namespace js 49 } // namespace js
47 } // namespace mojo 50 } // namespace mojo
48 51
49 #endif // MOJO_BINDINGS_JS_WAITING_CALLBACK_H_ 52 #endif // MOJO_BINDINGS_JS_WAITING_CALLBACK_H_
OLDNEW
« no previous file with comments | « mojo/bindings/js/support.cc ('k') | mojo/bindings/js/waiting_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698