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

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

Issue 417583002: Mojo: Make mojo::Handle::value() return a reference instead of a value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <assert.h> 8 #include <assert.h>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 void swap(Handle& other) { 167 void swap(Handle& other) {
168 MojoHandle temp = value_; 168 MojoHandle temp = value_;
169 value_ = other.value_; 169 value_ = other.value_;
170 other.value_ = temp; 170 other.value_ = temp;
171 } 171 }
172 172
173 bool is_valid() const { 173 bool is_valid() const {
174 return value_ != kInvalidHandleValue; 174 return value_ != kInvalidHandleValue;
175 } 175 }
176 176
177 MojoHandle value() const { return value_; } 177 const MojoHandle& value() const { return value_; }
178 MojoHandle* mutable_value() { return &value_; } 178 MojoHandle* mutable_value() { return &value_; }
179 void set_value(MojoHandle value) { value_ = value; } 179 void set_value(MojoHandle value) { value_ = value; }
180 180
181 private: 181 private:
182 MojoHandle value_; 182 MojoHandle value_;
183 183
184 // Copying and assignment allowed. 184 // Copying and assignment allowed.
185 }; 185 };
186 186
187 // Should have zero overhead. 187 // Should have zero overhead.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 // Strict weak ordering, so that |Handle|s can be used as keys in |std::map|s, 239 // Strict weak ordering, so that |Handle|s can be used as keys in |std::map|s,
240 // etc. 240 // etc.
241 inline bool operator<(const Handle& a, const Handle& b) { 241 inline bool operator<(const Handle& a, const Handle& b) {
242 return a.value() < b.value(); 242 return a.value() < b.value();
243 } 243 }
244 244
245 } // namespace mojo 245 } // namespace mojo
246 246
247 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ 247 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698