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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 return; | 107 return; |
108 } | 108 } |
109 | 109 |
110 if (!m_handle) | 110 if (!m_handle) |
111 m_handle = new WebCore::Persistent<T>(); | 111 m_handle = new WebCore::Persistent<T>(); |
112 | 112 |
113 (*m_handle) = val; | 113 (*m_handle) = val; |
114 } | 114 } |
115 | 115 |
116 void assign(T* ptr) { assign(RawPtr<T>(ptr)); } | 116 void assign(T* ptr) { assign(RawPtr<T>(ptr)); } |
| 117 template<typename U> void assign(const RawPtr<U>& val) { assign(RawPtr<T>(va
l)); } |
117 | 118 |
118 void assign(const PtrStorageImpl& other) { assign(other.get()); } | 119 void assign(const PtrStorageImpl& other) { assign(other.get()); } |
119 | 120 |
120 T* get() const { return m_handle ? m_handle->get() : 0; } | 121 T* get() const { return m_handle ? m_handle->get() : 0; } |
121 | 122 |
122 void release() | 123 void release() |
123 { | 124 { |
124 delete m_handle; | 125 delete m_handle; |
125 m_handle = 0; | 126 m_handle = 0; |
126 } | 127 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 // Disable the copy constructor; classes that contain a WebPrivatePtr | 266 // Disable the copy constructor; classes that contain a WebPrivatePtr |
266 // should implement their copy constructor using assign(). | 267 // should implement their copy constructor using assign(). |
267 WebPrivatePtr(const WebPrivatePtr<T>&); | 268 WebPrivatePtr(const WebPrivatePtr<T>&); |
268 | 269 |
269 void* m_storage; | 270 void* m_storage; |
270 }; | 271 }; |
271 | 272 |
272 } // namespace blink | 273 } // namespace blink |
273 | 274 |
274 #endif | 275 #endif |
OLD | NEW |