| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "bindings/core/v8/WrapperTypeInfo.h" | 41 #include "bindings/core/v8/WrapperTypeInfo.h" |
| 42 #include "core/dom/ExecutionContext.h" | 42 #include "core/dom/ExecutionContext.h" |
| 43 #include "wtf/HashTraits.h" | 43 #include "wtf/HashTraits.h" |
| 44 #include "wtf/StdLibExtras.h" | 44 #include "wtf/StdLibExtras.h" |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 unsigned DOMWrapperWorld::isolatedWorldCount = 0; | 48 unsigned DOMWrapperWorld::isolatedWorldCount = 0; |
| 49 DOMWrapperWorld* DOMWrapperWorld::worldOfInitializingWindow = 0; | 49 DOMWrapperWorld* DOMWrapperWorld::worldOfInitializingWindow = 0; |
| 50 | 50 |
| 51 PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::create(int worldId, int extensionGr
oup) | 51 PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::create(v8::Isolate* isolate, int wo
rldId, int extensionGroup) |
| 52 { | 52 { |
| 53 return adoptRef(new DOMWrapperWorld(worldId, extensionGroup)); | 53 return adoptRef(new DOMWrapperWorld(isolate, worldId, extensionGroup)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 DOMWrapperWorld::DOMWrapperWorld(int worldId, int extensionGroup) | 56 DOMWrapperWorld::DOMWrapperWorld(v8::Isolate* isolate, int worldId, int extensio
nGroup) |
| 57 : m_worldId(worldId) | 57 : m_worldId(worldId) |
| 58 , m_extensionGroup(extensionGroup) | 58 , m_extensionGroup(extensionGroup) |
| 59 , m_domDataStore(adoptPtr(new DOMDataStore(isMainWorld()))) | 59 , m_domDataStore(adoptPtr(new DOMDataStore(isolate, isMainWorld()))) |
| 60 { | 60 { |
| 61 } | 61 } |
| 62 | 62 |
| 63 DOMWrapperWorld& DOMWrapperWorld::mainWorld() | 63 DOMWrapperWorld& DOMWrapperWorld::mainWorld() |
| 64 { | 64 { |
| 65 ASSERT(isMainThread()); | 65 ASSERT(isMainThread()); |
| 66 DEFINE_STATIC_REF(DOMWrapperWorld, cachedMainWorld, (DOMWrapperWorld::create
(MainWorldId, mainWorldExtensionGroup))); | 66 DEFINE_STATIC_REF(DOMWrapperWorld, cachedMainWorld, (DOMWrapperWorld::create
(v8::Isolate::GetCurrent(), MainWorldId, mainWorldExtensionGroup))); |
| 67 return *cachedMainWorld; | 67 return *cachedMainWorld; |
| 68 } | 68 } |
| 69 | 69 |
| 70 DOMWrapperWorld& DOMWrapperWorld::privateScriptIsolatedWorld() | 70 DOMWrapperWorld& DOMWrapperWorld::privateScriptIsolatedWorld() |
| 71 { | 71 { |
| 72 ASSERT(isMainThread()); | 72 ASSERT(isMainThread()); |
| 73 DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, cachedPrivateScriptIsolatedWorl
d, ()); | 73 DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, cachedPrivateScriptIsolatedWorl
d, ()); |
| 74 if (!cachedPrivateScriptIsolatedWorld) { | 74 if (!cachedPrivateScriptIsolatedWorld) { |
| 75 cachedPrivateScriptIsolatedWorld = DOMWrapperWorld::create(PrivateScript
IsolatedWorldId, privateScriptIsolatedWorldExtensionGroup); | 75 cachedPrivateScriptIsolatedWorld = DOMWrapperWorld::create(v8::Isolate::
GetCurrent(), PrivateScriptIsolatedWorldId, privateScriptIsolatedWorldExtensionG
roup); |
| 76 isolatedWorldCount++; | 76 isolatedWorldCount++; |
| 77 } | 77 } |
| 78 return *cachedPrivateScriptIsolatedWorld; | 78 return *cachedPrivateScriptIsolatedWorld; |
| 79 } | 79 } |
| 80 | 80 |
| 81 typedef HashMap<int, DOMWrapperWorld*> WorldMap; | 81 typedef HashMap<int, DOMWrapperWorld*> WorldMap; |
| 82 static WorldMap& isolatedWorldMap() | 82 static WorldMap& isolatedWorldMap() |
| 83 { | 83 { |
| 84 ASSERT(isMainThread()); | 84 ASSERT(isMainThread()); |
| 85 DEFINE_STATIC_LOCAL(WorldMap, map, ()); | 85 DEFINE_STATIC_LOCAL(WorldMap, map, ()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 m_domDataStore.clear(); | 122 m_domDataStore.clear(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 #if ENABLE(ASSERT) | 125 #if ENABLE(ASSERT) |
| 126 static bool isIsolatedWorldId(int worldId) | 126 static bool isIsolatedWorldId(int worldId) |
| 127 { | 127 { |
| 128 return MainWorldId < worldId && worldId < IsolatedWorldIdLimit; | 128 return MainWorldId < worldId && worldId < IsolatedWorldIdLimit; |
| 129 } | 129 } |
| 130 #endif | 130 #endif |
| 131 | 131 |
| 132 PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::ensureIsolatedWorld(int worldId, in
t extensionGroup) | 132 PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::ensureIsolatedWorld(v8::Isolate* is
olate, int worldId, int extensionGroup) |
| 133 { | 133 { |
| 134 ASSERT(isIsolatedWorldId(worldId)); | 134 ASSERT(isIsolatedWorldId(worldId)); |
| 135 | 135 |
| 136 WorldMap& map = isolatedWorldMap(); | 136 WorldMap& map = isolatedWorldMap(); |
| 137 WorldMap::AddResult result = map.add(worldId, 0); | 137 WorldMap::AddResult result = map.add(worldId, 0); |
| 138 RefPtr<DOMWrapperWorld> world = result.storedValue->value; | 138 RefPtr<DOMWrapperWorld> world = result.storedValue->value; |
| 139 if (world) { | 139 if (world) { |
| 140 ASSERT(world->worldId() == worldId); | 140 ASSERT(world->worldId() == worldId); |
| 141 ASSERT(world->extensionGroup() == extensionGroup); | 141 ASSERT(world->extensionGroup() == extensionGroup); |
| 142 return world.release(); | 142 return world.release(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 world = DOMWrapperWorld::create(worldId, extensionGroup); | 145 world = DOMWrapperWorld::create(isolate, worldId, extensionGroup); |
| 146 result.storedValue->value = world.get(); | 146 result.storedValue->value = world.get(); |
| 147 isolatedWorldCount++; | 147 isolatedWorldCount++; |
| 148 return world.release(); | 148 return world.release(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 typedef HashMap<int, RefPtr<SecurityOrigin> > IsolatedWorldSecurityOriginMap; | 151 typedef HashMap<int, RefPtr<SecurityOrigin> > IsolatedWorldSecurityOriginMap; |
| 152 static IsolatedWorldSecurityOriginMap& isolatedWorldSecurityOrigins() | 152 static IsolatedWorldSecurityOriginMap& isolatedWorldSecurityOrigins() |
| 153 { | 153 { |
| 154 ASSERT(isMainThread()); | 154 ASSERT(isMainThread()); |
| 155 DEFINE_STATIC_LOCAL(IsolatedWorldSecurityOriginMap, map, ()); | 155 DEFINE_STATIC_LOCAL(IsolatedWorldSecurityOriginMap, map, ()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 m_domObjectHolders.remove(holderBase); | 232 m_domObjectHolders.remove(holderBase); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void DOMWrapperWorld::weakCallbackForDOMObjectHolder(const v8::WeakCallbackData<
v8::Value, DOMObjectHolderBase>& data) | 235 void DOMWrapperWorld::weakCallbackForDOMObjectHolder(const v8::WeakCallbackData<
v8::Value, DOMObjectHolderBase>& data) |
| 236 { | 236 { |
| 237 DOMObjectHolderBase* holderBase = data.GetParameter(); | 237 DOMObjectHolderBase* holderBase = data.GetParameter(); |
| 238 holderBase->world()->unregisterDOMObjectHolder(holderBase); | 238 holderBase->world()->unregisterDOMObjectHolder(holderBase); |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace blink | 241 } // namespace blink |
| OLD | NEW |