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

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

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