OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 #include "bindings/core/v8/WrapperTypeInfo.h" | 34 #include "bindings/core/v8/WrapperTypeInfo.h" |
35 #include "platform/ScriptForbiddenScope.h" | 35 #include "platform/ScriptForbiddenScope.h" |
36 #include "wtf/HashMap.h" | 36 #include "wtf/HashMap.h" |
37 #include <v8-util.h> | 37 #include <v8-util.h> |
38 #include <v8.h> | 38 #include <v8.h> |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 template<class KeyType> | 42 template<class KeyType> |
43 class DOMWrapperMap { | 43 class DOMWrapperMap { |
| 44 WTF_MAKE_FAST_ALLOCATED(DOMWrapperMap); |
44 public: | 45 public: |
45 explicit DOMWrapperMap(v8::Isolate* isolate) | 46 explicit DOMWrapperMap(v8::Isolate* isolate) |
46 : m_isolate(isolate) | 47 : m_isolate(isolate) |
47 , m_map(isolate) | 48 , m_map(isolate) |
48 { | 49 { |
49 } | 50 } |
50 | 51 |
51 v8::Local<v8::Object> newLocal(v8::Isolate* isolate, KeyType* key) | 52 v8::Local<v8::Object> newLocal(v8::Isolate* isolate, KeyType* key) |
52 { | 53 { |
53 return m_map.Get(key); | 54 return m_map.Get(key); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 87 } |
87 | 88 |
88 void removeAndDispose(KeyType* key) | 89 void removeAndDispose(KeyType* key) |
89 { | 90 { |
90 ASSERT(containsKey(key)); | 91 ASSERT(containsKey(key)); |
91 m_map.Remove(key); | 92 m_map.Remove(key); |
92 } | 93 } |
93 | 94 |
94 private: | 95 private: |
95 class PersistentValueMapTraits { | 96 class PersistentValueMapTraits { |
| 97 DISALLOW_ALLOCATION(); |
96 public: | 98 public: |
97 // Map traits: | 99 // Map traits: |
98 typedef HashMap<KeyType*, v8::PersistentContainerValue> Impl; | 100 typedef HashMap<KeyType*, v8::PersistentContainerValue> Impl; |
99 typedef typename Impl::iterator Iterator; | 101 typedef typename Impl::iterator Iterator; |
100 static size_t Size(const Impl* impl) { return impl->size(); } | 102 static size_t Size(const Impl* impl) { return impl->size(); } |
101 static bool Empty(Impl* impl) { return impl->isEmpty(); } | 103 static bool Empty(Impl* impl) { return impl->isEmpty(); } |
102 static void Swap(Impl& impl, Impl& other) { impl.swap(other); } | 104 static void Swap(Impl& impl, Impl& other) { impl.swap(other); } |
103 static Iterator Begin(Impl* impl) { return impl->begin(); } | 105 static Iterator Begin(Impl* impl) { return impl->begin(); } |
104 static Iterator End(Impl* impl) { return impl->end(); } | 106 static Iterator End(Impl* impl) { return impl->end(); } |
105 static v8::PersistentContainerValue Value(Iterator& iter) | 107 static v8::PersistentContainerValue Value(Iterator& iter) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 static void DisposeWeak(v8::Isolate* isolate, void* internalFields[v8::k
InternalFieldsInWeakCallback], KeyType* key) { } | 163 static void DisposeWeak(v8::Isolate* isolate, void* internalFields[v8::k
InternalFieldsInWeakCallback], KeyType* key) { } |
162 }; | 164 }; |
163 | 165 |
164 v8::Isolate* m_isolate; | 166 v8::Isolate* m_isolate; |
165 typename PersistentValueMapTraits::MapType m_map; | 167 typename PersistentValueMapTraits::MapType m_map; |
166 }; | 168 }; |
167 | 169 |
168 } // namespace blink | 170 } // namespace blink |
169 | 171 |
170 #endif // DOMWrapperMap_h | 172 #endif // DOMWrapperMap_h |
OLD | NEW |