| 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 #include "mojo/public/cpp/environment/default_async_waiter.h" | 5 #include "mojo/public/cpp/environment/lib/default_async_waiter.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 | 8 |
| 9 #include "mojo/public/c/environment/async_waiter.h" |
| 9 #include "mojo/public/cpp/utility/run_loop.h" | 10 #include "mojo/public/cpp/utility/run_loop.h" |
| 10 #include "mojo/public/cpp/utility/run_loop_handler.h" | 11 #include "mojo/public/cpp/utility/run_loop_handler.h" |
| 11 | 12 |
| 12 namespace mojo { | 13 namespace mojo { |
| 14 |
| 13 namespace { | 15 namespace { |
| 14 | 16 |
| 15 // RunLoopHandler implementation used for a request to AsyncWait(). There are | 17 // RunLoopHandler implementation used for a request to AsyncWait(). There are |
| 16 // two ways RunLoopHandlerImpl is deleted: | 18 // two ways RunLoopHandlerImpl is deleted: |
| 17 // . when the handle is ready (or errored). | 19 // . when the handle is ready (or errored). |
| 18 // . when CancelWait() is invoked. | 20 // . when CancelWait() is invoked. |
| 19 class RunLoopHandlerImpl : public RunLoopHandler { | 21 class RunLoopHandlerImpl : public RunLoopHandler { |
| 20 public: | 22 public: |
| 21 RunLoopHandlerImpl(const Handle& handle, | 23 RunLoopHandlerImpl(const Handle& handle, |
| 22 MojoAsyncWaitCallback callback, | 24 MojoAsyncWaitCallback callback, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 RunLoopHandlerImpl* run_loop_handler = | 73 RunLoopHandlerImpl* run_loop_handler = |
| 72 new RunLoopHandlerImpl(Handle(handle), callback, closure); | 74 new RunLoopHandlerImpl(Handle(handle), callback, closure); |
| 73 run_loop->AddHandler(run_loop_handler, Handle(handle), signals, deadline); | 75 run_loop->AddHandler(run_loop_handler, Handle(handle), signals, deadline); |
| 74 return reinterpret_cast<MojoAsyncWaitID>(run_loop_handler); | 76 return reinterpret_cast<MojoAsyncWaitID>(run_loop_handler); |
| 75 } | 77 } |
| 76 | 78 |
| 77 void CancelWait(MojoAsyncWaitID wait_id) { | 79 void CancelWait(MojoAsyncWaitID wait_id) { |
| 78 delete reinterpret_cast<RunLoopHandlerImpl*>(wait_id); | 80 delete reinterpret_cast<RunLoopHandlerImpl*>(wait_id); |
| 79 } | 81 } |
| 80 | 82 |
| 83 } // namespace |
| 84 |
| 85 namespace internal { |
| 86 |
| 81 const MojoAsyncWaiter kDefaultAsyncWaiter = { | 87 const MojoAsyncWaiter kDefaultAsyncWaiter = { |
| 82 AsyncWait, | 88 AsyncWait, |
| 83 CancelWait | 89 CancelWait |
| 84 }; | 90 }; |
| 85 | 91 |
| 86 } // namespace | 92 } // namespace internal |
| 87 | |
| 88 const MojoAsyncWaiter* GetDefaultAsyncWaiter() { | |
| 89 return &kDefaultAsyncWaiter; | |
| 90 } | |
| 91 | 93 |
| 92 } // namespace mojo | 94 } // namespace mojo |
| OLD | NEW |