| 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 #ifndef MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_ | 5 #ifndef MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_ | 
| 6 #define MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_ | 6 #define MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_ | 
| 7 | 7 | 
| 8 #include <utility> | 8 #include <utility> | 
| 9 | 9 | 
| 10 #include "mojo/public/cpp/system/macros.h" | 10 #include "mojo/public/cpp/system/macros.h" | 
| 11 | 11 | 
| 12 namespace mojo { | 12 namespace mojo { | 
| 13 namespace util { | 13 namespace util { | 
| 14 | 14 | 
| 15 template <typename T> | 15 template <typename T> | 
| 16 class RefPtr; | 16 class RefPtr; | 
| 17 | 17 | 
| 18 template <typename T> | 18 template <typename T> | 
| 19 RefPtr<T> AdoptRef(T* ptr); | 19 RefPtr<T> AdoptRef(T* ptr); | 
| 20 | 20 | 
| 21 namespace internal { | 21 namespace internal { | 
| 22 | 22 | 
| 23 // This is a wrapper class that can be friended for a particular |T|, if you | 23 // This is a wrapper class that can be friended for a particular |T|, if you | 
| 24 // want to make |T|'s constructor private, but still use |MakeRefCounted()| | 24 // want to make |T|'s constructor private, but still use |MakeRefCounted()| | 
| 25 // (below). (You can't friend partial specializations.) See |MakeRefCounted()| | 25 // (below). (You can't friend partial specializations.) See |MakeRefCounted()| | 
| 26 // and |FRIEND_MAKE_REF_COUNTED()|. | 26 // and |FRIEND_MAKE_REF_COUNTED()|. | 
| 27 template <typename T> | 27 template <typename T> | 
| 28 class MakeRefCountedHelper { | 28 class MakeRefCountedHelper final { | 
| 29  public: | 29  public: | 
| 30   template <typename... Args> | 30   template <typename... Args> | 
| 31   static RefPtr<T> MakeRefCounted(Args&&... args) { | 31   static RefPtr<T> MakeRefCounted(Args&&... args) { | 
| 32     return AdoptRef<T>(new T(std::forward<Args>(args)...)); | 32     return AdoptRef<T>(new T(std::forward<Args>(args)...)); | 
| 33   } | 33   } | 
| 34 }; | 34 }; | 
| 35 | 35 | 
| 36 }  // namespace internal | 36 }  // namespace internal | 
| 37 }  // namespace util | 37 }  // namespace util | 
| 38 }  // namespace mojo | 38 }  // namespace mojo | 
| 39 | 39 | 
| 40 #endif  // MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_ | 40 #endif  // MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_ | 
| OLD | NEW | 
|---|