OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_SYSTEM_HANDLE_TRANSPORT_H_ |
| 6 #define MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_ |
| 7 |
| 8 #include "mojo/edk/system/dispatcher.h" |
| 9 #include "mojo/edk/util/ref_ptr.h" |
| 10 #include "mojo/edk/util/thread_annotations.h" |
| 11 |
| 12 namespace mojo { |
| 13 namespace system { |
| 14 |
| 15 class MessagePipe; |
| 16 |
| 17 // Wrapper around a |Dispatcher| pointer, while it's being processed to be |
| 18 // passed in a message pipe. See the comment about |
| 19 // |Dispatcher::HandleTableAccess| for more details. |
| 20 // |
| 21 // Note: This class is deliberately "thin" -- no more expensive than a |
| 22 // |Dispatcher*|. |
| 23 // |
| 24 // TODO(vtl): Add handle rights to this, and rename it to HandleTransport. |
| 25 class DispatcherTransport final { |
| 26 public: |
| 27 DispatcherTransport() : dispatcher_(nullptr) {} |
| 28 |
| 29 void End() MOJO_NOT_THREAD_SAFE; |
| 30 |
| 31 Dispatcher::Type GetType() const { return dispatcher_->GetType(); } |
| 32 bool IsBusy() const MOJO_NOT_THREAD_SAFE { |
| 33 return dispatcher_->IsBusyNoLock(); |
| 34 } |
| 35 void Close() MOJO_NOT_THREAD_SAFE { dispatcher_->CloseNoLock(); } |
| 36 util::RefPtr<Dispatcher> CreateEquivalentDispatcherAndClose( |
| 37 MessagePipe* message_pipe, |
| 38 unsigned port) MOJO_NOT_THREAD_SAFE { |
| 39 return dispatcher_->CreateEquivalentDispatcherAndCloseNoLock(message_pipe, |
| 40 port); |
| 41 } |
| 42 |
| 43 bool is_valid() const { return !!dispatcher_; } |
| 44 |
| 45 private: |
| 46 friend class Dispatcher::HandleTableAccess; |
| 47 |
| 48 explicit DispatcherTransport(Dispatcher* dispatcher) |
| 49 : dispatcher_(dispatcher) {} |
| 50 |
| 51 Dispatcher* dispatcher_; |
| 52 |
| 53 // Copy and assign allowed. |
| 54 }; |
| 55 |
| 56 } // namespace system |
| 57 } // namespace mojo |
| 58 |
| 59 #endif // MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_ |
OLD | NEW |