| 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..0803547b11071f28a0ff26f402ce12ffb468b718 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 after its ExecutionContext becomes
|
| + // detached, even if hasPendingActivity() returns |true|. This measure
|
| + // avoids memory leaks and has proven not to be too eager wrt
|
| + // garbage collection of objects belonging to discarded browser contexts
|
| + // ( https://html.spec.whatwg.org/#a-browsing-context-is-discarded )
|
| + //
|
| + // 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(
|
|
|