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

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

Issue 2036053002: Mojo: Add a C++-style SharedBuffer API. (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
« no previous file with comments | « mojo/public/cpp/system/buffer.cc ('k') | mojo/public/cpp/system/tests/core_unittest.cc » ('j') | 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 <stdint.h> 8 #include <stdint.h>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 ScopedHandleBase(ScopedHandleBase&& other) : handle_(other.release()) {} 89 ScopedHandleBase(ScopedHandleBase&& other) : handle_(other.release()) {}
90 ScopedHandleBase& operator=(ScopedHandleBase&& other) { 90 ScopedHandleBase& operator=(ScopedHandleBase&& other) {
91 if (&other != this) { 91 if (&other != this) {
92 CloseIfNecessary(); 92 CloseIfNecessary();
93 handle_ = other.release(); 93 handle_ = other.release();
94 } 94 }
95 return *this; 95 return *this;
96 } 96 }
97 97
98 const HandleType& get() const { return handle_; } 98 const HandleType& get() const { return handle_; }
99 const HandleType* operator->() const { return &handle_; }
99 100
100 template <typename PassedHandleType> 101 template <typename PassedHandleType>
101 static ScopedHandleBase<HandleType> From( 102 static ScopedHandleBase<HandleType> From(
102 ScopedHandleBase<PassedHandleType> other) { 103 ScopedHandleBase<PassedHandleType> other) {
103 static_assert( 104 static_assert(
104 sizeof(static_cast<PassedHandleType*>(static_cast<HandleType*>(0))), 105 sizeof(static_cast<PassedHandleType*>(static_cast<HandleType*>(0))),
105 "HandleType is not a subtype of PassedHandleType"); 106 "HandleType is not a subtype of PassedHandleType");
106 return ScopedHandleBase<HandleType>( 107 return ScopedHandleBase<HandleType>(
107 static_cast<HandleType>(other.release().value())); 108 static_cast<HandleType>(other.release().value()));
108 } 109 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 296 }
296 297
297 // Comparison, so that |Handle|s can be used as keys in hash maps. 298 // Comparison, so that |Handle|s can be used as keys in hash maps.
298 inline bool operator==(const Handle a, const Handle b) { 299 inline bool operator==(const Handle a, const Handle b) {
299 return a.value() == b.value(); 300 return a.value() == b.value();
300 } 301 }
301 302
302 } // namespace mojo 303 } // namespace mojo
303 304
304 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ 305 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/system/buffer.cc ('k') | mojo/public/cpp/system/tests/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698