Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1035)

Unified Diff: third_party/WebKit/Source/platform/bindings/DOMWrapperWorld.cpp

Issue 2848653003: Add a DevTools command to create an isolated world for a given frame (Closed)
Patch Set: Fix test Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/bindings/DOMWrapperWorld.cpp
diff --git a/third_party/WebKit/Source/platform/bindings/DOMWrapperWorld.cpp b/third_party/WebKit/Source/platform/bindings/DOMWrapperWorld.cpp
index 106f9d359a1550d98dddc8b8e51e0a908a22a18f..edcc075b19ea6b545bf4fc1e4cff091d270a0809 100644
--- a/third_party/WebKit/Source/platform/bindings/DOMWrapperWorld.cpp
+++ b/third_party/WebKit/Source/platform/bindings/DOMWrapperWorld.cpp
@@ -257,6 +257,7 @@ void DOMWrapperWorld::WeakCallbackForDOMObjectHolder(
holder_base->World()->UnregisterDOMObjectHolder(holder_base);
}
+// static
int DOMWrapperWorld::GenerateWorldIdForType(WorldType world_type) {
DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<int>, next_world_id,
new ThreadSpecific<int>);
@@ -266,10 +267,7 @@ int DOMWrapperWorld::GenerateWorldIdForType(WorldType world_type) {
case WorldType::kMain:
return kMainWorldId;
case WorldType::kIsolated:
- // This function should not be called for IsolatedWorld because an
- // identifier for the world is given from out of DOMWrapperWorld.
- NOTREACHED();
- return kInvalidWorldId;
+ return GetNextDevToolsIsolatedWorldId();
case WorldType::kGarbageCollector:
case WorldType::kRegExp:
case WorldType::kTesting:
@@ -283,6 +281,16 @@ int DOMWrapperWorld::GenerateWorldIdForType(WorldType world_type) {
return kInvalidWorldId;
}
+// static
+int DOMWrapperWorld::GetNextDevToolsIsolatedWorldId() {
+ DCHECK(IsMainThread());
+ static int next_devtools_isolated_world_id =
+ WorldId::kDevToolsFirstIsolatedWorldId;
+ if (next_devtools_isolated_world_id > WorldId::kDevToolsLastIsolatedWorldId)
+ return WorldId::kInvalidWorldId;
+ return next_devtools_isolated_world_id++;
+}
+
void DOMWrapperWorld::DissociateDOMWindowWrappersInAllWorlds(
ScriptWrappable* script_wrappable) {
DCHECK(script_wrappable);

Powered by Google App Engine
This is Rietveld 408576698