source: webkit/trunk/JavaScriptCore/wtf/RefCounted.h@ 27885

Last change on this file since 27885 was 27776, checked in by [email protected], 18 years ago

JavaScriptCore:

Reviewed by Anders Carlsson.

Renamed Shared to RefCounted.

  • API/JSClassRef.h:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/interpreter.h:
  • kjs/regexp.h:
  • wtf/RefCounted.h: Copied from JavaScriptCore/wtf/Shared.h. (WTF::RefCounted::RefCounted):
  • wtf/Shared.h: Removed.

JavaScriptGlue:

Reviewed by Anders Carlsson.

Renamed Shared to RefCounted.

  • ForwardingHeaders/wtf/RefCounted.h: Copied from JavaScriptGlue/ForwardingHeaders/wtf/Shared.h.
  • ForwardingHeaders/wtf/Shared.h: Removed.

WebCore:

Reviewed by Anders Carlsson.

Renamed Shared to RefCounted.

  • ForwardingHeaders/wtf/RefCounted.h: Copied from WebCore/ForwardingHeaders/wtf/Shared.h.
  • ForwardingHeaders/wtf/Shared.h: Removed.
  • bindings/js/JSSVGPODTypeWrapper.h:
  • css/CSSFontFace.h:
  • css/CSSRuleList.h:
  • css/Counter.h:
  • css/Pair.h:
  • css/Rect.h:
  • css/StyleBase.h:
  • css/StyleSheetList.h:
  • dom/Attribute.h:
  • dom/Clipboard.h:
  • dom/DOMImplementation.h:
  • dom/Event.h:
  • dom/EventListener.h:
  • dom/NamedNodeMap.h:
  • dom/NodeFilter.h:
  • dom/NodeFilterCondition.h:
  • dom/NodeList.h:
  • dom/QualifiedName.h:
  • dom/Range.h:
  • dom/RangeException.h:
  • dom/RegisteredEventListener.h:
  • dom/Traversal.h:
  • editing/EditCommand.h:
  • history/BackForwardList.h:
  • history/CachedPage.h:
  • history/HistoryItem.cpp: (WebCore::HistoryItem::HistoryItem):
  • history/HistoryItem.h:
  • html/CanvasGradient.h:
  • html/CanvasPattern.h:
  • html/CanvasRenderingContext2D.h:
  • html/CanvasStyle.h:
  • html/HTMLCollection.h:
  • html/MediaError.h:
  • html/TimeRanges.h:
  • html/VoidCallback.h:
  • ksvg2/css/SVGRenderStyle.cpp: (WebCore::SVGRenderStyle::SVGRenderStyle):
  • ksvg2/css/SVGRenderStyle.h:
  • ksvg2/css/SVGRenderStyleDefs.cpp: (StyleFillData::StyleFillData): (StyleStrokeData::StyleStrokeData): (StyleStopData::StyleStopData): (StyleTextData::StyleTextData): (StyleClipData::StyleClipData): (StyleMaskData::StyleMaskData): (StyleMarkerData::StyleMarkerData): (StyleMiscData::StyleMiscData):
  • ksvg2/css/SVGRenderStyleDefs.h:
  • ksvg2/svg/SVGAngle.cpp: (WebCore::SVGAngle::SVGAngle):
  • ksvg2/svg/SVGAngle.h:
  • ksvg2/svg/SVGAnimatedTemplate.h:
  • ksvg2/svg/SVGElementInstanceList.h:
  • ksvg2/svg/SVGException.h:
  • ksvg2/svg/SVGList.h:
  • ksvg2/svg/SVGPathSeg.h:
  • ksvg2/svg/SVGPreserveAspectRatio.cpp: (WebCore::SVGPreserveAspectRatio::SVGPreserveAspectRatio):
  • ksvg2/svg/SVGPreserveAspectRatio.h:
  • ksvg2/svg/SVGRenderingIntent.h:
  • ksvg2/svg/SVGTransform.h:
  • ksvg2/svg/SVGUnitTypes.h:
  • loader/DocumentLoader.h:
  • loader/FormState.h:
  • loader/ResourceLoader.h:
  • loader/TextResourceDecoder.h:
  • loader/icon/IconRecord.h:
  • page/BarInfo.h:
  • page/Console.h:
  • page/DOMSelection.h:
  • page/DOMWindow.h:
  • page/Frame.h:
  • page/History.h:
  • page/InspectorController.cpp:
  • page/Plugin.h:
  • page/Screen.h:
  • platform/ArrayImpl.h:
  • platform/CString.h:
  • platform/Cursor.h:
  • platform/DeprecatedValueListImpl.cpp: (WebCore::DeprecatedValueListImpl::Private::Private):
  • platform/FileChooser.h:
  • platform/FontFallbackList.h:
  • platform/FontFamily.cpp: (WebCore::FontFamily::FontFamily):
  • platform/FontFamily.h:
  • platform/FontSelector.h:
  • platform/GlyphPageTreeNode.h:
  • platform/PopupMenu.h:
  • platform/RegularExpression.cpp:
  • platform/ScrollBar.h:
  • platform/SharedBuffer.h:
  • platform/StringImpl.h:
  • platform/graphics/Icon.h:
  • platform/graphics/svg/SVGResource.h:
  • platform/network/FormData.cpp: (WebCore::FormData::FormData):
  • platform/network/FormData.h:
  • platform/network/ResourceHandle.h:
  • platform/network/ResourceHandleClient.h:
  • rendering/RenderStyle.cpp: (WebCore::StyleSurroundData::StyleSurroundData): (WebCore::StyleBoxData::StyleBoxData): (WebCore::StyleVisualData::StyleVisualData): (WebCore::StyleBackgroundData::StyleBackgroundData): (WebCore::StyleMarqueeData::StyleMarqueeData): (WebCore::StyleFlexibleBoxData::StyleFlexibleBoxData): (WebCore::StyleMultiColData::StyleMultiColData): (WebCore::StyleTransformData::StyleTransformData): (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareInheritedData::StyleRareInheritedData): (WebCore::StyleInheritedData::StyleInheritedData):
  • rendering/RenderStyle.h:
  • rendering/SVGCharacterLayoutInfo.h: (WebCore::SVGCharOnPath::SVGCharOnPath):
  • storage/SQLResultSetRowList.h:
  • xml/DOMParser.h:
  • xml/XMLHttpRequest.h:
  • xml/XMLSerializer.h:
  • xml/XPathEvaluator.h:
  • xml/XPathExpression.h:
  • xml/XPathNSResolver.h:
  • xml/XPathResult.h:
  • xml/XPathValue.h:
  • xml/XSLTProcessor.h:

WebKit/mac:

Reviewed by Anders Carlsson.


Renamed Shared to RefCounted.

  • ForwardingHeaders/wtf/RefCounted.h: Copied from WebKit/mac/ForwardingHeaders/wtf/Shared.h.
  • ForwardingHeaders/wtf/Shared.h: Removed.
  • WebCoreSupport/WebContextMenuClient.h:
  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1/*
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#ifndef RefCounted_h
22#define RefCounted_h
23
24#include <wtf/Assertions.h>
25#include <wtf/Noncopyable.h>
26
27namespace WTF {
28
29template<class T> class RefCounted : Noncopyable {
30public:
31 RefCounted()
32 : m_refCount(0)
33#ifndef NDEBUG
34 , m_deletionHasBegun(false)
35#endif
36 {
37 }
38
39 void ref()
40 {
41 ASSERT(!m_deletionHasBegun);
42 ++m_refCount;
43 }
44
45 void deref()
46 {
47 ASSERT(!m_deletionHasBegun);
48 if (--m_refCount <= 0) {
49#ifndef NDEBUG
50 m_deletionHasBegun = true;
51#endif
52 delete static_cast<T*>(this);
53 }
54 }
55
56 bool hasOneRef()
57 {
58 ASSERT(!m_deletionHasBegun);
59 return m_refCount == 1;
60 }
61
62 int refCount() const
63 {
64 return m_refCount;
65 }
66
67private:
68 int m_refCount;
69#ifndef NDEBUG
70 bool m_deletionHasBegun;
71#endif
72};
73
74} // namespace WTF
75
76using WTF::RefCounted;
77
78#endif // RefCounted_h
Note: See TracBrowser for help on using the repository browser.