| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 template<class KeyType> | 42 template<class KeyType> |
| 43 class DOMWrapperMap { | 43 class DOMWrapperMap { |
| 44 public: | 44 public: |
| 45 explicit DOMWrapperMap(v8::Isolate* isolate) | 45 explicit DOMWrapperMap(v8::Isolate* isolate) |
| 46 : m_isolate(isolate) | 46 : m_isolate(isolate) |
| 47 , m_map(isolate) | 47 , m_map(isolate) |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 | 50 |
| 51 v8::Handle<v8::Object> newLocal(v8::Isolate* isolate, KeyType* key) | 51 v8::Local<v8::Object> newLocal(v8::Isolate* isolate, KeyType* key) |
| 52 { | 52 { |
| 53 return m_map.Get(key); | 53 return m_map.Get(key); |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, KeyType* key
) | 56 bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, KeyType* key
) |
| 57 { | 57 { |
| 58 return m_map.SetReturnValue(key, returnValue); | 58 return m_map.SetReturnValue(key, returnValue); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void setReference(v8::Isolate* isolate, const v8::Persistent<v8::Object>& pa
rent, KeyType* key) | 61 void setReference(v8::Isolate* isolate, const v8::Persistent<v8::Object>& pa
rent, KeyType* key) |
| 62 { | 62 { |
| 63 m_map.SetReference(key, parent); | 63 m_map.SetReference(key, parent); |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool containsKey(KeyType* key) | 66 bool containsKey(KeyType* key) |
| 67 { | 67 { |
| 68 return m_map.Contains(key); | 68 return m_map.Contains(key); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void set(KeyType* key, v8::Handle<v8::Object> wrapper, const WrapperTypeInfo
* wrapperTypeInfo) | 71 void set(KeyType* key, v8::Local<v8::Object> wrapper, const WrapperTypeInfo*
wrapperTypeInfo) |
| 72 { | 72 { |
| 73 ASSERT((getInternalField<KeyType, v8DOMWrapperObjectIndex>(wrapper)) ==
key); | 73 ASSERT((getInternalField<KeyType, v8DOMWrapperObjectIndex>(wrapper)) ==
key); |
| 74 RELEASE_ASSERT(!containsKey(key)); // See crbug.com/368095 | 74 RELEASE_ASSERT(!containsKey(key)); // See crbug.com/368095 |
| 75 v8::Global<v8::Object> global(m_isolate, wrapper); | 75 v8::Global<v8::Object> global(m_isolate, wrapper); |
| 76 wrapperTypeInfo->configureWrapper(&global); | 76 wrapperTypeInfo->configureWrapper(&global); |
| 77 m_map.Set(key, global.Pass()); | 77 m_map.Set(key, global.Pass()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void clear() | 80 void clear() |
| 81 { | 81 { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 static void DisposeWeak(v8::Isolate* isolate, void* internalFields[v8::k
InternalFieldsInWeakCallback], KeyType* key) { } | 156 static void DisposeWeak(v8::Isolate* isolate, void* internalFields[v8::k
InternalFieldsInWeakCallback], KeyType* key) { } |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 v8::Isolate* m_isolate; | 159 v8::Isolate* m_isolate; |
| 160 typename PersistentValueMapTraits::MapType m_map; | 160 typename PersistentValueMapTraits::MapType m_map; |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 } // namespace blink | 163 } // namespace blink |
| 164 | 164 |
| 165 #endif // DOMWrapperMap_h | 165 #endif // DOMWrapperMap_h |
| OLD | NEW |