| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, int extensionGroup); | 60 static PassRefPtr<DOMWrapperWorld> create(int worldId, int extensionGroup); |
| 61 | 61 |
| 62 static const int mainWorldExtensionGroup = 0; | 62 static const int mainWorldExtensionGroup = 0; |
| 63 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int exte
nsionGroup); | 63 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int exte
nsionGroup); |
| 64 ~DOMWrapperWorld(); | 64 ~DOMWrapperWorld(); |
| 65 | 65 |
| 66 static bool isolatedWorldsExist() { return isolatedWorldCount; } | 66 static bool isolatedWorldsExist() { return isolatedWorldCount; } |
| 67 static bool isIsolatedWorldId(int worldId) { return worldId != MainWorldId &
& worldId != WorkerWorldId; } | |
| 68 static void getAllWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& world
s); | 67 static void getAllWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& world
s); |
| 69 | 68 |
| 70 // FIXME: Replace all call sites of isolatedWorld() with world(). | 69 // FIXME: Replace all call sites of isolatedWorld() with world(). |
| 71 static DOMWrapperWorld* isolatedWorld(v8::Handle<v8::Context> context) | 70 static DOMWrapperWorld* isolatedWorld(v8::Handle<v8::Context> context) |
| 72 { | 71 { |
| 73 ASSERT(contextHasCorrectPrototype(context)); | 72 ASSERT(contextHasCorrectPrototype(context)); |
| 74 DOMWrapperWorld* world = V8PerContextDataHolder::from(context)->world(); | 73 DOMWrapperWorld* world = V8PerContextDataHolder::from(context)->world(); |
| 75 return world->isIsolatedWorld() ? world : 0; | 74 return world->isIsolatedWorld() ? world : 0; |
| 76 } | 75 } |
| 77 | 76 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 108 // identifying the main world). | 107 // identifying the main world). |
| 109 static void setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLogger>); | 108 static void setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLogger>); |
| 110 static V8DOMActivityLogger* activityLogger(int worldId); | 109 static V8DOMActivityLogger* activityLogger(int worldId); |
| 111 | 110 |
| 112 bool isMainWorld() const { return m_worldId == MainWorldId; } | 111 bool isMainWorld() const { return m_worldId == MainWorldId; } |
| 113 bool isWorkerWorld() const { return m_worldId == WorkerWorldId; } | 112 bool isWorkerWorld() const { return m_worldId == WorkerWorldId; } |
| 114 bool isIsolatedWorld() const { return !isMainWorld() && !isWorkerWorld(); } | 113 bool isIsolatedWorld() const { return !isMainWorld() && !isWorkerWorld(); } |
| 115 | 114 |
| 116 int worldId() const { return m_worldId; } | 115 int worldId() const { return m_worldId; } |
| 117 int extensionGroup() const { return m_extensionGroup; } | 116 int extensionGroup() const { return m_extensionGroup; } |
| 118 v8::Handle<v8::Context> context(ScriptController&); | |
| 119 | |
| 120 DOMDataStore& domDataStore() { return *m_domDataStore; } | 117 DOMDataStore& domDataStore() { return *m_domDataStore; } |
| 121 | 118 |
| 122 private: | 119 private: |
| 123 static unsigned isolatedWorldCount; | 120 static unsigned isolatedWorldCount; |
| 124 | 121 |
| 125 DOMWrapperWorld(int worldId, int extensionGroup); | 122 DOMWrapperWorld(int worldId, int extensionGroup); |
| 126 static bool contextHasCorrectPrototype(v8::Handle<v8::Context>); | 123 static bool contextHasCorrectPrototype(v8::Handle<v8::Context>); |
| 127 | 124 |
| 128 const int m_worldId; | 125 const int m_worldId; |
| 129 const int m_extensionGroup; | 126 const int m_extensionGroup; |
| 130 OwnPtr<DOMDataStore> m_domDataStore; | 127 OwnPtr<DOMDataStore> m_domDataStore; |
| 131 }; | 128 }; |
| 132 | 129 |
| 133 } // namespace WebCore | 130 } // namespace WebCore |
| 134 | 131 |
| 135 #endif // DOMWrapperWorld_h | 132 #endif // DOMWrapperWorld_h |
| OLD | NEW |