| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return impl->get(key); | 74 return impl->get(key); |
| 75 } | 75 } |
| 76 | 76 |
| 77 static v8::PersistentContainerValue Remove(Impl* impl, KeyType key) | 77 static v8::PersistentContainerValue Remove(Impl* impl, KeyType key) |
| 78 { | 78 { |
| 79 return impl->take(key); | 79 return impl->take(key); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Weak traits: | 82 // Weak traits: |
| 83 static const v8::PersistentContainerCallbackType kCallbackType = is_weak ? v
8::kWeak : v8::kNotWeak; | 83 static const v8::PersistentContainerCallbackType kCallbackType = is_weak ? v
8::kWeak : v8::kNotWeak; |
| 84 typedef v8::PersistentValueMap<KeyType, ValueType, V8PersistentValueMapTrait
s<KeyType, ValueType, is_weak> > MapType; | 84 typedef v8::PersistentValueMap<KeyType, ValueType, V8PersistentValueMapTrait
s<KeyType, ValueType, is_weak>> MapType; |
| 85 | 85 |
| 86 typedef void WeakCallbackDataType; | 86 typedef void WeakCallbackDataType; |
| 87 | 87 |
| 88 static WeakCallbackDataType* WeakCallbackParameter(MapType* map, KeyType key
, const v8::Local<ValueType>& value) | 88 static WeakCallbackDataType* WeakCallbackParameter(MapType* map, KeyType key
, const v8::Local<ValueType>& value) |
| 89 { | 89 { |
| 90 return 0; | 90 return 0; |
| 91 } | 91 } |
| 92 | 92 |
| 93 static void DisposeCallbackData(WeakCallbackDataType* callbackData) | 93 static void DisposeCallbackData(WeakCallbackDataType* callbackData) |
| 94 { | 94 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * A map for safely storing persistent V8 values, based on | 114 * A map for safely storing persistent V8 values, based on |
| 115 * v8::PersistentValueMap. | 115 * v8::PersistentValueMap. |
| 116 * | 116 * |
| 117 * If is_weak is set, values will be held weakly and map entries will be | 117 * If is_weak is set, values will be held weakly and map entries will be |
| 118 * removed as their values are being collected. | 118 * removed as their values are being collected. |
| 119 */ | 119 */ |
| 120 template<class KeyType, class ValueType, bool is_weak = true> | 120 template<class KeyType, class ValueType, bool is_weak = true> |
| 121 class V8PersistentValueMap : public v8::PersistentValueMap<KeyType, ValueType, V
8PersistentValueMapTraits<KeyType, ValueType, is_weak> > { | 121 class V8PersistentValueMap : public v8::PersistentValueMap<KeyType, ValueType, V
8PersistentValueMapTraits<KeyType, ValueType, is_weak>> { |
| 122 public: | 122 public: |
| 123 typedef V8PersistentValueMapTraits<KeyType, ValueType, is_weak> Traits; | 123 typedef V8PersistentValueMapTraits<KeyType, ValueType, is_weak> Traits; |
| 124 explicit V8PersistentValueMap(v8::Isolate* isolate) : v8::PersistentValueMap
<KeyType, ValueType, Traits>(isolate) { } | 124 explicit V8PersistentValueMap(v8::Isolate* isolate) : v8::PersistentValueMap
<KeyType, ValueType, Traits>(isolate) { } |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace blink | 127 } // namespace blink |
| 128 | 128 |
| 129 #endif // V8PersistentValueMap_h | 129 #endif // V8PersistentValueMap_h |
| OLD | NEW |