| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 ScriptPreprocessorIsolatedWorldId, | 50 ScriptPreprocessorIsolatedWorldId, |
| 51 PrivateScriptIsolatedWorldId, | 51 PrivateScriptIsolatedWorldId, |
| 52 IsolatedWorldIdLimit, | 52 IsolatedWorldIdLimit, |
| 53 WorkerWorldId, | 53 WorkerWorldId, |
| 54 TestingWorldId, | 54 TestingWorldId, |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 // This class represent a collection of DOM wrappers for a specific world. | 57 // This class represent a collection of DOM wrappers for a specific world. |
| 58 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { | 58 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { |
| 59 public: | 59 public: |
| 60 static PassRefPtr<DOMWrapperWorld> create(int worldId = -1, int extensionGro
up = -1); | 60 static PassRefPtr<DOMWrapperWorld> create(v8::Isolate*, int worldId = -1, in
t extensionGroup = -1); |
| 61 | 61 |
| 62 static const int mainWorldExtensionGroup = 0; | 62 static const int mainWorldExtensionGroup = 0; |
| 63 static const int privateScriptIsolatedWorldExtensionGroup = 1; | 63 static const int privateScriptIsolatedWorldExtensionGroup = 1; |
| 64 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int exte
nsionGroup); | 64 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(v8::Isolate*, int wor
ldId, int extensionGroup); |
| 65 ~DOMWrapperWorld(); | 65 ~DOMWrapperWorld(); |
| 66 void dispose(); | 66 void dispose(); |
| 67 | 67 |
| 68 static bool isolatedWorldsExist() { return isolatedWorldCount; } | 68 static bool isolatedWorldsExist() { return isolatedWorldCount; } |
| 69 static void allWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds); | 69 static void allWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds); |
| 70 | 70 |
| 71 static DOMWrapperWorld& world(v8::Handle<v8::Context> context) | 71 static DOMWrapperWorld& world(v8::Handle<v8::Context> context) |
| 72 { | 72 { |
| 73 return ScriptState::from(context)->world(); | 73 return ScriptState::from(context)->world(); |
| 74 } | 74 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 public: | 168 public: |
| 169 template<typename T> | 169 template<typename T> |
| 170 void registerDOMObjectHolder(v8::Isolate* isolate, T* object, v8::Handle<v8:
:Value> wrapper) | 170 void registerDOMObjectHolder(v8::Isolate* isolate, T* object, v8::Handle<v8:
:Value> wrapper) |
| 171 { | 171 { |
| 172 registerDOMObjectHolderInternal(DOMObjectHolder<T>::create(isolate, obje
ct, wrapper)); | 172 registerDOMObjectHolderInternal(DOMObjectHolder<T>::create(isolate, obje
ct, wrapper)); |
| 173 } | 173 } |
| 174 | 174 |
| 175 private: | 175 private: |
| 176 DOMWrapperWorld(int worldId, int extensionGroup); | 176 DOMWrapperWorld(v8::Isolate*, int worldId, int extensionGroup); |
| 177 | 177 |
| 178 static void weakCallbackForDOMObjectHolder(const v8::WeakCallbackData<v8::Va
lue, DOMObjectHolderBase>&); | 178 static void weakCallbackForDOMObjectHolder(const v8::WeakCallbackData<v8::Va
lue, DOMObjectHolderBase>&); |
| 179 void registerDOMObjectHolderInternal(PassOwnPtr<DOMObjectHolderBase>); | 179 void registerDOMObjectHolderInternal(PassOwnPtr<DOMObjectHolderBase>); |
| 180 void unregisterDOMObjectHolder(DOMObjectHolderBase*); | 180 void unregisterDOMObjectHolder(DOMObjectHolderBase*); |
| 181 | 181 |
| 182 static unsigned isolatedWorldCount; | 182 static unsigned isolatedWorldCount; |
| 183 static DOMWrapperWorld* worldOfInitializingWindow; | 183 static DOMWrapperWorld* worldOfInitializingWindow; |
| 184 | 184 |
| 185 const int m_worldId; | 185 const int m_worldId; |
| 186 const int m_extensionGroup; | 186 const int m_extensionGroup; |
| 187 OwnPtr<DOMDataStore> m_domDataStore; | 187 OwnPtr<DOMDataStore> m_domDataStore; |
| 188 HashSet<OwnPtr<DOMObjectHolderBase> > m_domObjectHolders; | 188 HashSet<OwnPtr<DOMObjectHolderBase> > m_domObjectHolders; |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 } // namespace blink | 191 } // namespace blink |
| 192 | 192 |
| 193 #endif // DOMWrapperWorld_h | 193 #endif // DOMWrapperWorld_h |
| OLD | NEW |