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

Side by Side 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 unified diff | Download patch
OLDNEW
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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 DCHECK(dom_object_holders_.Contains(holder_base)); 250 DCHECK(dom_object_holders_.Contains(holder_base));
251 dom_object_holders_.erase(holder_base); 251 dom_object_holders_.erase(holder_base);
252 } 252 }
253 253
254 void DOMWrapperWorld::WeakCallbackForDOMObjectHolder( 254 void DOMWrapperWorld::WeakCallbackForDOMObjectHolder(
255 const v8::WeakCallbackInfo<DOMObjectHolderBase>& data) { 255 const v8::WeakCallbackInfo<DOMObjectHolderBase>& data) {
256 DOMObjectHolderBase* holder_base = data.GetParameter(); 256 DOMObjectHolderBase* holder_base = data.GetParameter();
257 holder_base->World()->UnregisterDOMObjectHolder(holder_base); 257 holder_base->World()->UnregisterDOMObjectHolder(holder_base);
258 } 258 }
259 259
260 // static
260 int DOMWrapperWorld::GenerateWorldIdForType(WorldType world_type) { 261 int DOMWrapperWorld::GenerateWorldIdForType(WorldType world_type) {
261 DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<int>, next_world_id, 262 DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<int>, next_world_id,
262 new ThreadSpecific<int>); 263 new ThreadSpecific<int>);
263 if (!next_world_id.IsSet()) 264 if (!next_world_id.IsSet())
264 *next_world_id = WorldId::kUnspecifiedWorldIdStart; 265 *next_world_id = WorldId::kUnspecifiedWorldIdStart;
265 switch (world_type) { 266 switch (world_type) {
266 case WorldType::kMain: 267 case WorldType::kMain:
267 return kMainWorldId; 268 return kMainWorldId;
268 case WorldType::kIsolated: 269 case WorldType::kIsolated:
269 // This function should not be called for IsolatedWorld because an 270 return GetNextDevToolsIsolatedWorldId();
270 // identifier for the world is given from out of DOMWrapperWorld.
271 NOTREACHED();
272 return kInvalidWorldId;
273 case WorldType::kGarbageCollector: 271 case WorldType::kGarbageCollector:
274 case WorldType::kRegExp: 272 case WorldType::kRegExp:
275 case WorldType::kTesting: 273 case WorldType::kTesting:
276 case WorldType::kWorker: 274 case WorldType::kWorker:
277 int world_id = *next_world_id; 275 int world_id = *next_world_id;
278 CHECK_GE(world_id, WorldId::kUnspecifiedWorldIdStart); 276 CHECK_GE(world_id, WorldId::kUnspecifiedWorldIdStart);
279 *next_world_id = world_id + 1; 277 *next_world_id = world_id + 1;
280 return world_id; 278 return world_id;
281 } 279 }
282 NOTREACHED(); 280 NOTREACHED();
283 return kInvalidWorldId; 281 return kInvalidWorldId;
284 } 282 }
285 283
284 // static
285 int DOMWrapperWorld::GetNextDevToolsIsolatedWorldId() {
286 DCHECK(IsMainThread());
287 static int next_devtools_isolated_world_id =
288 WorldId::kDevToolsFirstIsolatedWorldId;
289 if (next_devtools_isolated_world_id > WorldId::kDevToolsLastIsolatedWorldId)
290 return WorldId::kInvalidWorldId;
291 return next_devtools_isolated_world_id++;
292 }
293
286 void DOMWrapperWorld::DissociateDOMWindowWrappersInAllWorlds( 294 void DOMWrapperWorld::DissociateDOMWindowWrappersInAllWorlds(
287 ScriptWrappable* script_wrappable) { 295 ScriptWrappable* script_wrappable) {
288 DCHECK(script_wrappable); 296 DCHECK(script_wrappable);
289 DCHECK(IsMainThread()); 297 DCHECK(IsMainThread());
290 298
291 script_wrappable->UnsetWrapperIfAny(); 299 script_wrappable->UnsetWrapperIfAny();
292 300
293 for (auto& world : GetWorldMap().Values()) 301 for (auto& world : GetWorldMap().Values())
294 world->DomDataStore().UnsetWrapperIfAny(script_wrappable); 302 world->DomDataStore().UnsetWrapperIfAny(script_wrappable);
295 } 303 }
296 304
297 } // namespace blink 305 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698