source: webkit/trunk/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp@ 65286

Last change on this file since 65286 was 61324, checked in by Darin Adler, 15 years ago

2010-06-17 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

Use adoptRef and create functions in more code paths
https://bugs.webkit.org/show_bug.cgi?id=40760

  • API/JSClassRef.h: Removed unneeded include of RefCounted.h.
  • API/JSWeakObjectMapRefPrivate.cpp: Ditto.
  • bytecode/CodeBlock.h: (JSC::FunctionCodeBlock::FunctionCodeBlock): Use the SharedSymbolTable::create function instead of calling new directly.
  • runtime/SymbolTable.h: Added a create function to the SharedSymbolTable class and made the constructor private.

2010-06-17 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

Use adoptRef and create functions in more code paths
https://bugs.webkit.org/show_bug.cgi?id=40760

  • Plugins/Hosted/NetscapePluginInstanceProxy.h: Made create no longer be an inline function.
  • Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::NetscapePluginInstanceProxy): Moved the call to addPluginInstance out of here. (WebKit::NetscapePluginInstanceProxy::create): Move it in here. This makes sure we call adoptRef on the new proxy before any caller calls ref on it.

2010-06-17 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

Use adoptRef and create functions in more code paths
https://bugs.webkit.org/show_bug.cgi?id=40760

This helps prepare for an assertion that fires if you ref or destroy an
object before calling adoptRef on it. That will help us catch mistakes
that can lead to storage leaks.

  • WebCore.base.exp: Updated export now that Frame::create is not an inline function.
  • css/CSSInitialValue.h: (WebCore::CSSInitialValue::createExplicit): Use create. (WebCore::CSSInitialValue::createImplicit): Ditto. (WebCore::CSSInitialValue::create): Added.
  • css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::createUncachedIdentifier): Added. (WebCore::CSSPrimitiveValue::createUncachedColor): Added. (WebCore::CSSPrimitiveValue::createUncached): Added. (WebCore::CSSPrimitiveValue::createIdentifier): Use createUncachedIdentifier instead of using new directly. (WebCore::CSSPrimitiveValue::createColor): Use createUncachedColor instead of using new directly. (WebCore::CSSPrimitiveValue::create): Use createdUncached instead of using new directly.
  • css/CSSPrimitiveValue.h: Declare the new functions above.
  • css/CSSStyleSelector.cpp: (WebCore::loadFullDefaultStyle): Deref simpleDefaultStyleSheet instead of explicitly deleting it.
  • loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::SubresourceLoader): Move the call to addSubresourceLoader out of here. (WebCore::SubresourceLoader::create): Move it in here. This makes it so we don't ref the loader before finishing its creation and calling adoptRef.
  • page/Frame.cpp: (WebCore::Frame::Frame): Move the call to setMainFrame out of here. Also refactor the code so an assertion is easier to read. (WebCore::Frame::create): Move the call to setMainFrame in here. This makes it so we don't ref the frame before finishing its creation and calling adoptRef.
  • page/Frame.h: Made the create function non-inline.
  • platform/text/BidiContext.cpp: (WebCore::BidiContext::createUncached): Added. (WebCore::BidiContext::create): Call createUncached instead of callling new directly.
  • platform/text/BidiContext.h: Declare createUncached.
  • rendering/RenderSVGResourceFilter.cpp: (WebCore::RenderSVGResourceFilter::buildPrimitives): Use PassRefPtr and RefPtr instead of OwnPtr. And use the create function instead of new.
  • rendering/RenderSVGResourceFilter.h: Ditto.
  • rendering/SVGRenderTreeAsText.cpp: (WebCore::writeSVGResourceContainer): Ditto.
  • storage/StorageAreaImpl.cpp: (WebCore::StorageAreaImpl::StorageAreaImpl): Move the code that calls StorageAreaSync::create out of here. (WebCore::StorageAreaImpl::create): Move it in here. This makes it so we don't ref the storage area before finishing its creation and calling adoptRef.
  • svg/SVGPaint.cpp: (WebCore::SVGPaint::defaultFill): Use create instead of new. (WebCore::SVGPaint::defaultStroke): Ditto.
  • svg/graphics/filters/SVGFilterBuilder.h: Made the constructor private and added a create function since this is a reference counted object and should not be constructed directly.

2010-06-17 Darin Adler <Darin Adler>

Reviewed by Sam Weinig.

Use adoptRef and create functions in more code paths
https://bugs.webkit.org/show_bug.cgi?id=40760

  • DumpRenderTree/DumpRenderTree.h: Change gLayoutTestController to a RefPtr.
  • DumpRenderTree/LayoutTestController.cpp: (LayoutTestController::create): Added.
  • DumpRenderTree/LayoutTestController.h: Declare the create function.
  • DumpRenderTree/chromium/TestShell.cpp: (TestShell::TestShell): Use create instead of new.
  • DumpRenderTree/chromium/TestShell.h: Use RefPtr instead of OwnPtr.
  • DumpRenderTree/gtk/DumpRenderTree.cpp: (runTest): Use RefPtr and create instead of OwnPtr and new.
  • DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Use RefPtr and create instead of OwnPtr and new.
  • DumpRenderTree/qt/DumpRenderTreeQt.cpp: (WebCore::DumpRenderTree::DumpRenderTree): Use create and releaseRef instead of new.
  • DumpRenderTree/win/DumpRenderTree.cpp: (runTest): Use RefPtr and create instead of OwnPtr and new.
  • DumpRenderTree/wx/DumpRenderTreeWx.cpp: (runTest): Use RefPtr and create instead of OwnPtr and new. (MyApp::OnInit): Removed unneeded code to delete the layout test controller. This is done during each test.
File size: 2.9 KB
Line 
1/*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "JSWeakObjectMapRefPrivate.h"
28
29#include "APICast.h"
30#include "APIShims.h"
31#include "JSCallbackObject.h"
32#include "JSValue.h"
33#include "JSWeakObjectMapRefInternal.h"
34#include <wtf/HashMap.h>
35#include <wtf/text/StringHash.h>
36
37using namespace WTF;
38using namespace JSC;
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44JSWeakObjectMapRef JSWeakObjectMapCreate(JSContextRef context, void* privateData, JSWeakMapDestroyedCallback callback)
45{
46 ExecState* exec = toJS(context);
47 APIEntryShim entryShim(exec);
48 RefPtr<OpaqueJSWeakObjectMap> map = OpaqueJSWeakObjectMap::create(privateData, callback);
49 exec->lexicalGlobalObject()->registerWeakMap(map.get());
50 return map.get();
51}
52
53void JSWeakObjectMapSet(JSContextRef ctx, JSWeakObjectMapRef map, void* key, JSObjectRef object)
54{
55 ExecState* exec = toJS(ctx);
56 APIEntryShim entryShim(exec);
57 JSObject* obj = toJS(object);
58 if (!obj)
59 return;
60 ASSERT(obj->inherits(&JSCallbackObject<JSGlobalObject>::info) || obj->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info));
61 map->map().set(key, obj);
62}
63
64JSObjectRef JSWeakObjectMapGet(JSContextRef ctx, JSWeakObjectMapRef map, void* key)
65{
66 ExecState* exec = toJS(ctx);
67 APIEntryShim entryShim(exec);
68 return toRef(static_cast<JSObject*>(map->map().get(key)));
69}
70
71bool JSWeakObjectMapClear(JSContextRef ctx, JSWeakObjectMapRef map, void* key, JSObjectRef object)
72{
73 ExecState* exec = toJS(ctx);
74 APIEntryShim entryShim(exec);
75 JSObject* obj = toJS(object);
76 if (map->map().uncheckedRemove(key, obj))
77 return true;
78 return false;
79}
80
81#ifdef __cplusplus
82}
83#endif
Note: See TracBrowser for help on using the repository browser.