2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef DOMDataStore_h
32 #define DOMDataStore_h
38 #include <wtf/HashMap.h>
39 #include <wtf/MainThread.h>
40 #include <wtf/Noncopyable.h>
41 #include <wtf/OwnPtr.h>
42 #include <wtf/StdLibExtras.h>
43 #include <wtf/Threading.h>
44 #include <wtf/ThreadSpecific.h>
45 #include <wtf/Vector.h>
52 typedef WTF::Vector<DOMDataStore*> DOMDataList;
56 // DOMDataStore is the backing store that holds the maps between DOM objects
57 // and JavaScript objects. In general, each thread can have multiple backing
58 // stores, one per isolated world.
60 // This class doesn't manage the lifetime of the store. The data store
61 // lifetime is managed by subclasses.
64 WTF_MAKE_NONCOPYABLE(DOMDataStore);
66 enum DOMWrapperMapType {
71 DOMSVGElementInstanceMap
76 virtual ~DOMDataStore();
78 // A list of all DOMDataStore objects in the current V8 instance (thread). Normally, each World has a DOMDataStore.
79 static DOMDataList& allStores();
81 void* getDOMWrapperMap(DOMWrapperMapType);
83 DOMNodeMapping& domNodeMap() { return *m_domNodeMap; }
84 DOMWrapperMap<void>& domObjectMap() { return *m_domObjectMap; }
85 DOMWrapperMap<void>& activeDomObjectMap() { return *m_activeDomObjectMap; }
87 DOMWrapperMap<SVGElementInstance>& domSvgElementInstanceMap() { return *m_domSvgElementInstanceMap; }
90 // Need by V8GCController.
91 static void weakActiveDOMObjectCallback(v8::Persistent<v8::Value> v8Object, void* domObject);
94 static void weakNodeCallback(v8::Persistent<v8::Value> v8Object, void* domObject);
95 static void weakDOMObjectCallback(v8::Persistent<v8::Value> v8Object, void* domObject);
97 static void weakSVGElementInstanceCallback(v8::Persistent<v8::Value> v8Object, void* domObject);
100 DOMNodeMapping* m_domNodeMap;
101 DOMWrapperMap<void>* m_domObjectMap;
102 DOMWrapperMap<void>* m_activeDomObjectMap;
104 DOMWrapperMap<SVGElementInstance>* m_domSvgElementInstanceMap;
108 } // namespace WebCore
110 #endif // DOMDataStore_h