summaryrefslogtreecommitdiffstats
path: root/Source/JavaScriptCore/wtf/ListRefPtr.h
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-13 06:44:40 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-05-13 06:44:40 -0700
commit08014c20784f3db5df3a89b73cce46037b77eb59 (patch)
tree47749210d31e19e6e2f64036fa8fae2ad693476f /Source/JavaScriptCore/wtf/ListRefPtr.h
parent860220379e56aeb66424861ad602b07ee22b4055 (diff)
parent4c3661f7918f8b3f139f824efb7855bedccb4c94 (diff)
downloadexternal_webkit-08014c20784f3db5df3a89b73cce46037b77eb59.zip
external_webkit-08014c20784f3db5df3a89b73cce46037b77eb59.tar.gz
external_webkit-08014c20784f3db5df3a89b73cce46037b77eb59.tar.bz2
Merge changes Ide388898,Ic49f367c,I1158a808,Iacb6ca5d,I2100dd3a,I5c1abe54,Ib0ef9902,I31dbc523,I570314b3
* changes: Merge WebKit at r75315: Update WebKit version Merge WebKit at r75315: Add FrameLoaderClient PageCache stubs Merge WebKit at r75315: Stub out AXObjectCache::remove() Merge WebKit at r75315: Fix ImageBuffer Merge WebKit at r75315: Fix PluginData::initPlugins() Merge WebKit at r75315: Fix conflicts Merge WebKit at r75315: Fix Makefiles Merge WebKit at r75315: Move Android-specific WebCore files to Source Merge WebKit at r75315: Initial merge by git.
Diffstat (limited to 'Source/JavaScriptCore/wtf/ListRefPtr.h')
-rw-r--r--Source/JavaScriptCore/wtf/ListRefPtr.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/wtf/ListRefPtr.h b/Source/JavaScriptCore/wtf/ListRefPtr.h
new file mode 100644
index 0000000..8bf6447
--- /dev/null
+++ b/Source/JavaScriptCore/wtf/ListRefPtr.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef WTF_ListRefPtr_h
+#define WTF_ListRefPtr_h
+
+#include <wtf/RefPtr.h>
+
+namespace WTF {
+
+ // Specialized version of RefPtr desgined for use in singly-linked lists.
+ // Derefs the list iteratively to avoid recursive derefing that can overflow the stack.
+ template <typename T> class ListRefPtr : public RefPtr<T> {
+ public:
+ ListRefPtr() : RefPtr<T>() {}
+ ListRefPtr(T* ptr) : RefPtr<T>(ptr) {}
+ ListRefPtr(const RefPtr<T>& o) : RefPtr<T>(o) {}
+ // see comment in PassRefPtr.h for why this takes const reference
+ template <typename U> ListRefPtr(const PassRefPtr<U>& o) : RefPtr<T>(o) {}
+
+ ~ListRefPtr();
+
+ ListRefPtr& operator=(T* optr) { RefPtr<T>::operator=(optr); return *this; }
+ ListRefPtr& operator=(const RefPtr<T>& o) { RefPtr<T>::operator=(o); return *this; }
+ ListRefPtr& operator=(const PassRefPtr<T>& o) { RefPtr<T>::operator=(o); return *this; }
+ template <typename U> ListRefPtr& operator=(const RefPtr<U>& o) { RefPtr<T>::operator=(o); return *this; }
+ template <typename U> ListRefPtr& operator=(const PassRefPtr<U>& o) { RefPtr<T>::operator=(o); return *this; }
+ };
+
+ // Remove inline for winscw compiler to prevent the compiler agressively resolving
+ // T::ref() in RefPtr<T>'s copy constructor. The bug is reported at:
+ // https://xdabug001.ext.nokia.com/bugzilla/show_bug.cgi?id=9812.
+ template <typename T>
+#if !COMPILER(WINSCW)
+ inline
+#endif
+ ListRefPtr<T>::~ListRefPtr()
+ {
+ RefPtr<T> reaper = this->release();
+ while (reaper && reaper->hasOneRef())
+ reaper = reaper->releaseNext(); // implicitly protects reaper->next, then derefs reaper
+ }
+
+ template <typename T> inline T* getPtr(const ListRefPtr<T>& p)
+ {
+ return p.get();
+ }
+
+} // namespace WTF
+
+using WTF::ListRefPtr;
+
+#endif // WTF_ListRefPtr_h