Commit ffcc1ea7 authored by Keishi Hattori's avatar Keishi Hattori Committed by Commit Bot

Replace ScopedPersistent in V8V0CustomElementLifecycleCallbacks with TraceWrapperV8Reference

Replace ScopedPersistent in V8V0CustomElementLifecycleCallbacks with TraceWrapperV8Reference.
Use of ScopedPersistent is discourage in favour of TraceWrapperV8Reference which is GC aware.

Bug: 1013149
Change-Id: I3b45f15616d2b206d260f45519546e845a183c5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1855321
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705073}
parent d1eb2ebd
...@@ -106,19 +106,15 @@ V8V0CustomElementLifecycleCallbacks::V8V0CustomElementLifecycleCallbacks( ...@@ -106,19 +106,15 @@ V8V0CustomElementLifecycleCallbacks::V8V0CustomElementLifecycleCallbacks(
: V0CustomElementLifecycleCallbacks( : V0CustomElementLifecycleCallbacks(
FlagSet(attached, detached, attribute_changed)), FlagSet(attached, detached, attribute_changed)),
script_state_(script_state), script_state_(script_state),
prototype_(script_state->GetIsolate(), prototype), prototype_(script_state->GetIsolate(), prototype){
created_(script_state->GetIsolate(), created), v8::Isolate* isolate = script_state->GetIsolate();
attached_(script_state->GetIsolate(), attached), v8::Local<v8::Function> function;
detached_(script_state->GetIsolate(), detached), #define SET_FIELD(maybe, ignored) \
attribute_changed_(script_state->GetIsolate(), attribute_changed) { if (maybe.ToLocal(&function)) \
prototype_.SetPhantom(); maybe##_.Set(isolate, function);
#define MAKE_WEAK(Var, Ignored) \ CALLBACK_LIST(SET_FIELD)
if (!Var##_.IsEmpty()) \ #undef SET_FIELD
Var##_.SetPhantom();
CALLBACK_LIST(MAKE_WEAK)
#undef MAKE_WEAK
} }
V8PerContextData* V8V0CustomElementLifecycleCallbacks::CreationContextData() { V8PerContextData* V8V0CustomElementLifecycleCallbacks::CreationContextData() {
...@@ -228,7 +224,7 @@ void V8V0CustomElementLifecycleCallbacks::AttributeChanged( ...@@ -228,7 +224,7 @@ void V8V0CustomElementLifecycleCallbacks::AttributeChanged(
} }
void V8V0CustomElementLifecycleCallbacks::Call( void V8V0CustomElementLifecycleCallbacks::Call(
const ScopedPersistent<v8::Function>& weak_callback, const TraceWrapperV8Reference<v8::Function>& callback_reference,
Element* element) { Element* element) {
// FIXME: callbacks while paused should be queued up for execution to // FIXME: callbacks while paused should be queued up for execution to
// continue then be delivered in order rather than delivered immediately. // continue then be delivered in order rather than delivered immediately.
...@@ -238,7 +234,7 @@ void V8V0CustomElementLifecycleCallbacks::Call( ...@@ -238,7 +234,7 @@ void V8V0CustomElementLifecycleCallbacks::Call(
ScriptState::Scope scope(script_state_); ScriptState::Scope scope(script_state_);
v8::Isolate* isolate = script_state_->GetIsolate(); v8::Isolate* isolate = script_state_->GetIsolate();
v8::Local<v8::Context> context = script_state_->GetContext(); v8::Local<v8::Context> context = script_state_->GetContext();
v8::Local<v8::Function> callback = weak_callback.NewLocal(isolate); v8::Local<v8::Function> callback = callback_reference.NewLocal(isolate);
if (callback.IsEmpty()) if (callback.IsEmpty())
return; return;
...@@ -254,6 +250,11 @@ void V8V0CustomElementLifecycleCallbacks::Call( ...@@ -254,6 +250,11 @@ void V8V0CustomElementLifecycleCallbacks::Call(
void V8V0CustomElementLifecycleCallbacks::Trace(blink::Visitor* visitor) { void V8V0CustomElementLifecycleCallbacks::Trace(blink::Visitor* visitor) {
visitor->Trace(script_state_); visitor->Trace(script_state_);
visitor->Trace(prototype_);
visitor->Trace(created_);
visitor->Trace(attached_);
visitor->Trace(detached_);
visitor->Trace(attribute_changed_);
V0CustomElementLifecycleCallbacks::Trace(visitor); V0CustomElementLifecycleCallbacks::Trace(visitor);
} }
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/core/html/custom/v0_custom_element_lifecycle_callbacks.h" #include "third_party/blink/renderer/core/html/custom/v0_custom_element_lifecycle_callbacks.h"
#include "third_party/blink/renderer/platform/bindings/scoped_persistent.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/trace_wrapper_v8_reference.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
namespace blink { namespace blink {
...@@ -79,16 +79,17 @@ class V8V0CustomElementLifecycleCallbacks final ...@@ -79,16 +79,17 @@ class V8V0CustomElementLifecycleCallbacks final
const AtomicString& old_value, const AtomicString& old_value,
const AtomicString& new_value) override; const AtomicString& new_value) override;
void Call(const ScopedPersistent<v8::Function>& weak_callback, Element*); void Call(const TraceWrapperV8Reference<v8::Function>& callback_reference,
Element*);
V8PerContextData* CreationContextData(); V8PerContextData* CreationContextData();
Member<ScriptState> script_state_; Member<ScriptState> script_state_;
ScopedPersistent<v8::Object> prototype_; TraceWrapperV8Reference<v8::Object> prototype_;
ScopedPersistent<v8::Function> created_; TraceWrapperV8Reference<v8::Function> created_;
ScopedPersistent<v8::Function> attached_; TraceWrapperV8Reference<v8::Function> attached_;
ScopedPersistent<v8::Function> detached_; TraceWrapperV8Reference<v8::Function> detached_;
ScopedPersistent<v8::Function> attribute_changed_; TraceWrapperV8Reference<v8::Function> attribute_changed_;
}; };
} // namespace blink } // namespace blink
......
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