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

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

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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
« no previous file with comments | « mojo/edk/js/threading.cc ('k') | mojo/edk/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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_EDK_JS_WAITING_CALLBACK_H_
6 #define MOJO_EDK_JS_WAITING_CALLBACK_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "gin/handle.h"
10 #include "gin/runner.h"
11 #include "gin/wrappable.h"
12 #include "mojo/edk/js/handle.h"
13 #include "mojo/edk/js/handle_close_observer.h"
14 #include "mojo/public/c/environment/async_waiter.h"
15 #include "mojo/public/cpp/system/core.h"
16
17 namespace mojo {
18 namespace js {
19
20 class WaitingCallback : public gin::Wrappable<WaitingCallback>,
21 public HandleCloseObserver {
22 public:
23 static gin::WrapperInfo kWrapperInfo;
24
25 // Creates a new WaitingCallback.
26 static gin::Handle<WaitingCallback> Create(
27 v8::Isolate* isolate,
28 v8::Handle<v8::Function> callback,
29 gin::Handle<HandleWrapper> handle_wrapper,
30 MojoHandleSignals signals);
31
32 // Cancels the callback. Does nothing if a callback is not pending. This is
33 // implicitly invoked from the destructor but can be explicitly invoked as
34 // necessary.
35 void Cancel();
36
37 private:
38 WaitingCallback(v8::Isolate* isolate,
39 v8::Handle<v8::Function> callback,
40 gin::Handle<HandleWrapper> handle_wrapper);
41 ~WaitingCallback() override;
42
43 // Callback from MojoAsyncWaiter. |closure| is the WaitingCallback.
44 static void CallOnHandleReady(void* closure, MojoResult result);
45
46 // Invoked from CallOnHandleReady() (CallOnHandleReady() must be static).
47 void OnHandleReady(MojoResult result);
48
49 // Invoked by the HandleWrapper if the handle is closed while this wait is
50 // still in progress.
51 void OnWillCloseHandle() override;
52
53 void ClearWaitId();
54 void CallCallback(MojoResult result);
55
56 base::WeakPtr<gin::Runner> runner_;
57 MojoAsyncWaitID wait_id_;
58
59 HandleWrapper* handle_wrapper_;
60 base::WeakPtrFactory<WaitingCallback> weak_factory_;
61
62 DISALLOW_COPY_AND_ASSIGN(WaitingCallback);
63 };
64
65 } // namespace js
66 } // namespace mojo
67
68 #endif // MOJO_EDK_JS_WAITING_CALLBACK_H_
OLDNEW
« no previous file with comments | « mojo/edk/js/threading.cc ('k') | mojo/edk/js/waiting_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698