diff options
author | dglazkov@chromium.org <dglazkov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 21:30:15 +0000 |
---|---|---|
committer | dglazkov@chromium.org <dglazkov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 21:30:15 +0000 |
commit | e7e21c8163aa4b71d69d19ba5c9a7d5bfd0d8da9 (patch) | |
tree | 82aa8a770e6b83fc0d573c458f6983f9cdcb6add /webkit | |
parent | 6a0f942ce84fe3bb6ba3f491b8c8c32f24ca54a3 (diff) | |
download | chromium_src-e7e21c8163aa4b71d69d19ba5c9a7d5bfd0d8da9.zip chromium_src-e7e21c8163aa4b71d69d19ba5c9a7d5bfd0d8da9.tar.gz chromium_src-e7e21c8163aa4b71d69d19ba5c9a7d5bfd0d8da9.tar.bz2 |
Complete upstreaming V8 DOM Wrapper Map.
R=levin
BUG=3319
TEST=no additional regressions.
Review URL: http://codereview.chromium.org/113476
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16186 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/port/bindings/v8/V8NPObject.cpp | 2 | ||||
-rw-r--r-- | webkit/port/bindings/v8/dom_wrapper_map.h | 72 | ||||
-rw-r--r-- | webkit/webkit.gyp | 1 |
3 files changed, 1 insertions, 74 deletions
diff --git a/webkit/port/bindings/v8/V8NPObject.cpp b/webkit/port/bindings/v8/V8NPObject.cpp index eec8417..a902ab7 100644 --- a/webkit/port/bindings/v8/V8NPObject.cpp +++ b/webkit/port/bindings/v8/V8NPObject.cpp @@ -36,7 +36,7 @@ #include "NPV8Object.h" #include "npruntime_priv.h" #include "v8_proxy.h" -#include "dom_wrapper_map.h" +#include "V8DOMMap.h" #include "HTMLPlugInElement.h" #include "V8HTMLAppletElement.h" #include "V8HTMLEmbedElement.h" diff --git a/webkit/port/bindings/v8/dom_wrapper_map.h b/webkit/port/bindings/v8/dom_wrapper_map.h deleted file mode 100644 index e95ff88..0000000 --- a/webkit/port/bindings/v8/dom_wrapper_map.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BINDINGS_V8_DOM_WRAPPER_MAP -#define BINDINGS_V8_DOM_WRAPPER_MAP - -#include <v8.h> -#include <wtf/HashMap.h> - -// A table of wrappers with weak pointers. -// This table allows us to avoid track wrapped objects for debugging -// and for ensuring that we don't double wrap the same object. -template<class KeyType, class ValueType> -class WeakReferenceMap { - public: - WeakReferenceMap(v8::WeakReferenceCallback callback) : - weak_reference_callback_(callback) { } -#ifndef NDEBUG - virtual ~WeakReferenceMap() { - if (map_.size() > 0) { - fprintf(stderr, "Leak %d JS wrappers.\n", map_.size()); - // Print out details. - } - } -#endif - - // Get the JS wrapper object of an object. - virtual v8::Persistent<ValueType> get(KeyType* obj) { - ValueType* wrapper = map_.get(obj); - return wrapper ? v8::Persistent<ValueType>(wrapper) - : v8::Persistent<ValueType>(); - } - - virtual void set(KeyType* obj, v8::Persistent<ValueType> wrapper) { - ASSERT(!map_.contains(obj)); - wrapper.MakeWeak(obj, weak_reference_callback_); - map_.set(obj, *wrapper); - } - - virtual void forget(KeyType* obj) { - ASSERT(obj); - ValueType* wrapper = map_.take(obj); - if (wrapper) { - v8::Persistent<ValueType> handle(wrapper); - handle.Dispose(); - handle.Clear(); - } - } - - bool contains(KeyType* obj) { - return map_.contains(obj); - } - - HashMap<KeyType*, ValueType*>& impl() { - return map_; - } - - protected: - HashMap<KeyType*, ValueType*> map_; - v8::WeakReferenceCallback weak_reference_callback_; -}; - - -template <class KeyType> -class DOMWrapperMap : public WeakReferenceMap<KeyType, v8::Object> { - public: - DOMWrapperMap(v8::WeakReferenceCallback callback) : - WeakReferenceMap<KeyType, v8::Object>(callback) { } -}; - -#endif // BINDINGS_V8_DOM_WRAPPER_MAP diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 1f41666..ac60041 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -1125,7 +1125,6 @@ 'port/bindings/v8/ScriptController.h', 'port/bindings/v8/V8MessagePortCustom.cpp', 'port/bindings/v8/V8SVGPODTypeWrapper.h', - 'port/bindings/v8/dom_wrapper_map.h', 'port/bindings/v8/NPV8Object.cpp', 'port/bindings/v8/NPV8Object.h', 'port/bindings/v8/npruntime.cpp', |