| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Provides a smart pointer class for intrusively reference-counted objects. | 5 // Provides a smart pointer class for intrusively reference-counted objects. |
| 6 | 6 |
| 7 #ifndef MOJO_EDK_SYSTEM_REF_PTR_H_ | 7 #ifndef MOJO_EDK_UTIL_REF_PTR_H_ |
| 8 #define MOJO_EDK_SYSTEM_REF_PTR_H_ | 8 #define MOJO_EDK_UTIL_REF_PTR_H_ |
| 9 | 9 |
| 10 #include <assert.h> | 10 #include <assert.h> |
| 11 | 11 |
| 12 #include <cstddef> | 12 #include <cstddef> |
| 13 #include <utility> | 13 #include <utility> |
| 14 | 14 |
| 15 #include "mojo/edk/system/ref_ptr_internal.h" | 15 #include "mojo/edk/util/ref_ptr_internal.h" |
| 16 #include "mojo/public/cpp/system/macros.h" | 16 #include "mojo/public/cpp/system/macros.h" |
| 17 | 17 |
| 18 namespace mojo { | 18 namespace mojo { |
| 19 namespace system { | 19 namespace util { |
| 20 | 20 |
| 21 // A smart pointer class for intrusively reference-counted objects (e.g., those | 21 // A smart pointer class for intrusively reference-counted objects (e.g., those |
| 22 // subclassing |RefCountedThreadSafe| -- see ref_counted.h). | 22 // subclassing |RefCountedThreadSafe| -- see ref_counted.h). |
| 23 // | 23 // |
| 24 // Such objects require *adoption* to obtain the first |RefPtr|, which is | 24 // Such objects require *adoption* to obtain the first |RefPtr|, which is |
| 25 // accomplished using |AdoptRef| (see below). (This is due to such objects being | 25 // accomplished using |AdoptRef| (see below). (This is due to such objects being |
| 26 // constructed with a reference count of 1. The adoption requirement is | 26 // constructed with a reference count of 1. The adoption requirement is |
| 27 // enforced, at least in Debug builds, by assertions.) | 27 // enforced, at least in Debug builds, by assertions.) |
| 28 // | 28 // |
| 29 // E.g., if |Foo| is an intrusively reference-counted class: | 29 // E.g., if |Foo| is an intrusively reference-counted class: |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // | 220 // |
| 221 // auto my_foo = MakeRefCounted<Foo>(ctor_arg1, ctor_arg2); | 221 // auto my_foo = MakeRefCounted<Foo>(ctor_arg1, ctor_arg2); |
| 222 // | 222 // |
| 223 // (|my_foo| will be of type |RefPtr<Foo>|.) | 223 // (|my_foo| will be of type |RefPtr<Foo>|.) |
| 224 template <typename T, typename... Args> | 224 template <typename T, typename... Args> |
| 225 RefPtr<T> MakeRefCounted(Args&&... args) { | 225 RefPtr<T> MakeRefCounted(Args&&... args) { |
| 226 return internal::MakeRefCountedHelper<T>::MakeRefCounted( | 226 return internal::MakeRefCountedHelper<T>::MakeRefCounted( |
| 227 std::forward<Args>(args)...); | 227 std::forward<Args>(args)...); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace system | 230 } // namespace util |
| 231 } // namespace mojo | 231 } // namespace mojo |
| 232 | 232 |
| 233 #endif // MOJO_EDK_SYSTEM_REF_PTR_H_ | 233 #endif // MOJO_EDK_UTIL_REF_PTR_H_ |
| OLD | NEW |