Commit d4dd5c37 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

v8binding: Stops using the copyable ver of v8::Persistent.

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: I1fae7a1547af2abefa932458f398d8e2b50ecaa3
Reviewed-on: https://chromium-review.googlesource.com/798820Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520528}
parent 53549f0a
......@@ -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(const Persistent& other) : Parent(other) {
if (other)
function_.Reset(other->GetIsolate(), other.function_);
}
~Persistent() = default;
Persistent& operator=(const Persistent& other) = default;
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