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

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: Changes for Sami 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 // This function should not be called for IsolatedWorld because an
270 // identifier for the world is given from out of DOMWrapperWorld. 271 // identifier for the world is given from out of DOMWrapperWorld.
271 NOTREACHED(); 272 NOTREACHED();
272 return kInvalidWorldId; 273 return kInvalidWorldId;
273 case WorldType::kGarbageCollector: 274 case WorldType::kGarbageCollector:
274 case WorldType::kRegExp: 275 case WorldType::kRegExp:
275 case WorldType::kTesting: 276 case WorldType::kTesting:
276 case WorldType::kWorker: 277 case WorldType::kWorker:
277 int world_id = *next_world_id; 278 int world_id = *next_world_id;
278 CHECK_GE(world_id, WorldId::kUnspecifiedWorldIdStart); 279 CHECK_GE(world_id, WorldId::kUnspecifiedWorldIdStart);
279 *next_world_id = world_id + 1; 280 *next_world_id = world_id + 1;
280 return world_id; 281 return world_id;
281 } 282 }
282 NOTREACHED(); 283 NOTREACHED();
283 return kInvalidWorldId; 284 return kInvalidWorldId;
284 } 285 }
285 286
287 // static
288 int DOMWrapperWorld::GetNextDevToolsIsolatedWorldId() {
289 DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<int>,
pfeldman 2017/05/05 15:40:24 DCHECK(isMainThread()) + simpler static local inst
alex clarke (OOO till 29th) 2017/05/05 19:29:44 Done.
290 next_devtools_isolated_world_id,
291 new ThreadSpecific<int>);
292
293 if (!next_devtools_isolated_world_id.IsSet())
294 *next_devtools_isolated_world_id = WorldId::kDevToolsFirstIsolatedWorldId;
295 int world_id = *next_devtools_isolated_world_id;
296 if (world_id > WorldId::kDevToolsLastIsolatedWorldId)
297 return WorldId::kInvalidWorldId;
298 *next_devtools_isolated_world_id = world_id + 1;
299 return world_id;
300 }
301
286 void DOMWrapperWorld::DissociateDOMWindowWrappersInAllWorlds( 302 void DOMWrapperWorld::DissociateDOMWindowWrappersInAllWorlds(
287 ScriptWrappable* script_wrappable) { 303 ScriptWrappable* script_wrappable) {
288 DCHECK(script_wrappable); 304 DCHECK(script_wrappable);
289 DCHECK(IsMainThread()); 305 DCHECK(IsMainThread());
290 306
291 script_wrappable->UnsetWrapperIfAny(); 307 script_wrappable->UnsetWrapperIfAny();
292 308
293 for (auto& world : GetWorldMap().Values()) 309 for (auto& world : GetWorldMap().Values())
294 world->DomDataStore().UnsetWrapperIfAny(script_wrappable); 310 world->DomDataStore().UnsetWrapperIfAny(script_wrappable);
295 } 311 }
296 312
297 } // namespace blink 313 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698