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( ...@@ -23,15 +23,13 @@ void ActiveScriptWrappableBase::TraceActiveScriptWrappables(
v8::Isolate* isolate, v8::Isolate* isolate,
ScriptWrappableVisitor* visitor) { ScriptWrappableVisitor* visitor) {
V8PerIsolateData* isolate_data = V8PerIsolateData::From(isolate); V8PerIsolateData* isolate_data = V8PerIsolateData::From(isolate);
auto active_script_wrappables = isolate_data->ActiveScriptWrappables(); const auto* active_script_wrappables = isolate_data->ActiveScriptWrappables();
if (!active_script_wrappables) { if (!active_script_wrappables)
return; return;
}
for (auto active_wrappable : *active_script_wrappables) { for (auto active_wrappable : *active_script_wrappables) {
if (!active_wrappable->DispatchHasPendingActivity(active_wrappable)) { if (!active_wrappable->DispatchHasPendingActivity())
continue; continue;
}
// A wrapper isn't kept alive after its ExecutionContext becomes // A wrapper isn't kept alive after its ExecutionContext becomes
// detached, even if hasPendingActivity() returns |true|. This measure // detached, even if hasPendingActivity() returns |true|. This measure
...@@ -46,13 +44,11 @@ void ActiveScriptWrappableBase::TraceActiveScriptWrappables( ...@@ -46,13 +44,11 @@ void ActiveScriptWrappableBase::TraceActiveScriptWrappables(
// |isContextDestroyed()|. // |isContextDestroyed()|.
// //
// TODO(haraken): Implement correct lifetime using traceWrapper. // TODO(haraken): Implement correct lifetime using traceWrapper.
if (active_wrappable->IsContextDestroyed(active_wrappable)) { if (active_wrappable->IsContextDestroyed())
continue; continue;
}
auto script_wrappable = ScriptWrappable* script_wrappable = active_wrappable->ToScriptWrappable();
active_wrappable->ToScriptWrappable(active_wrappable); auto* wrapper_type_info =
auto wrapper_type_info =
const_cast<WrapperTypeInfo*>(script_wrappable->GetWrapperTypeInfo()); const_cast<WrapperTypeInfo*>(script_wrappable->GetWrapperTypeInfo());
visitor->RegisterV8Reference( visitor->RegisterV8Reference(
std::make_pair(wrapper_type_info, script_wrappable)); std::make_pair(wrapper_type_info, script_wrappable));
......
...@@ -33,10 +33,9 @@ class PLATFORM_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin { ...@@ -33,10 +33,9 @@ class PLATFORM_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin {
ScriptWrappableVisitor*); ScriptWrappableVisitor*);
protected: protected:
virtual bool IsContextDestroyed(ActiveScriptWrappableBase*) const = 0; virtual bool IsContextDestroyed() const = 0;
virtual bool DispatchHasPendingActivity(ActiveScriptWrappableBase*) const = 0; virtual bool DispatchHasPendingActivity() const = 0;
virtual ScriptWrappable* ToScriptWrappable( virtual ScriptWrappable* ToScriptWrappable() = 0;
ActiveScriptWrappableBase*) const = 0;
}; };
template <typename T> template <typename T>
...@@ -47,21 +46,17 @@ class ActiveScriptWrappable : public ActiveScriptWrappableBase { ...@@ -47,21 +46,17 @@ class ActiveScriptWrappable : public ActiveScriptWrappableBase {
ActiveScriptWrappable() {} ActiveScriptWrappable() {}
protected: protected:
bool IsContextDestroyed(ActiveScriptWrappableBase* object) const final { bool IsContextDestroyed() const final {
return !(static_cast<T*>(object)->T::GetExecutionContext)() || const auto* execution_context =
(static_cast<T*>(object)->T::GetExecutionContext)() static_cast<const T*>(this)->GetExecutionContext();
->IsContextDestroyed(); return !execution_context || execution_context->IsContextDestroyed();
} }
bool DispatchHasPendingActivity( bool DispatchHasPendingActivity() const final {
ActiveScriptWrappableBase* object) const final { return static_cast<const T*>(this)->HasPendingActivity();
return static_cast<T*>(object)->HasPendingActivity();
} }
ScriptWrappable* ToScriptWrappable( ScriptWrappable* ToScriptWrappable() final { return static_cast<T*>(this); }
ActiveScriptWrappableBase* object) const final {
return static_cast<T*>(object);
}
}; };
} // 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