| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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_ |
| OLD | NEW |