| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_SYSTEM_HANDLE_TRANSPORT_H_ | 5 #ifndef MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_ |
| 6 #define MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_ | 6 #define MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_ |
| 7 | 7 |
| 8 #include "mojo/edk/system/dispatcher.h" | 8 #include "mojo/edk/system/dispatcher.h" |
| 9 #include "mojo/edk/system/handle.h" | 9 #include "mojo/edk/system/handle.h" |
| 10 #include "mojo/edk/util/ref_ptr.h" | 10 #include "mojo/edk/util/ref_ptr.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // | 24 // |
| 25 // Note: This class is deliberately "thin" -- no more expensive than a struct | 25 // Note: This class is deliberately "thin" -- no more expensive than a struct |
| 26 // containing a |Dispatcher*| and a |MojoHandleRights|. | 26 // containing a |Dispatcher*| and a |MojoHandleRights|. |
| 27 class HandleTransport final { | 27 class HandleTransport final { |
| 28 public: | 28 public: |
| 29 HandleTransport() : dispatcher_(nullptr), rights_(MOJO_HANDLE_RIGHT_NONE) {} | 29 HandleTransport() : dispatcher_(nullptr), rights_(MOJO_HANDLE_RIGHT_NONE) {} |
| 30 | 30 |
| 31 void End() MOJO_NOT_THREAD_SAFE; | 31 void End() MOJO_NOT_THREAD_SAFE; |
| 32 | 32 |
| 33 Dispatcher::Type GetType() const { return dispatcher_->GetType(); } | 33 Dispatcher::Type GetType() const { return dispatcher_->GetType(); } |
| 34 bool IsBusy() const MOJO_NOT_THREAD_SAFE { | |
| 35 return dispatcher_->IsBusyNoLock(); | |
| 36 } | |
| 37 void Close() MOJO_NOT_THREAD_SAFE { dispatcher_->CloseNoLock(); } | 34 void Close() MOJO_NOT_THREAD_SAFE { dispatcher_->CloseNoLock(); } |
| 38 Handle CreateEquivalentHandleAndClose(MessagePipe* message_pipe, | 35 Handle CreateEquivalentHandleAndClose(MessagePipe* message_pipe, |
| 39 unsigned port) MOJO_NOT_THREAD_SAFE { | 36 unsigned port) MOJO_NOT_THREAD_SAFE { |
| 40 return Handle(dispatcher_->CreateEquivalentDispatcherAndCloseNoLock( | 37 return Handle(dispatcher_->CreateEquivalentDispatcherAndCloseNoLock( |
| 41 message_pipe, port), | 38 message_pipe, port), |
| 42 rights_); | 39 rights_); |
| 43 } | 40 } |
| 44 | 41 |
| 45 bool is_valid() const { return !!dispatcher_; } | 42 bool is_valid() const { return !!dispatcher_; } |
| 46 | 43 |
| 47 private: | 44 private: |
| 48 friend class Dispatcher::HandleTableAccess; | 45 friend class Dispatcher::HandleTableAccess; |
| 49 | 46 |
| 50 explicit HandleTransport(const Handle& handle) | 47 explicit HandleTransport(const Handle& handle) |
| 51 : dispatcher_(handle.dispatcher.get()), rights_(handle.rights) {} | 48 : dispatcher_(handle.dispatcher.get()), rights_(handle.rights) {} |
| 52 | 49 |
| 53 Dispatcher* dispatcher_; | 50 Dispatcher* dispatcher_; |
| 54 MojoHandleRights rights_; | 51 MojoHandleRights rights_; |
| 55 | 52 |
| 56 // Copy and assign allowed. | 53 // Copy and assign allowed. |
| 57 }; | 54 }; |
| 58 | 55 |
| 59 } // namespace system | 56 } // namespace system |
| 60 } // namespace mojo | 57 } // namespace mojo |
| 61 | 58 |
| 62 #endif // MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_ | 59 #endif // MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_ |
| OLD | NEW |