Commit 6544de65 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

v8binding: Stops using the copyable ver of v8::Persistent. (reland)

The first attempt: https://crrev.com/c/798820
Its revert: https://crrev.com/c/802715
The cause: Forgot to v8::Persistent::Reset in the dtor.

I learnt that v8::Persistent provides two variations of copying.
One actually copies, and the other actually shares the underlying
slot.

This patch changes CallbackFunctionBase::Persistent from the
"share" version to the "copy" (= make another independent slot)
version.

Bug: 779036
Change-Id: Id088dfa5ac111dbcb314ee992c6ba626e3a6f8ce
Reviewed-on: https://chromium-review.googlesource.com/802609Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520912}
parent f4638f7b
......@@ -75,11 +75,24 @@ class CallbackFunctionBase::Persistent
if (raw)
function_.Reset(raw->GetIsolate(), raw->callback_function_.Get());
}
Persistent(const Persistent& other)
: Parent(other), function_(other.function_) {}
~Persistent() = default;
Persistent& operator=(const Persistent& other) = default;
Persistent(const Persistent& other) : Parent(other) {
if (other)
function_.Reset(other->GetIsolate(), other.function_);
}
~Persistent() { function_.Reset(); }
Persistent& operator=(const Persistent& other) {
if (this == &other)
return *this;
if (other) {
Parent::operator=(other);
function_.Reset(other->GetIsolate(), other.function_);
} else {
Clear();
}
return *this;
}
void Clear() {
Parent::Clear();
......@@ -87,8 +100,7 @@ class CallbackFunctionBase::Persistent
}
private:
v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function>>
function_;
v8::Persistent<v8::Function> function_;
};
template <typename T>
......
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