Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CORE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_SYSTEM_CORE_H_ |
| 6 #define MOJO_PUBLIC_CPP_SYSTEM_CORE_H_ | 6 #define MOJO_PUBLIC_CPP_SYSTEM_CORE_H_ |
| 7 | 7 |
| 8 #include <assert.h> | 8 #include <assert.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 ~ScopedHandleBase() { CloseIfNecessary(); } | 100 ~ScopedHandleBase() { CloseIfNecessary(); } |
| 101 | 101 |
| 102 template <class CompatibleHandleType> | 102 template <class CompatibleHandleType> |
| 103 explicit ScopedHandleBase(ScopedHandleBase<CompatibleHandleType> other) | 103 explicit ScopedHandleBase(ScopedHandleBase<CompatibleHandleType> other) |
| 104 : handle_(other.release()) { | 104 : handle_(other.release()) { |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Move-only constructor and operator=. | 107 // Move-only constructor and operator=. |
| 108 ScopedHandleBase(RValue other) : handle_(other.object->release()) {} | 108 ScopedHandleBase(RValue other) : handle_(other.object->release()) {} |
| 109 ScopedHandleBase& operator=(RValue other) { | 109 ScopedHandleBase& operator=(RValue other) { |
| 110 if (handle_.is_valid() && handle_.value() != other.object->get().value()) | |
|
viettrungluu
2014/06/17 22:58:25
Since a handle should only be in a single ScopedHa
Elliot Glaysher
2014/06/17 23:08:28
Switched to if (other.object != this). Didn't add
| |
| 111 CloseIfNecessary(); | |
| 110 handle_ = other.object->release(); | 112 handle_ = other.object->release(); |
| 111 return *this; | 113 return *this; |
| 112 } | 114 } |
| 113 | 115 |
| 114 const HandleType& get() const { return handle_; } | 116 const HandleType& get() const { return handle_; } |
| 115 | 117 |
| 116 template <typename PassedHandleType> | 118 template <typename PassedHandleType> |
| 117 static ScopedHandleBase<HandleType> From( | 119 static ScopedHandleBase<HandleType> From( |
| 118 ScopedHandleBase<PassedHandleType> other) { | 120 ScopedHandleBase<PassedHandleType> other) { |
| 119 MOJO_COMPILE_ASSERT( | 121 MOJO_COMPILE_ASSERT( |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 CreateSharedBuffer(&options, num_bytes, &handle); | 544 CreateSharedBuffer(&options, num_bytes, &handle); |
| 543 assert(result == MOJO_RESULT_OK); | 545 assert(result == MOJO_RESULT_OK); |
| 544 } | 546 } |
| 545 | 547 |
| 546 inline SharedBuffer::~SharedBuffer() { | 548 inline SharedBuffer::~SharedBuffer() { |
| 547 } | 549 } |
| 548 | 550 |
| 549 } // namespace mojo | 551 } // namespace mojo |
| 550 | 552 |
| 551 #endif // MOJO_PUBLIC_CPP_SYSTEM_CORE_H_ | 553 #endif // MOJO_PUBLIC_CPP_SYSTEM_CORE_H_ |
| OLD | NEW |