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

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

Issue 1465293002: Mojo C++ bindings: introduce public associated-interface-related types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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_ASSOCIATED_INTERFACE_PTR_INFO_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_INFO_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_INFO_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_INFO_H_
7 7
8 #include "mojo/public/cpp/system/macros.h" 8 #include "base/macros.h"
9 #include "mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.h"
9 10
10 namespace mojo { 11 namespace mojo {
11 12
13 namespace internal {
14 class AssociatedInterfacePtrInfoHelper;
15 }
16
12 // AssociatedInterfacePtrInfo stores necessary information to construct an 17 // AssociatedInterfacePtrInfo stores necessary information to construct an
13 // associated interface pointer. 18 // associated interface pointer. It is similar to InterfacePtrInfo except that
14 // TODO(yzshen): implement it. 19 // it doesn't own a message pipe handle.
15 template <typename Interface> 20 template <typename Interface>
16 class AssociatedInterfacePtrInfo { 21 class AssociatedInterfacePtrInfo {
17 MOJO_MOVE_ONLY_TYPE(AssociatedInterfacePtrInfo); 22 MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(AssociatedInterfacePtrInfo);
18 23
19 public: 24 public:
20 AssociatedInterfacePtrInfo() {} 25 AssociatedInterfacePtrInfo() : version_(0u) {}
21 AssociatedInterfacePtrInfo(AssociatedInterfacePtrInfo&& other) {} 26
27 AssociatedInterfacePtrInfo(AssociatedInterfacePtrInfo&& other)
28 : handle_(other.handle_.Pass()), version_(other.version_) {
29 other.version_ = 0u;
30 }
31
32 ~AssociatedInterfacePtrInfo() {}
22 33
23 AssociatedInterfacePtrInfo& operator=(AssociatedInterfacePtrInfo&& other) { 34 AssociatedInterfacePtrInfo& operator=(AssociatedInterfacePtrInfo&& other) {
35 if (this != &other) {
36 handle_ = other.handle_.Pass();
37 version_ = other.version_;
38 other.version_ = 0u;
39 }
40
24 return *this; 41 return *this;
25 } 42 }
26 43
27 bool is_valid() const { return false; } 44 bool is_valid() const { return handle_.is_valid(); }
45
46 uint32_t version() const { return version_; }
47 void set_version(uint32_t version) { version_ = version; }
48
49 private:
50 friend class internal::AssociatedInterfacePtrInfoHelper;
51
52 internal::ScopedInterfaceEndpointHandle handle_;
53 uint32_t version_;
28 }; 54 };
29 55
56 namespace internal {
57
58 // With this helper, AssociatedInterfacePtrInfo doesn't have to expose any
59 // operations related to ScopedInterfaceEndpointHandle, which is an internal
60 // class.
61 class AssociatedInterfacePtrInfoHelper {
62 public:
63 template <typename Interface>
64 static ScopedInterfaceEndpointHandle PassHandle(
65 AssociatedInterfacePtrInfo<Interface>* info) {
66 return info->handle_.Pass();
67 }
68
69 template <typename Interface>
70 static const ScopedInterfaceEndpointHandle& GetHandle(
71 AssociatedInterfacePtrInfo<Interface>* info) {
72 return info->handle_;
73 }
74
75 template <typename Interface>
76 static void SetHandle(AssociatedInterfacePtrInfo<Interface>* info,
77 ScopedInterfaceEndpointHandle handle) {
78 info->handle_ = handle.Pass();
79 }
80 };
81
82 } // namespace internal
30 } // namespace mojo 83 } // namespace mojo
31 84
32 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_INFO_H_ 85 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_INFO_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/associated_interface_ptr.h ('k') | mojo/public/cpp/bindings/associated_interface_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698