| Index: third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.cpp b/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.cpp
|
| index 2c44e04451016528612e51009012b2c17b843847..ef1a3770f1b7236cb09019c170cea0f142ab6ca6 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/ActiveScriptWrappable.cpp
|
| @@ -4,13 +4,16 @@
|
|
|
| #include "bindings/core/v8/ActiveScriptWrappable.h"
|
|
|
| +#include "bindings/core/v8/DOMDataStore.h"
|
| #include "bindings/core/v8/ScriptWrappable.h"
|
| #include "bindings/core/v8/ScriptWrappableVisitor.h"
|
| +#include "bindings/core/v8/V8Binding.h"
|
| #include "bindings/core/v8/V8PerIsolateData.h"
|
| +#include "core/dom/ExecutionContext.h"
|
|
|
| namespace blink {
|
|
|
| -ActiveScriptWrappable::ActiveScriptWrappable(ScriptWrappable* self)
|
| +ActiveScriptWrappableBase::ActiveScriptWrappableBase(ScriptWrappable* self)
|
| : m_scriptWrappable(self) {
|
| ASSERT(ThreadState::current());
|
| v8::Isolate* isolate = ThreadState::current()->isolate();
|
| @@ -18,7 +21,7 @@ ActiveScriptWrappable::ActiveScriptWrappable(ScriptWrappable* self)
|
| isolateData->addActiveScriptWrappable(this);
|
| }
|
|
|
| -void ActiveScriptWrappable::traceActiveScriptWrappables(
|
| +void ActiveScriptWrappableBase::traceActiveScriptWrappables(
|
| v8::Isolate* isolate,
|
| ScriptWrappableVisitor* visitor) {
|
| V8PerIsolateData* isolateData = V8PerIsolateData::from(isolate);
|
| @@ -33,6 +36,22 @@ void ActiveScriptWrappable::traceActiveScriptWrappables(
|
| continue;
|
| }
|
|
|
| + // A wrapper isn't kept alive if its ExecutionContext has become
|
| + // detached, even if hasPendingActivity() returns |true|. This avoids
|
| + // memory leaks and is acceptable lifetime handling as the HTML spec
|
| + // requires us to stop almost all DOM activities when the associated
|
| + // browsing context is detached.
|
| + //
|
| + // Consequently, an implementation of hasPendingActivity() is
|
| + // not required to take the detached state of the associated
|
| + // ExecutionContext into account (i.e., return |false|.) We probe
|
| + // the detached state of the ExecutionContext via
|
| + // |isContextDestroyed()|.
|
| + //
|
| + // TODO(haraken): Implement correct lifetime using traceWrapper.
|
| + if (activeWrappable->isContextDestroyed(activeWrappable)) {
|
| + continue;
|
| + }
|
| auto wrapperTypeInfo =
|
| const_cast<WrapperTypeInfo*>(scriptWrappable->wrapperTypeInfo());
|
| visitor->RegisterV8Reference(
|
|
|