| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 public: | 59 public: |
| 60 static PassRefPtr<DOMWrapperWorld> create(v8::Isolate*, int worldId = -1, in
t extensionGroup = -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(v8::Isolate*, int wor
ldId, int extensionGroup); | 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 } |
| 75 | 75 |
| 76 static DOMWrapperWorld& current(v8::Isolate* isolate) | 76 static DOMWrapperWorld& current(v8::Isolate* isolate) |
| 77 { | 77 { |
| 78 if (isMainThread() && worldOfInitializingWindow) { | 78 if (isMainThread() && worldOfInitializingWindow) { |
| 79 // It's possible that current() is being called while window is bein
g initialized. | 79 // It's possible that current() is being called while window is bein
g initialized. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 143 } |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 ScopedPersistent<v8::Value> m_wrapper; | 146 ScopedPersistent<v8::Value> m_wrapper; |
| 147 DOMWrapperWorld* m_world; | 147 DOMWrapperWorld* m_world; |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 template<typename T> | 150 template<typename T> |
| 151 class DOMObjectHolder : public DOMObjectHolderBase { | 151 class DOMObjectHolder : public DOMObjectHolderBase { |
| 152 public: | 152 public: |
| 153 static PassOwnPtr<DOMObjectHolder<T> > create(v8::Isolate* isolate, T* o
bject, v8::Handle<v8::Value> wrapper) | 153 static PassOwnPtr<DOMObjectHolder<T>> create(v8::Isolate* isolate, T* ob
ject, v8::Handle<v8::Value> wrapper) |
| 154 { | 154 { |
| 155 return adoptPtr(new DOMObjectHolder(isolate, object, wrapper)); | 155 return adoptPtr(new DOMObjectHolder(isolate, object, wrapper)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 DOMObjectHolder(v8::Isolate* isolate, T* object, v8::Handle<v8::Value> w
rapper) | 159 DOMObjectHolder(v8::Isolate* isolate, T* object, v8::Handle<v8::Value> w
rapper) |
| 160 : DOMObjectHolderBase(isolate, wrapper) | 160 : DOMObjectHolderBase(isolate, wrapper) |
| 161 , m_object(object) | 161 , m_object(object) |
| 162 { | 162 { |
| 163 } | 163 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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 |