Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: Source/bindings/v8/DOMWrapperMap.h

Issue 13973026: remove memoryinstrumentation Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove the rest part of MemoryInstrumentation Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/DOMDataStore.cpp ('k') | Source/bindings/v8/ScriptProfiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef DOMWrapperMap_h 31 #ifndef DOMWrapperMap_h
32 #define DOMWrapperMap_h 32 #define DOMWrapperMap_h
33 33
34 #include "V8Utilities.h" 34 #include "V8Utilities.h"
35 #include "WebCoreMemoryInstrumentation.h"
36 #include "WrapperTypeInfo.h" 35 #include "WrapperTypeInfo.h"
37 #include <v8.h> 36 #include <v8.h>
38 #include <wtf/HashMap.h> 37 #include <wtf/HashMap.h>
39 #include <wtf/MemoryInstrumentationHashMap.h>
40 38
41 namespace WebCore { 39 namespace WebCore {
42 40
43 template<class KeyType> 41 template<class KeyType>
44 class DOMWrapperMap { 42 class DOMWrapperMap {
45 public: 43 public:
46 typedef HashMap<KeyType*, v8::Persistent<v8::Object> > MapType; 44 typedef HashMap<KeyType*, v8::Persistent<v8::Object> > MapType;
47 45
48 explicit DOMWrapperMap(v8::Isolate* isolate) 46 explicit DOMWrapperMap(v8::Isolate* isolate)
49 : m_isolate(isolate) 47 : m_isolate(isolate)
(...skipping 23 matching lines...) Expand all
73 map.swap(m_map); 71 map.swap(m_map);
74 for (typename MapType::iterator it = map.begin(); it != map.end(); + +it) { 72 for (typename MapType::iterator it = map.begin(); it != map.end(); + +it) {
75 v8::Persistent<v8::Object> wrapper = it->value; 73 v8::Persistent<v8::Object> wrapper = it->value;
76 toWrapperTypeInfo(wrapper)->derefObject(it->key); 74 toWrapperTypeInfo(wrapper)->derefObject(it->key);
77 wrapper.Dispose(m_isolate); 75 wrapper.Dispose(m_isolate);
78 wrapper.Clear(); 76 wrapper.Clear();
79 } 77 }
80 } 78 }
81 } 79 }
82 80
83 void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
84 {
85 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Binding );
86 info.addMember(m_map, "map");
87 }
88
89 void removeAndDispose(KeyType* key, v8::Handle<v8::Object> value, v8::Isolat e* isolate) 81 void removeAndDispose(KeyType* key, v8::Handle<v8::Object> value, v8::Isolat e* isolate)
90 { 82 {
91 v8::Persistent<v8::Object> wrapper(*value); 83 v8::Persistent<v8::Object> wrapper(*value);
92 typename MapType::iterator it = m_map.find(key); 84 typename MapType::iterator it = m_map.find(key);
93 ASSERT(it != m_map.end()); 85 ASSERT(it != m_map.end());
94 ASSERT(it->value == wrapper); 86 ASSERT(it->value == wrapper);
95 m_map.remove(it); 87 m_map.remove(it);
96 wrapper.Dispose(isolate); 88 wrapper.Dispose(isolate);
97 value.Clear(); 89 value.Clear();
98 } 90 }
99 91
100 private: 92 private:
101 v8::Isolate* m_isolate; 93 v8::Isolate* m_isolate;
102 MapType m_map; 94 MapType m_map;
103 }; 95 };
104 96
105 } // namespace WebCore 97 } // namespace WebCore
106 98
107 #endif // DOMWrapperMap_h 99 #endif // DOMWrapperMap_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/DOMDataStore.cpp ('k') | Source/bindings/v8/ScriptProfiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698