Commit 39b2227b authored by ccyongwang's avatar ccyongwang Committed by Commit Bot

fix compile error when use PersistentValueMap.

In PersistentValueMap, SetWeak function should supply WeakCallbackType arguments.

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: I70a59e90b7ea0a10f695419e57ae9bfb8d5ba852
Reviewed-on: https://chromium-review.googlesource.com/684002
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48529}
parent 68a16b63
......@@ -133,6 +133,7 @@ Vlad Burlik <vladbph@gmail.com>
Vladimir Krivosheev <develar@gmail.com>
Vladimir Shutoff <vovan@shutoff.ru>
Wiktor Garbacz <wiktor.garbacz@gmail.com>
Yong Wang <ccyongwang@tencent.com>
Yu Yin <xwafish@gmail.com>
Zac Hansen <xaxxon@gmail.com>
Zhongping Wang <kewpie.w.zp@gmail.com>
......
......@@ -393,9 +393,14 @@ class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
*/
Global<V> SetUnique(const K& key, Global<V>* persistent) {
if (Traits::kCallbackType != kNotWeak) {
WeakCallbackType callback_type =
Traits::kCallbackType == kWeakWithInternalFields
? WeakCallbackType::kInternalFields
: 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), WeakCallback,
callback_type);
}
PersistentContainerValue old_value =
Traits::Set(this->impl(), key, this->ClearAndLeak(persistent));
......
......@@ -27314,3 +27314,19 @@ TEST(PrimitiveArray) {
CHECK(array->Get(3)->IsBoolean());
CHECK(array->Get(4)->IsNull());
}
TEST(PersistentValueMap) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
LocalContext env;
v8::PersistentValueMap<
std::string, v8::Value,
v8::DefaultPersistentValueMapTraits<std::string, v8::Value>>
map(isolate);
v8::Local<v8::Value> value =
v8::String::NewFromUtf8(isolate, "value",
v8::NewStringType::kInternalized)
.ToLocalChecked();
map.Set("key", value);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment