| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_SCOPED_INTERFACE_ENDPOINT_HANDLE_H_ | |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SCOPED_INTERFACE_ENDPOINT_HANDLE_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/move.h" | |
| 11 #include "mojo/public/cpp/bindings/lib/interface_id.h" | |
| 12 | |
| 13 namespace mojo { | |
| 14 namespace internal { | |
| 15 | |
| 16 class MultiplexRouter; | |
| 17 | |
| 18 // ScopedInterfaceEndpointHandle refers to one end of an interface, either the | |
| 19 // implementation side or the client side. | |
| 20 class ScopedInterfaceEndpointHandle { | |
| 21 DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(ScopedInterfaceEndpointHandle); | |
| 22 | |
| 23 public: | |
| 24 // Creates an invalid endpoint handle. | |
| 25 ScopedInterfaceEndpointHandle(); | |
| 26 | |
| 27 // This is supposed to be used by MultiplexRouter only. | |
| 28 // |id| is the corresponding interface ID. | |
| 29 // If |is_local| is false, this handle is meant to be passed over |router| to | |
| 30 // the remote side. | |
| 31 ScopedInterfaceEndpointHandle(InterfaceId id, | |
| 32 bool is_local, | |
| 33 scoped_refptr<MultiplexRouter> router); | |
| 34 | |
| 35 ScopedInterfaceEndpointHandle(ScopedInterfaceEndpointHandle&& other); | |
| 36 | |
| 37 ~ScopedInterfaceEndpointHandle(); | |
| 38 | |
| 39 ScopedInterfaceEndpointHandle& operator=( | |
| 40 ScopedInterfaceEndpointHandle&& other); | |
| 41 | |
| 42 bool is_valid() const { return IsValidInterfaceId(id_); } | |
| 43 | |
| 44 InterfaceId id() const { return id_; } | |
| 45 bool is_local() const { return is_local_; } | |
| 46 MultiplexRouter* router() const { return router_.get(); } | |
| 47 | |
| 48 void reset(); | |
| 49 void swap(ScopedInterfaceEndpointHandle& other); | |
| 50 | |
| 51 // Releases the handle without closing it. | |
| 52 InterfaceId release(); | |
| 53 | |
| 54 private: | |
| 55 InterfaceId id_; | |
| 56 bool is_local_; | |
| 57 scoped_refptr<MultiplexRouter> router_; | |
| 58 }; | |
| 59 | |
| 60 } // namespace internal | |
| 61 } // namespace mojo | |
| 62 | |
| 63 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SCOPED_INTERFACE_ENDPOINT_HANDLE_H_ | |
| OLD | NEW |