Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_UTIL_H_ | 5 #ifndef V8_UTIL_H_ |
| 6 #define V8_UTIL_H_ | 6 #define V8_UTIL_H_ |
| 7 | 7 |
| 8 #include "v8.h" | 8 #include "v8.h" |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 private: | 276 private: |
| 277 PersistentValueMap(PersistentValueMap&); | 277 PersistentValueMap(PersistentValueMap&); |
| 278 void operator=(PersistentValueMap&); | 278 void operator=(PersistentValueMap&); |
| 279 | 279 |
| 280 /** | 280 /** |
| 281 * Put the value into the map, and set the 'weak' callback when demanded | 281 * Put the value into the map, and set the 'weak' callback when demanded |
| 282 * by the Traits class. | 282 * by the Traits class. |
| 283 */ | 283 */ |
| 284 UniquePersistent<V> SetUnique(const K& key, UniquePersistent<V>* persistent) { | 284 UniquePersistent<V> SetUnique(const K& key, UniquePersistent<V>* persistent) { |
| 285 if (Traits::kCallbackType != kNotWeak) { | 285 if (Traits::kCallbackType != kNotWeak) { |
| 286 // If the persistent is empty, the weak callback will actually never | |
| 287 // happen since there's no object to be garbage collected. | |
| 288 RELEASE_ASSERT(!persistent->IsEmpty()); | |
|
jochen (gone - plz use gerrit)
2014/05/05 17:42:46
the v8 equivalent to RELEASE_ASSERT() is CHECK(),
| |
| 289 | |
| 286 Local<V> value(Local<V>::New(isolate_, *persistent)); | 290 Local<V> value(Local<V>::New(isolate_, *persistent)); |
| 287 persistent->template SetWeak<typename Traits::WeakCallbackDataType>( | 291 persistent->template SetWeak<typename Traits::WeakCallbackDataType>( |
| 288 Traits::WeakCallbackParameter(this, key, value), WeakCallback); | 292 Traits::WeakCallbackParameter(this, key, value), WeakCallback); |
| 289 } | 293 } |
| 290 PersistentContainerValue old_value = | 294 PersistentContainerValue old_value = |
| 291 Traits::Set(&impl_, key, ClearAndLeak(persistent)); | 295 Traits::Set(&impl_, key, ClearAndLeak(persistent)); |
| 292 return Release(old_value).Pass(); | 296 return Release(old_value).Pass(); |
| 293 } | 297 } |
| 294 | 298 |
| 295 static void WeakCallback( | 299 static void WeakCallback( |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 return reinterpret_cast<V*>(v); | 481 return reinterpret_cast<V*>(v); |
| 478 } | 482 } |
| 479 | 483 |
| 480 Isolate* isolate_; | 484 Isolate* isolate_; |
| 481 typename Traits::Impl impl_; | 485 typename Traits::Impl impl_; |
| 482 }; | 486 }; |
| 483 | 487 |
| 484 } // namespace v8 | 488 } // namespace v8 |
| 485 | 489 |
| 486 #endif // V8_UTIL_H_ | 490 #endif // V8_UTIL_H_ |
| OLD | NEW |