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

Side by Side Diff: mojo/public/cpp/system/handle.h

Issue 2031823002: Mojo C++ bindings: more consistent Clone() and Equals(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SYSTEM_HANDLE_H_ 5 #ifndef MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_
6 #define MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ 6 #define MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return rv; 115 return rv;
116 } 116 }
117 117
118 void reset(HandleType handle = HandleType()) { 118 void reset(HandleType handle = HandleType()) {
119 CloseIfNecessary(); 119 CloseIfNecessary();
120 handle_ = handle; 120 handle_ = handle;
121 } 121 }
122 122
123 bool is_valid() const { return handle_.is_valid(); } 123 bool is_valid() const { return handle_.is_valid(); }
124 124
125 bool operator==(const ScopedHandleBase& other) const {
126 return handle_.value() == other.get().value();
127 }
128
125 private: 129 private:
126 void CloseIfNecessary() { 130 void CloseIfNecessary() {
127 if (handle_.is_valid()) 131 if (handle_.is_valid())
128 handle_.Close(); 132 handle_.Close();
129 } 133 }
130 134
131 HandleType handle_; 135 HandleType handle_;
132 }; 136 };
133 137
134 template <typename HandleType> 138 template <typename HandleType>
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 299 }
296 300
297 // Comparison, so that |Handle|s can be used as keys in hash maps. 301 // Comparison, so that |Handle|s can be used as keys in hash maps.
298 inline bool operator==(const Handle a, const Handle b) { 302 inline bool operator==(const Handle a, const Handle b) {
299 return a.value() == b.value(); 303 return a.value() == b.value();
300 } 304 }
301 305
302 } // namespace mojo 306 } // namespace mojo
303 307
304 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ 308 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/wtf_array.h ('k') | mojo/public/interfaces/bindings/tests/struct_with_traits.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698