Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_PUBLIC_CPP_BINDINGS_LIB_SCOPED_INTERFACE_ENDPOINT_HANDLE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_SCOPED_INTERFACE_ENDPOINT_HANDLE_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SCOPED_INTERFACE_ENDPOINT_HANDLE_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_SCOPED_INTERFACE_ENDPOINT_HANDLE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/move.h" | 10 #include "base/move.h" |
| 11 #include "mojo/public/cpp/bindings/lib/interface_id.h" | 11 #include "mojo/public/cpp/bindings/lib/interface_id.h" |
| 12 | 12 |
| 13 namespace mojo { | 13 namespace mojo { |
| 14 | |
| 14 namespace internal { | 15 namespace internal { |
| 15 | |
| 16 class MultiplexRouter; | 16 class MultiplexRouter; |
| 17 } | |
| 17 | 18 |
| 18 // ScopedInterfaceEndpointHandle refers to one end of an interface, either the | 19 // ScopedInterfaceEndpointHandle refers to one end of an interface, either the |
| 19 // implementation side or the client side. | 20 // implementation side or the client side. |
| 20 class ScopedInterfaceEndpointHandle { | 21 class ScopedInterfaceEndpointHandle { |
| 21 DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(ScopedInterfaceEndpointHandle); | 22 DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(ScopedInterfaceEndpointHandle); |
| 22 | 23 |
| 23 public: | 24 public: |
| 24 // Creates an invalid endpoint handle. | 25 // Creates an invalid endpoint handle. |
| 25 ScopedInterfaceEndpointHandle(); | 26 ScopedInterfaceEndpointHandle(); |
| 26 | 27 |
| 27 // This is supposed to be used by MultiplexRouter only. | 28 // This is supposed to be used by MultiplexRouter only. |
| 28 // |id| is the corresponding interface ID. | 29 // |id| is the corresponding interface ID. |
| 29 // If |is_local| is false, this handle is meant to be passed over |router| to | 30 // If |is_local| is false, this handle is meant to be passed over |router| to |
| 30 // the remote side. | 31 // the remote side. |
| 31 ScopedInterfaceEndpointHandle(InterfaceId id, | 32 ScopedInterfaceEndpointHandle( |
|
yzshen1
2016/05/17 21:50:48
Does it make sense to make this private and Multip
Ken Rockot(use gerrit already)
2016/05/17 22:35:04
Done
| |
| 32 bool is_local, | 33 internal::InterfaceId id, |
| 33 scoped_refptr<MultiplexRouter> router); | 34 bool is_local, |
| 35 scoped_refptr<internal::MultiplexRouter> router); | |
| 34 | 36 |
| 35 ScopedInterfaceEndpointHandle(ScopedInterfaceEndpointHandle&& other); | 37 ScopedInterfaceEndpointHandle(ScopedInterfaceEndpointHandle&& other); |
| 36 | 38 |
| 37 ~ScopedInterfaceEndpointHandle(); | 39 ~ScopedInterfaceEndpointHandle(); |
| 38 | 40 |
| 39 ScopedInterfaceEndpointHandle& operator=( | 41 ScopedInterfaceEndpointHandle& operator=( |
| 40 ScopedInterfaceEndpointHandle&& other); | 42 ScopedInterfaceEndpointHandle&& other); |
| 41 | 43 |
| 42 bool is_valid() const { return IsValidInterfaceId(id_); } | 44 bool is_valid() const { return internal::IsValidInterfaceId(id_); } |
| 43 | 45 |
| 44 InterfaceId id() const { return id_; } | |
| 45 bool is_local() const { return is_local_; } | 46 bool is_local() const { return is_local_; } |
| 46 MultiplexRouter* router() const { return router_.get(); } | |
| 47 | 47 |
| 48 void reset(); | 48 void reset(); |
| 49 void swap(ScopedInterfaceEndpointHandle& other); | 49 void swap(ScopedInterfaceEndpointHandle& other); |
| 50 | 50 |
| 51 // DO NOT USE METHODS BELOW THIS LINE. These are for internal use and testing. | |
| 52 | |
| 53 internal::InterfaceId id() const { return id_; } | |
| 54 | |
| 55 internal::MultiplexRouter* router() const { return router_.get(); } | |
| 56 | |
| 51 // Releases the handle without closing it. | 57 // Releases the handle without closing it. |
| 52 InterfaceId release(); | 58 internal::InterfaceId release(); |
| 53 | 59 |
| 54 private: | 60 private: |
| 55 InterfaceId id_; | 61 internal::InterfaceId id_; |
| 56 bool is_local_; | 62 bool is_local_; |
| 57 scoped_refptr<MultiplexRouter> router_; | 63 scoped_refptr<internal::MultiplexRouter> router_; |
| 58 }; | 64 }; |
| 59 | 65 |
| 60 } // namespace internal | |
| 61 } // namespace mojo | 66 } // namespace mojo |
| 62 | 67 |
| 63 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SCOPED_INTERFACE_ENDPOINT_HANDLE_H_ | 68 #endif // MOJO_PUBLIC_CPP_BINDINGS_SCOPED_INTERFACE_ENDPOINT_HANDLE_H_ |
| OLD | NEW |