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

Side by Side Diff: mojo/public/cpp/bindings/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: Remove self-move checks to avoid triggering clang warning. 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_INTERFACE_PTR_INFO_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_INFO_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_INFO_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_INFO_H_
7 7
8 #include <utility>
9
8 #include "mojo/public/cpp/system/macros.h" 10 #include "mojo/public/cpp/system/macros.h"
9 #include "mojo/public/cpp/system/message_pipe.h" 11 #include "mojo/public/cpp/system/message_pipe.h"
10 12
11 namespace mojo { 13 namespace mojo {
12 14
13 // InterfacePtrInfo stores necessary information to communicate with a remote 15 // InterfacePtrInfo stores necessary information to communicate with a remote
14 // interface implementation, which could be used to construct an InterfacePtr. 16 // interface implementation, which could be used to construct an InterfacePtr.
15 template <typename Interface> 17 template <typename Interface>
16 class InterfacePtrInfo { 18 class InterfacePtrInfo {
17 MOJO_MOVE_ONLY_TYPE(InterfacePtrInfo); 19 MOJO_MOVE_ONLY_TYPE(InterfacePtrInfo);
18 20
19 public: 21 public:
20 InterfacePtrInfo() : version_(0u) {} 22 InterfacePtrInfo() : version_(0u) {}
21 23
22 InterfacePtrInfo(ScopedMessagePipeHandle handle, uint32_t version) 24 InterfacePtrInfo(ScopedMessagePipeHandle handle, uint32_t version)
23 : handle_(handle.Pass()), version_(version) {} 25 : handle_(std::move(handle)), version_(version) {}
24 26
25 InterfacePtrInfo(InterfacePtrInfo&& other) 27 InterfacePtrInfo(InterfacePtrInfo&& other)
26 : handle_(other.handle_.Pass()), version_(other.version_) { 28 : handle_(std::move(other.handle_)), version_(other.version_) {
27 other.version_ = 0u; 29 other.version_ = 0u;
28 } 30 }
29 31
30 ~InterfacePtrInfo() {} 32 ~InterfacePtrInfo() {}
31 33
32 InterfacePtrInfo& operator=(InterfacePtrInfo&& other) { 34 InterfacePtrInfo& operator=(InterfacePtrInfo&& other) {
33 if (this != &other) { 35 if (this != &other) {
34 handle_ = other.handle_.Pass(); 36 handle_ = other.handle_.Pass();
35 version_ = other.version_; 37 version_ = other.version_;
36 other.version_ = 0u; 38 other.version_ = 0u;
37 } 39 }
38 40
39 return *this; 41 return *this;
40 } 42 }
41 43
42 bool is_valid() const { return handle_.is_valid(); } 44 bool is_valid() const { return handle_.is_valid(); }
43 45
44 ScopedMessagePipeHandle PassHandle() { return handle_.Pass(); } 46 ScopedMessagePipeHandle PassHandle() { return std::move(handle_); }
45 const ScopedMessagePipeHandle& handle() const { return handle_; } 47 const ScopedMessagePipeHandle& handle() const { return handle_; }
46 void set_handle(ScopedMessagePipeHandle handle) { handle_ = handle.Pass(); } 48 void set_handle(ScopedMessagePipeHandle handle) {
49 handle_ = std::move(handle);
50 }
47 51
48 uint32_t version() const { return version_; } 52 uint32_t version() const { return version_; }
49 void set_version(uint32_t version) { version_ = version; } 53 void set_version(uint32_t version) { version_ = version; }
50 54
51 private: 55 private:
52 ScopedMessagePipeHandle handle_; 56 ScopedMessagePipeHandle handle_;
53 uint32_t version_; 57 uint32_t version_;
54 }; 58 };
55 59
56 } // namespace mojo 60 } // namespace mojo
57 61
58 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_INFO_H_ 62 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698