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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 |
| 43 // Move-only constructor and operator=. | 43 // Move-only constructor and operator=. |
| 44 ScopedHandleBase(RValue other) : handle_(other.object->release()) {} | 44 ScopedHandleBase(RValue other) : handle_(other.object->release()) {} |
| 45 ScopedHandleBase& operator=(RValue other) { | 45 ScopedHandleBase& operator=(RValue other) { |
| 46 handle_ = other.object->release(); | 46 handle_ = other.object->release(); |
| 47 return *this; | 47 return *this; |
| 48 } | 48 } |
| 49 | 49 |
| 50 const HandleType& get() const { return handle_; } | 50 const HandleType& get() const { return handle_; } |
| 51 | 51 |
| 52 template <typename Passed> | |
|
viettrungluu
2014/04/03 20:42:48
Nit: Could you call this PassedHandleType?
| |
| 53 static ScopedHandleBase<HandleType> From(ScopedHandleBase<Passed> other) { | |
| 54 return ScopedHandleBase<HandleType>( | |
|
viettrungluu
2014/04/03 20:42:48
Please add a comment:
// The |static_cast| here is
| |
| 55 static_cast<HandleType>(other.release().value())); | |
|
viettrungluu
2014/04/03 20:42:48
It should be static_cast<HandleType>(other.release
| |
| 56 } | |
| 57 | |
| 52 void swap(ScopedHandleBase& other) { | 58 void swap(ScopedHandleBase& other) { |
| 53 handle_.swap(other.handle_); | 59 handle_.swap(other.handle_); |
| 54 } | 60 } |
| 55 | 61 |
| 56 HandleType release() MOJO_WARN_UNUSED_RESULT { | 62 HandleType release() MOJO_WARN_UNUSED_RESULT { |
| 57 HandleType rv; | 63 HandleType rv; |
| 58 rv.swap(handle_); | 64 rv.swap(handle_); |
| 59 return rv; | 65 return rv; |
| 60 } | 66 } |
| 61 | 67 |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 CreateSharedBuffer(&options, num_bytes, &handle); | 464 CreateSharedBuffer(&options, num_bytes, &handle); |
| 459 assert(result == MOJO_RESULT_OK); | 465 assert(result == MOJO_RESULT_OK); |
| 460 } | 466 } |
| 461 | 467 |
| 462 inline SharedBuffer::~SharedBuffer() { | 468 inline SharedBuffer::~SharedBuffer() { |
| 463 } | 469 } |
| 464 | 470 |
| 465 } // namespace mojo | 471 } // namespace mojo |
| 466 | 472 |
| 467 #endif // MOJO_PUBLIC_CPP_SYSTEM_CORE_H_ | 473 #endif // MOJO_PUBLIC_CPP_SYSTEM_CORE_H_ |
| OLD | NEW |