Index: third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h |
diff --git a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h |
index 4970d3eb581defda0a55c13184f2e83fd9c5ecb4..9c5f2751194a1596425f308676f69b0f7f6838a8 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h |
+++ b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h |
@@ -45,23 +45,35 @@ namespace blink { |
class DOMDataStore; |
-enum WorldIdConstants { |
+// Per-thread global identifiers for DOMWrapperWorld. |
+enum WorldIdSpace { |
peria
2017/03/08 09:48:19
Can you move this enum into DOMWrapperWorld class?
nhiroki
2017/03/08 10:24:53
Done.
|
+ UnknownWorldId = -1, |
MainWorldId = 0, |
// Embedder isolated worlds can use IDs in [1, 1<<29). |
EmbedderWorldIdLimit = (1 << 29), |
DocumentXMLTreeViewerWorldId, |
IsolatedWorldIdLimit, |
WorkerWorldId, |
- TestingWorldId, |
+}; |
+ |
+enum class WorldType { |
+ Unknown, |
+ Main, |
+ Isolated, |
+ Worker, |
}; |
class DOMObjectHolderBase; |
-// This class represent a collection of DOM wrappers for a specific world. |
+// This class represent a collection of DOM wrappers for a specific world. This |
+// is identified by a world id that is a per-thread global identifier (see |
+// WorldIdSpace above). |
class CORE_EXPORT DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { |
public: |
- static PassRefPtr<DOMWrapperWorld> create(v8::Isolate*, int worldId = -1); |
+ // Creates a world other than IsolatedWorld. |
+ static PassRefPtr<DOMWrapperWorld> create(v8::Isolate*, WorldType); |
+ // Ensures an IsolatedWorld for |worldId|. |
static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(v8::Isolate*, |
int worldId); |
~DOMWrapperWorld(); |
@@ -106,11 +118,9 @@ class CORE_EXPORT DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { |
const String& policy); |
bool isolatedWorldHasContentSecurityPolicy(); |
- bool isMainWorld() const { return m_worldId == MainWorldId; } |
- bool isWorkerWorld() const { return m_worldId == WorkerWorldId; } |
- bool isIsolatedWorld() const { |
- return MainWorldId < m_worldId && m_worldId < IsolatedWorldIdLimit; |
- } |
+ bool isMainWorld() const { return m_worldType == WorldType::Main; } |
+ bool isWorkerWorld() const { return m_worldType == WorldType::Worker; } |
+ bool isIsolatedWorld() const { return m_worldType == WorldType::Isolated; } |
int worldId() const { return m_worldId; } |
DOMDataStore& domDataStore() const { return *m_domDataStore; } |
@@ -120,7 +130,7 @@ class CORE_EXPORT DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { |
void registerDOMObjectHolder(v8::Isolate*, T*, v8::Local<v8::Value>); |
private: |
- DOMWrapperWorld(v8::Isolate*, int worldId); |
+ DOMWrapperWorld(v8::Isolate*, WorldType, int worldId); |
static void weakCallbackForDOMObjectHolder( |
const v8::WeakCallbackInfo<DOMObjectHolderBase>&); |
@@ -129,6 +139,7 @@ class CORE_EXPORT DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { |
static unsigned isolatedWorldCount; |
+ const WorldType m_worldType; |
const int m_worldId; |
std::unique_ptr<DOMDataStore> m_domDataStore; |
HashSet<std::unique_ptr<DOMObjectHolderBase>> m_domObjectHolders; |