| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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  Loading... | 
| 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_ | 
| OLD | NEW | 
|---|