| 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 23 matching lines...) Expand all Loading... |
| 34 #include "V8Window.h" | 34 #include "V8Window.h" |
| 35 #include "bindings/v8/DOMDataStore.h" | 35 #include "bindings/v8/DOMDataStore.h" |
| 36 #include "bindings/v8/ScriptController.h" | 36 #include "bindings/v8/ScriptController.h" |
| 37 #include "bindings/v8/V8Binding.h" | 37 #include "bindings/v8/V8Binding.h" |
| 38 #include "bindings/v8/V8DOMActivityLogger.h" | 38 #include "bindings/v8/V8DOMActivityLogger.h" |
| 39 #include "bindings/v8/V8DOMWrapper.h" | 39 #include "bindings/v8/V8DOMWrapper.h" |
| 40 #include "bindings/v8/V8WindowShell.h" | 40 #include "bindings/v8/V8WindowShell.h" |
| 41 #include "bindings/v8/WrapperTypeInfo.h" | 41 #include "bindings/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/MainThread.h" | |
| 45 #include "wtf/StdLibExtras.h" | 44 #include "wtf/StdLibExtras.h" |
| 46 | 45 |
| 47 namespace WebCore { | 46 namespace WebCore { |
| 48 | 47 |
| 49 unsigned DOMWrapperWorld::isolatedWorldCount = 0; | 48 unsigned DOMWrapperWorld::isolatedWorldCount = 0; |
| 49 DOMWrapperWorld* DOMWrapperWorld::worldOfInitializingWindow = 0; |
| 50 | 50 |
| 51 PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::create(int worldId, int extensionGr
oup) | 51 PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::create(int worldId, int extensionGr
oup) |
| 52 { | 52 { |
| 53 return adoptRef(new DOMWrapperWorld(worldId, extensionGroup)); | 53 return adoptRef(new DOMWrapperWorld(worldId, extensionGroup)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 DOMWrapperWorld::DOMWrapperWorld(int worldId, int extensionGroup) | 56 DOMWrapperWorld::DOMWrapperWorld(int worldId, int extensionGroup) |
| 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(isMainWorld()))) |
| 60 { | 60 { |
| 61 } | 61 } |
| 62 | 62 |
| 63 DOMWrapperWorld* DOMWrapperWorld::current(v8::Isolate* isolate) | |
| 64 { | |
| 65 v8::Handle<v8::Context> context = isolate->GetCurrentContext(); | |
| 66 if (context.IsEmpty() || !toDOMWindow(context)) | |
| 67 return 0; | |
| 68 return world(context); | |
| 69 } | |
| 70 | |
| 71 DOMWrapperWorld* DOMWrapperWorld::mainWorld() | 63 DOMWrapperWorld* DOMWrapperWorld::mainWorld() |
| 72 { | 64 { |
| 73 ASSERT(isMainThread()); | 65 ASSERT(isMainThread()); |
| 74 DEFINE_STATIC_REF(DOMWrapperWorld, cachedMainWorld, (DOMWrapperWorld::create
(MainWorldId, mainWorldExtensionGroup))); | 66 DEFINE_STATIC_REF(DOMWrapperWorld, cachedMainWorld, (DOMWrapperWorld::create
(MainWorldId, mainWorldExtensionGroup))); |
| 75 return cachedMainWorld; | 67 return cachedMainWorld; |
| 76 } | 68 } |
| 77 | 69 |
| 78 typedef HashMap<int, DOMWrapperWorld*> WorldMap; | 70 typedef HashMap<int, DOMWrapperWorld*> WorldMap; |
| 79 static WorldMap& isolatedWorldMap() | 71 static WorldMap& isolatedWorldMap() |
| 80 { | 72 { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 domActivityLoggers().set(worldId, logger); | 207 domActivityLoggers().set(worldId, logger); |
| 216 } | 208 } |
| 217 | 209 |
| 218 V8DOMActivityLogger* DOMWrapperWorld::activityLogger(int worldId) | 210 V8DOMActivityLogger* DOMWrapperWorld::activityLogger(int worldId) |
| 219 { | 211 { |
| 220 DOMActivityLoggerMap& loggers = domActivityLoggers(); | 212 DOMActivityLoggerMap& loggers = domActivityLoggers(); |
| 221 DOMActivityLoggerMap::iterator it = loggers.find(worldId); | 213 DOMActivityLoggerMap::iterator it = loggers.find(worldId); |
| 222 return it == loggers.end() ? 0 : it->value.get(); | 214 return it == loggers.end() ? 0 : it->value.get(); |
| 223 } | 215 } |
| 224 | 216 |
| 225 bool DOMWrapperWorld::contextHasCorrectPrototype(v8::Handle<v8::Context> context
) | |
| 226 { | |
| 227 return V8WindowShell::contextHasCorrectPrototype(context); | |
| 228 } | |
| 229 | |
| 230 } // namespace WebCore | 217 } // namespace WebCore |
| OLD | NEW |