OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 // wrap a reference counted WebCore class. | 44 // wrap a reference counted WebCore class. |
45 template <typename T> | 45 template <typename T> |
46 class WebPrivatePtr { | 46 class WebPrivatePtr { |
47 public: | 47 public: |
48 WebPrivatePtr() : m_ptr(0) { } | 48 WebPrivatePtr() : m_ptr(0) { } |
49 ~WebPrivatePtr() { WEBKIT_ASSERT(!m_ptr); } | 49 ~WebPrivatePtr() { WEBKIT_ASSERT(!m_ptr); } |
50 | 50 |
51 bool isNull() const { return !m_ptr; } | 51 bool isNull() const { return !m_ptr; } |
52 | 52 |
53 #if WEBKIT_IMPLEMENTATION | 53 #if WEBKIT_IMPLEMENTATION |
54 WebPrivatePtr(const WebPrivatePtr& other) | |
55 : m_ptr(other.m_ptr) | |
56 { | |
57 if (m_ptr) | |
58 m_ptr->ref(); | |
59 } | |
abarth-chromium
2013/05/22 17:16:11
We shouldn't need to modify this class.
dmichael (off chromium)
2013/05/22 17:37:33
See the updated CL description. WebPrivatePtr did
abarth-chromium
2013/05/22 18:06:23
Good point. Let's try disabling the copy construc
dmichael (off chromium)
2013/05/22 18:44:26
Done. I kind of liked fixing it better; I wasn't s
| |
60 | |
54 WebPrivatePtr(const PassRefPtr<T>& prp) | 61 WebPrivatePtr(const PassRefPtr<T>& prp) |
55 : m_ptr(prp.leakRef()) | 62 : m_ptr(prp.leakRef()) |
56 { | 63 { |
57 } | 64 } |
58 | 65 |
59 void reset() | 66 void reset() |
60 { | 67 { |
61 assign(0); | 68 assign(0); |
62 } | 69 } |
63 | 70 |
(...skipping 26 matching lines...) Expand all Loading... | |
90 | 97 |
91 private: | 98 private: |
92 #if WEBKIT_IMPLEMENTATION | 99 #if WEBKIT_IMPLEMENTATION |
93 void assign(T* p) | 100 void assign(T* p) |
94 { | 101 { |
95 // p is already ref'd for us by the caller | 102 // p is already ref'd for us by the caller |
96 if (m_ptr) | 103 if (m_ptr) |
97 m_ptr->deref(); | 104 m_ptr->deref(); |
98 m_ptr = p; | 105 m_ptr = p; |
99 } | 106 } |
107 #else | |
108 // Disable copy and assign; we define them above for the implementation, but | |
109 // we need to make sure that they aren't used outside there; the compiler- | |
110 // provided versions won't handle reference counting properly. | |
111 WebPrivatePtr(const WebPrivatePtr<T>&); | |
112 WebPrivatePtr<T>& operator=(const WebPrivatePtr<T>& other); | |
100 #endif | 113 #endif |
101 | 114 |
102 T* m_ptr; | 115 T* m_ptr; |
103 }; | 116 }; |
104 | 117 |
105 } // namespace WebKit | 118 } // namespace WebKit |
106 | 119 |
107 #endif | 120 #endif |
OLD | NEW |