| OLD | NEW |
| 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_EDK_JS_WAITING_CALLBACK_H_ | 5 #ifndef MOJO_EDK_JS_WAITING_CALLBACK_H_ |
| 6 #define MOJO_EDK_JS_WAITING_CALLBACK_H_ | 6 #define MOJO_EDK_JS_WAITING_CALLBACK_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 8 #include "gin/handle.h" | 9 #include "gin/handle.h" |
| 9 #include "gin/runner.h" | 10 #include "gin/runner.h" |
| 10 #include "gin/wrappable.h" | 11 #include "gin/wrappable.h" |
| 11 #include "mojo/edk/js/handle.h" | 12 #include "mojo/edk/js/handle.h" |
| 12 #include "mojo/edk/js/handle_close_observer.h" | 13 #include "mojo/edk/js/handle_close_observer.h" |
| 13 #include "mojo/public/c/environment/async_waiter.h" | 14 #include "mojo/public/c/environment/async_waiter.h" |
| 14 #include "mojo/public/cpp/system/core.h" | 15 #include "mojo/public/cpp/system/core.h" |
| 15 | 16 |
| 16 namespace mojo { | 17 namespace mojo { |
| 17 namespace js { | 18 namespace js { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 42 // Callback from MojoAsyncWaiter. |closure| is the WaitingCallback. | 43 // Callback from MojoAsyncWaiter. |closure| is the WaitingCallback. |
| 43 static void CallOnHandleReady(void* closure, MojoResult result); | 44 static void CallOnHandleReady(void* closure, MojoResult result); |
| 44 | 45 |
| 45 // Invoked from CallOnHandleReady() (CallOnHandleReady() must be static). | 46 // Invoked from CallOnHandleReady() (CallOnHandleReady() must be static). |
| 46 void OnHandleReady(MojoResult result); | 47 void OnHandleReady(MojoResult result); |
| 47 | 48 |
| 48 // Invoked by the HandleWrapper if the handle is closed while this wait is | 49 // Invoked by the HandleWrapper if the handle is closed while this wait is |
| 49 // still in progress. | 50 // still in progress. |
| 50 void OnWillCloseHandle() override; | 51 void OnWillCloseHandle() override; |
| 51 | 52 |
| 53 void ClearWaitId(); |
| 54 void CallCallback(MojoResult result); |
| 55 |
| 52 base::WeakPtr<gin::Runner> runner_; | 56 base::WeakPtr<gin::Runner> runner_; |
| 53 MojoAsyncWaitID wait_id_; | 57 MojoAsyncWaitID wait_id_; |
| 54 | 58 |
| 55 HandleWrapper* handle_wrapper_; | 59 HandleWrapper* handle_wrapper_; |
| 60 base::WeakPtrFactory<WaitingCallback> weak_factory_; |
| 56 | 61 |
| 57 DISALLOW_COPY_AND_ASSIGN(WaitingCallback); | 62 DISALLOW_COPY_AND_ASSIGN(WaitingCallback); |
| 58 }; | 63 }; |
| 59 | 64 |
| 60 } // namespace js | 65 } // namespace js |
| 61 } // namespace mojo | 66 } // namespace mojo |
| 62 | 67 |
| 63 #endif // MOJO_EDK_JS_WAITING_CALLBACK_H_ | 68 #endif // MOJO_EDK_JS_WAITING_CALLBACK_H_ |
| OLD | NEW |