| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 void set(KeyType* key, v8::Handle<v8::Object> wrapper, const WrapperConfigur
ation& configuration) | 84 void set(KeyType* key, v8::Handle<v8::Object> wrapper, const WrapperConfigur
ation& configuration) |
| 85 { | 85 { |
| 86 ASSERT(static_cast<KeyType*>(toNative(wrapper)) == key); | 86 ASSERT(static_cast<KeyType*>(toNative(wrapper)) == key); |
| 87 v8::Persistent<v8::Object> persistent(m_isolate, wrapper); | 87 v8::Persistent<v8::Object> persistent(m_isolate, wrapper); |
| 88 configuration.configureWrapper(&persistent); | 88 configuration.configureWrapper(&persistent); |
| 89 persistent.SetWeak(this, &setWeakCallback); | 89 persistent.SetWeak(this, &setWeakCallback); |
| 90 typename MapType::AddResult result = m_map.add(key, UnsafePersistent<v8:
:Object>()); | 90 typename MapType::AddResult result = m_map.add(key, UnsafePersistent<v8:
:Object>()); |
| 91 ASSERT(result.isNewEntry); | 91 ASSERT(result.isNewEntry); |
| 92 // FIXME: Stop handling this case once duplicate wrappers are guaranteed
not to be created. | 92 // FIXME: Stop handling this case once duplicate wrappers are guaranteed
not to be created. |
| 93 if (!result.isNewEntry) | 93 if (!result.isNewEntry) |
| 94 result.iterator->value.dispose(); | 94 result.storedValue->value.dispose(); |
| 95 result.iterator->value = UnsafePersistent<v8::Object>(persistent); | 95 result.storedValue->value = UnsafePersistent<v8::Object>(persistent); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void clear() | 98 void clear() |
| 99 { | 99 { |
| 100 v8::HandleScope scope(m_isolate); | 100 v8::HandleScope scope(m_isolate); |
| 101 while (!m_map.isEmpty()) { | 101 while (!m_map.isEmpty()) { |
| 102 // Swap out m_map on each iteration to ensure any wrappers added due
to side effects of the loop are cleared. | 102 // Swap out m_map on each iteration to ensure any wrappers added due
to side effects of the loop are cleared. |
| 103 MapType map; | 103 MapType map; |
| 104 map.swap(m_map); | 104 map.swap(m_map); |
| 105 for (typename MapType::iterator it = map.begin(); it != map.end(); +
+it) { | 105 for (typename MapType::iterator it = map.begin(); it != map.end(); +
+it) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 129 { | 129 { |
| 130 void* key = static_cast<void*>(toNative(data.GetValue())); | 130 void* key = static_cast<void*>(toNative(data.GetValue())); |
| 131 ASSERT(*data.GetParameter()->m_map.get(key).persistent() == data.GetValue())
; | 131 ASSERT(*data.GetParameter()->m_map.get(key).persistent() == data.GetValue())
; |
| 132 data.GetParameter()->removeAndDispose(key); | 132 data.GetParameter()->removeAndDispose(key); |
| 133 releaseObject(data.GetValue()); | 133 releaseObject(data.GetValue()); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace WebCore | 136 } // namespace WebCore |
| 137 | 137 |
| 138 #endif // DOMWrapperMap_h | 138 #endif // DOMWrapperMap_h |
| OLD | NEW |