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

Side by Side Diff: third_party/WebKit/public/platform/WebPrivateOwnPtr.h

Issue 1917193006: WTF: Make PassOwnPtr<T> move-only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/public/platform/WebBlobData.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 * Copyright (C) 2013 Intel Corporation. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 ~WebPrivateOwnPtr() { DCHECK(!m_ptr); } 52 ~WebPrivateOwnPtr() { DCHECK(!m_ptr); }
53 53
54 explicit WebPrivateOwnPtr(T* ptr) 54 explicit WebPrivateOwnPtr(T* ptr)
55 : m_ptr(ptr) 55 : m_ptr(ptr)
56 { 56 {
57 } 57 }
58 58
59 T* get() const { return m_ptr; } 59 T* get() const { return m_ptr; }
60 60
61 #if INSIDE_BLINK 61 #if INSIDE_BLINK
62 template<typename U> WebPrivateOwnPtr(const PassOwnPtr<U>&, EnsurePtrConvert ibleArgDecl(U, T)); 62 template <typename U>
63 WebPrivateOwnPtr(PassOwnPtr<U>, EnsurePtrConvertibleArgDecl(U, T));
63 64
64 void reset(T* ptr) 65 void reset(T* ptr)
65 { 66 {
66 delete m_ptr; 67 delete m_ptr;
67 m_ptr = ptr; 68 m_ptr = ptr;
68 } 69 }
69 70
70 void reset(const PassOwnPtr<T>& o) 71 void reset(PassOwnPtr<T> o)
71 { 72 {
72 reset(o.leakPtr()); 73 reset(o.leakPtr());
73 } 74 }
74 75
75 PassOwnPtr<T> release() 76 PassOwnPtr<T> release()
76 { 77 {
77 T* ptr = m_ptr; 78 T* ptr = m_ptr;
78 m_ptr = nullptr; 79 m_ptr = nullptr;
79 return adoptPtr(ptr); 80 return adoptPtr(ptr);
80 } 81 }
81 82
82 T& operator*() const 83 T& operator*() const
83 { 84 {
84 DCHECK(m_ptr); 85 DCHECK(m_ptr);
85 return *m_ptr; 86 return *m_ptr;
86 } 87 }
87 88
88 T* operator->() const 89 T* operator->() const
89 { 90 {
90 DCHECK(m_ptr); 91 DCHECK(m_ptr);
91 return m_ptr; 92 return m_ptr;
92 } 93 }
93 #endif // INSIDE_BLINK 94 #endif // INSIDE_BLINK
94 95
95 private: 96 private:
96 T* m_ptr; 97 T* m_ptr;
97 }; 98 };
98 99
99 #if INSIDE_BLINK 100 #if INSIDE_BLINK
100 template<typename T> template<typename U> inline WebPrivateOwnPtr<T>::WebPrivate OwnPtr(const PassOwnPtr<U>& o, EnsurePtrConvertibleArgDefn(U, T)) 101 template <typename T>
102 template <typename U>
103 inline WebPrivateOwnPtr<T>::WebPrivateOwnPtr(PassOwnPtr<U> o, EnsurePtrConvertib leArgDefn(U, T))
101 : m_ptr(o.leakPtr()) 104 : m_ptr(o.leakPtr())
102 { 105 {
103 static_assert(!std::is_array<T>::value, "Pointers to array must never be con verted"); 106 static_assert(!std::is_array<T>::value, "Pointers to array must never be con verted");
104 } 107 }
105 #endif 108 #endif
106 109
107 } // namespace blink 110 } // namespace blink
108 111
109 #endif 112 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/public/platform/WebBlobData.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698