Chromium Code Reviews| 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..c7b2fff7c0edc75081afceb49502b2b2c1561802 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,13 @@ void ActiveScriptWrappable::traceActiveScriptWrappables( |
| continue; |
| } |
| + // Do not keep the wrapper alive if the ExecutionContext |
| + // has become detached, irrespective of what hasPendingActivity() |
| + // returns. This is done to avoid memory leaks. see |
|
Michael Lippautz
2016/12/15 13:57:31
nit: Mind copying over the comment? This part of M
sof
2016/12/15 15:33:02
Blended in that comment. Even though we invoke has
|
| + // MajorGCWrapperVisitor::VisitPersistentHandle() comment. |
| + if (activeWrappable->isContextDestroyed(activeWrappable)) { |
| + continue; |
| + } |
| auto wrapperTypeInfo = |
| const_cast<WrapperTypeInfo*>(scriptWrappable->wrapperTypeInfo()); |
| visitor->RegisterV8Reference( |