| Index: third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp
|
| index eac486e780f17b6797abf8e05478a02b0de39fc8..0c43fadfa4bad3e9bab67a766ae98ff6ae61fa21 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp
|
| @@ -91,7 +91,11 @@ PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::create(v8::Isolate* isolate,
|
| DOMWrapperWorld::DOMWrapperWorld(v8::Isolate* isolate, int worldId)
|
| : m_worldId(worldId),
|
| m_domDataStore(
|
| - WTF::wrapUnique(new DOMDataStore(isolate, isMainWorld()))) {}
|
| + WTF::wrapUnique(new DOMDataStore(isolate, isMainWorld()))) {
|
| + if (worldId == WorkerWorldId) {
|
| + workerWorld() = this;
|
| + }
|
| +}
|
|
|
| DOMWrapperWorld& DOMWrapperWorld::mainWorld() {
|
| ASSERT(isMainThread());
|
| @@ -101,6 +105,12 @@ DOMWrapperWorld& DOMWrapperWorld::mainWorld() {
|
| return *cachedMainWorld;
|
| }
|
|
|
| +DOMWrapperWorld*& DOMWrapperWorld::workerWorld() {
|
| + DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<DOMWrapperWorld*>, workerWorld,
|
| + new ThreadSpecific<DOMWrapperWorld*>);
|
| + return *workerWorld;
|
| +}
|
| +
|
| PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::fromWorldId(v8::Isolate* isolate,
|
| int worldId) {
|
| if (worldId == MainWorldId)
|
| @@ -128,15 +138,19 @@ void DOMWrapperWorld::allWorldsInMainThread(
|
| void DOMWrapperWorld::markWrappersInAllWorlds(
|
| ScriptWrappable* scriptWrappable,
|
| const ScriptWrappableVisitor* visitor) {
|
| - // TODO(hlopko): Currently wrapper in one world will keep wrappers in all
|
| - // worlds alive (possibly holding on entire documents). This is neither
|
| - // needed (there is no way to get from one wrapper to another), nor wanted
|
| - // (big performance and memory overhead).
|
| + // Handle marking in per-worker wrapper worlds.
|
| + if (!isMainThread()) {
|
| + DCHECK(ThreadState::current()->isolate());
|
| + if (workerWorld()) {
|
| + DOMDataStore& dataStore = workerWorld()->domDataStore();
|
| + if (dataStore.containsWrapper(scriptWrappable)) {
|
| + dataStore.markWrapper(scriptWrappable);
|
| + }
|
| + }
|
| + return;
|
| + }
|
|
|
| - // Marking for the main world
|
| scriptWrappable->markWrapper(visitor);
|
| - if (!isMainThread())
|
| - return;
|
| WorldMap& isolatedWorlds = isolatedWorldMap();
|
| for (auto& world : isolatedWorlds.values()) {
|
| DOMDataStore& dataStore = world->domDataStore();
|
| @@ -173,6 +187,10 @@ DOMWrapperWorld::~DOMWrapperWorld() {
|
|
|
| dispose();
|
|
|
| + if (m_worldId == WorkerWorldId) {
|
| + workerWorld() = nullptr;
|
| + }
|
| +
|
| if (!isIsolatedWorld())
|
| return;
|
|
|
|
|