Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h

Issue 1991463002: Mojo: Expose untyped associated endpoints through public API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // |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); 28 ScopedInterfaceEndpointHandle(ScopedInterfaceEndpointHandle&& other);
36 29
37 ~ScopedInterfaceEndpointHandle(); 30 ~ScopedInterfaceEndpointHandle();
38 31
39 ScopedInterfaceEndpointHandle& operator=( 32 ScopedInterfaceEndpointHandle& operator=(
40 ScopedInterfaceEndpointHandle&& other); 33 ScopedInterfaceEndpointHandle&& other);
41 34
42 bool is_valid() const { return IsValidInterfaceId(id_); } 35 bool is_valid() const { return internal::IsValidInterfaceId(id_); }
43 36
44 InterfaceId id() const { return id_; }
45 bool is_local() const { return is_local_; } 37 bool is_local() const { return is_local_; }
46 MultiplexRouter* router() const { return router_.get(); }
47 38
48 void reset(); 39 void reset();
49 void swap(ScopedInterfaceEndpointHandle& other); 40 void swap(ScopedInterfaceEndpointHandle& other);
50 41
42 // DO NOT USE METHODS BELOW THIS LINE. These are for internal use and testing.
43
44 internal::InterfaceId id() const { return id_; }
45
46 internal::MultiplexRouter* router() const { return router_.get(); }
47
51 // Releases the handle without closing it. 48 // Releases the handle without closing it.
52 InterfaceId release(); 49 internal::InterfaceId release();
53 50
54 private: 51 private:
55 InterfaceId id_; 52 friend class internal::MultiplexRouter;
53
54 // This is supposed to be used by MultiplexRouter only.
55 // |id| is the corresponding interface ID.
56 // If |is_local| is false, this handle is meant to be passed over |router| to
57 // the remote side.
58 ScopedInterfaceEndpointHandle(
59 internal::InterfaceId id,
60 bool is_local,
61 scoped_refptr<internal::MultiplexRouter> router);
62
63 internal::InterfaceId id_;
56 bool is_local_; 64 bool is_local_;
57 scoped_refptr<MultiplexRouter> router_; 65 scoped_refptr<internal::MultiplexRouter> router_;
58 }; 66 };
59 67
60 } // namespace internal
61 } // namespace mojo 68 } // namespace mojo
62 69
63 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SCOPED_INTERFACE_ENDPOINT_HANDLE_H_ 70 #endif // MOJO_PUBLIC_CPP_BINDINGS_SCOPED_INTERFACE_ENDPOINT_HANDLE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/serialization_util.h ('k') | mojo/public/cpp/bindings/tests/associated_interface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698