Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(827)

Side by Side Diff: base/memory/ptr_util.h

Issue 2164503002: Do not delete blink::WebRTCCertificateCallback on non-main thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +std::move, -auto, s/std::move/&/ Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 BASE_MEMORY_PTR_UTIL_H_ 5 #ifndef BASE_MEMORY_PTR_UTIL_H_
6 #define BASE_MEMORY_PTR_UTIL_H_ 6 #define BASE_MEMORY_PTR_UTIL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
11 namespace base { 11 namespace base {
12 12
13 // Helper to transfer ownership of a raw pointer to a std::unique_ptr<T>. 13 // Helper to transfer ownership of a raw pointer to a std::unique_ptr<T>.
14 // Note that std::unique_ptr<T> has very different semantics from 14 // Note that std::unique_ptr<T> has very different semantics from
15 // std::unique_ptr<T[]>: do not use this helper for array allocations. 15 // std::unique_ptr<T[]>: do not use this helper for array allocations.
16 template <typename T> 16 template <typename T, typename D = std::default_delete<T>>
17 std::unique_ptr<T> WrapUnique(T* ptr) { 17 std::unique_ptr<T, D> WrapUnique(T* ptr, D deleter = D()) {
dcheng 2016/07/22 07:29:00 We don't need the custom deleter argument anymore,
tzik 2016/07/22 08:14:53 Ah, right. Removed.
18 return std::unique_ptr<T>(ptr); 18 return std::unique_ptr<T, D>(ptr, std::move(deleter));
19 } 19 }
20 20
21 namespace internal { 21 namespace internal {
22 22
23 template <typename T> 23 template <typename T>
24 struct MakeUniqueResult { 24 struct MakeUniqueResult {
25 using Scalar = std::unique_ptr<T>; 25 using Scalar = std::unique_ptr<T>;
26 }; 26 };
27 27
28 template <typename T> 28 template <typename T>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 // Overload to reject array types of known bound, e.g. T[n]. 67 // Overload to reject array types of known bound, e.g. T[n].
68 template <typename T, typename... Args> 68 template <typename T, typename... Args>
69 typename internal::MakeUniqueResult<T>::Invalid MakeUnique(Args&&... args) = 69 typename internal::MakeUniqueResult<T>::Invalid MakeUnique(Args&&... args) =
70 delete; 70 delete;
71 71
72 } // namespace base 72 } // namespace base
73 73
74 #endif // BASE_MEMORY_PTR_UTIL_H_ 74 #endif // BASE_MEMORY_PTR_UTIL_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/memory/ptr_util_unittest.cc » ('j') | base/sequenced_task_runner.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698