Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: include/v8-util.h

Issue 1074153002: simplify GlobalValueMap calls to DisposeWeak (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8-util.h
diff --git a/include/v8-util.h b/include/v8-util.h
index b01d527754b5ce758d641fadfabc0b7133d92c5f..8199016a89fd5e554af4177d5909d97514542b0d 100644
--- a/include/v8-util.h
+++ b/include/v8-util.h
@@ -134,9 +134,8 @@ class DefaultGlobalMapTraits : public StdMapTraits<K, V> {
}
static void DisposeCallbackData(WeakCallbackInfoType* data) {}
static void Dispose(Isolate* isolate, Global<V> value, K key) {}
- static void DisposeWeak(Isolate* isolate,
- const WeakCallbackInfo<WeakCallbackInfoType>& data,
- K key) {}
+ // This is a second pass callback, so SetSecondPassCallback cannot be called.
+ static void DisposeWeak(const WeakCallbackInfo<WeakCallbackInfoType>& data) {}
private:
template <typename T>
@@ -453,7 +452,7 @@ class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> {
: WeakCallbackType::kParameter;
Local<V> value(Local<V>::New(this->isolate(), *persistent));
persistent->template SetWeak<typename Traits::WeakCallbackDataType>(
- Traits::WeakCallbackParameter(this, key, value), WeakCallback,
+ Traits::WeakCallbackParameter(this, key, value), FirstWeakCallback,
callback_type);
}
PersistentContainerValue old_value =
@@ -472,16 +471,20 @@ class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> {
}
private:
- static void WeakCallback(
+ static void FirstWeakCallback(
const WeakCallbackInfo<typename Traits::WeakCallbackDataType>& data) {
if (Traits::kCallbackType != kNotWeak) {
- GlobalValueMap<K, V, Traits>* persistentValueMap =
- Traits::MapFromWeakCallbackInfo(data);
+ auto map = Traits::MapFromWeakCallbackInfo(data);
K key = Traits::KeyFromWeakCallbackInfo(data);
- persistentValueMap->RemoveWeak(key);
- Traits::DisposeWeak(data.GetIsolate(), data, key);
+ map->RemoveWeak(key);
+ data.SetSecondPassCallback(SecondWeakCallback);
}
}
+
+ static void SecondWeakCallback(
+ const WeakCallbackInfo<typename Traits::WeakCallbackDataType>& data) {
+ Traits::DisposeWeak(data);
+ }
};
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698