Commit 3f3b0167 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Don't duplicate |this| pointer in ActiveScriptWrappableBase methods.

The argument is always equal to the |this| pointer. We can just use the latter.

Change-Id: Ia14c0858b18c61bc500e3f276e36dc270a8e8232
Reviewed-on: https://chromium-review.googlesource.com/579961Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488612}
parent 659015bc
......@@ -23,15 +23,13 @@ void ActiveScriptWrappableBase::TraceActiveScriptWrappables(
v8::Isolate* isolate,
ScriptWrappableVisitor* visitor) {
V8PerIsolateData* isolate_data = V8PerIsolateData::From(isolate);
auto active_script_wrappables = isolate_data->ActiveScriptWrappables();
if (!active_script_wrappables) {
const auto* active_script_wrappables = isolate_data->ActiveScriptWrappables();
if (!active_script_wrappables)
return;
}
for (auto active_wrappable : *active_script_wrappables) {
if (!active_wrappable->DispatchHasPendingActivity(active_wrappable)) {
if (!active_wrappable->DispatchHasPendingActivity())
continue;
}
// A wrapper isn't kept alive after its ExecutionContext becomes
// detached, even if hasPendingActivity() returns |true|. This measure
......@@ -46,13 +44,11 @@ void ActiveScriptWrappableBase::TraceActiveScriptWrappables(
// |isContextDestroyed()|.
//
// TODO(haraken): Implement correct lifetime using traceWrapper.
if (active_wrappable->IsContextDestroyed(active_wrappable)) {
if (active_wrappable->IsContextDestroyed())
continue;
}
auto script_wrappable =
active_wrappable->ToScriptWrappable(active_wrappable);
auto wrapper_type_info =
ScriptWrappable* script_wrappable = active_wrappable->ToScriptWrappable();
auto* wrapper_type_info =
const_cast<WrapperTypeInfo*>(script_wrappable->GetWrapperTypeInfo());
visitor->RegisterV8Reference(
std::make_pair(wrapper_type_info, script_wrappable));
......
......@@ -33,10 +33,9 @@ class PLATFORM_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin {
ScriptWrappableVisitor*);
protected:
virtual bool IsContextDestroyed(ActiveScriptWrappableBase*) const = 0;
virtual bool DispatchHasPendingActivity(ActiveScriptWrappableBase*) const = 0;
virtual ScriptWrappable* ToScriptWrappable(
ActiveScriptWrappableBase*) const = 0;
virtual bool IsContextDestroyed() const = 0;
virtual bool DispatchHasPendingActivity() const = 0;
virtual ScriptWrappable* ToScriptWrappable() = 0;
};
template <typename T>
......@@ -47,21 +46,17 @@ class ActiveScriptWrappable : public ActiveScriptWrappableBase {
ActiveScriptWrappable() {}
protected:
bool IsContextDestroyed(ActiveScriptWrappableBase* object) const final {
return !(static_cast<T*>(object)->T::GetExecutionContext)() ||
(static_cast<T*>(object)->T::GetExecutionContext)()
->IsContextDestroyed();
bool IsContextDestroyed() const final {
const auto* execution_context =
static_cast<const T*>(this)->GetExecutionContext();
return !execution_context || execution_context->IsContextDestroyed();
}
bool DispatchHasPendingActivity(
ActiveScriptWrappableBase* object) const final {
return static_cast<T*>(object)->HasPendingActivity();
bool DispatchHasPendingActivity() const final {
return static_cast<const T*>(this)->HasPendingActivity();
}
ScriptWrappable* ToScriptWrappable(
ActiveScriptWrappableBase* object) const final {
return static_cast<T*>(object);
}
ScriptWrappable* ToScriptWrappable() final { return static_cast<T*>(this); }
};
} // 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