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

v8binding: Minor refactoring of ActiveScriptWrappable.

ActiveScriptWrappable is designed to be inherited.  The ctor should
be protected:.

Also all classes that support virtual member functions should have
the virtual dtor.

Change-Id: I1eaa60b45607b5404868e0d293a150e1b98dfc5b
Reviewed-on: https://chromium-review.googlesource.com/964068Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543343}
parent 556a9a41
...@@ -17,9 +17,11 @@ class ActiveScriptWrappable : public ActiveScriptWrappableBase { ...@@ -17,9 +17,11 @@ class ActiveScriptWrappable : public ActiveScriptWrappableBase {
WTF_MAKE_NONCOPYABLE(ActiveScriptWrappable); WTF_MAKE_NONCOPYABLE(ActiveScriptWrappable);
public: public:
ActiveScriptWrappable() = default; ~ActiveScriptWrappable() override = default;
protected: protected:
ActiveScriptWrappable() = default;
bool IsContextDestroyed() const final { bool IsContextDestroyed() const final {
const auto* execution_context = const auto* execution_context =
static_cast<const T*>(this)->GetExecutionContext(); static_cast<const T*>(this)->GetExecutionContext();
......
...@@ -12,13 +12,6 @@ ...@@ -12,13 +12,6 @@
namespace blink { namespace blink {
ActiveScriptWrappableBase::ActiveScriptWrappableBase() {
DCHECK(ThreadState::Current());
v8::Isolate* isolate = ThreadState::Current()->GetIsolate();
V8PerIsolateData* isolate_data = V8PerIsolateData::From(isolate);
isolate_data->AddActiveScriptWrappable(this);
}
void ActiveScriptWrappableBase::TraceActiveScriptWrappables( void ActiveScriptWrappableBase::TraceActiveScriptWrappables(
v8::Isolate* isolate, v8::Isolate* isolate,
ScriptWrappableVisitor* visitor) { ScriptWrappableVisitor* visitor) {
...@@ -57,4 +50,11 @@ void ActiveScriptWrappableBase::TraceActiveScriptWrappables( ...@@ -57,4 +50,11 @@ void ActiveScriptWrappableBase::TraceActiveScriptWrappables(
} }
} }
ActiveScriptWrappableBase::ActiveScriptWrappableBase() {
DCHECK(ThreadState::Current());
v8::Isolate* isolate = ThreadState::Current()->GetIsolate();
V8PerIsolateData* isolate_data = V8PerIsolateData::From(isolate);
isolate_data->AddActiveScriptWrappable(this);
}
} // namespace blink } // namespace blink
...@@ -8,10 +8,7 @@ ...@@ -8,10 +8,7 @@
#include "platform/PlatformExport.h" #include "platform/PlatformExport.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "platform/wtf/Noncopyable.h" #include "platform/wtf/Noncopyable.h"
#include "v8/include/v8.h"
namespace v8 {
class Isolate;
}
namespace blink { namespace blink {
...@@ -27,12 +24,14 @@ class PLATFORM_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin { ...@@ -27,12 +24,14 @@ class PLATFORM_EXPORT ActiveScriptWrappableBase : public GarbageCollectedMixin {
WTF_MAKE_NONCOPYABLE(ActiveScriptWrappableBase); WTF_MAKE_NONCOPYABLE(ActiveScriptWrappableBase);
public: public:
ActiveScriptWrappableBase();
static void TraceActiveScriptWrappables(v8::Isolate*, static void TraceActiveScriptWrappables(v8::Isolate*,
ScriptWrappableVisitor*); ScriptWrappableVisitor*);
virtual ~ActiveScriptWrappableBase() = default;
protected: protected:
ActiveScriptWrappableBase();
virtual bool IsContextDestroyed() const = 0; virtual bool IsContextDestroyed() const = 0;
virtual bool DispatchHasPendingActivity() const = 0; virtual bool DispatchHasPendingActivity() const = 0;
virtual ScriptWrappable* ToScriptWrappable() = 0; virtual ScriptWrappable* ToScriptWrappable() = 0;
......
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