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

Side by Side Diff: Source/bindings/v8/DOMWrapperWorld.cpp

Issue 182903003: Make DOMWrapperWorld::current() callable from workers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 23 matching lines...) Expand all
34 #include "V8Window.h" 34 #include "V8Window.h"
35 #include "bindings/v8/DOMDataStore.h" 35 #include "bindings/v8/DOMDataStore.h"
36 #include "bindings/v8/ScriptController.h" 36 #include "bindings/v8/ScriptController.h"
37 #include "bindings/v8/V8Binding.h" 37 #include "bindings/v8/V8Binding.h"
38 #include "bindings/v8/V8DOMActivityLogger.h" 38 #include "bindings/v8/V8DOMActivityLogger.h"
39 #include "bindings/v8/V8DOMWrapper.h" 39 #include "bindings/v8/V8DOMWrapper.h"
40 #include "bindings/v8/V8WindowShell.h" 40 #include "bindings/v8/V8WindowShell.h"
41 #include "bindings/v8/WrapperTypeInfo.h" 41 #include "bindings/v8/WrapperTypeInfo.h"
42 #include "core/dom/ExecutionContext.h" 42 #include "core/dom/ExecutionContext.h"
43 #include "wtf/HashTraits.h" 43 #include "wtf/HashTraits.h"
44 #include "wtf/MainThread.h"
45 #include "wtf/StdLibExtras.h" 44 #include "wtf/StdLibExtras.h"
46 45
47 namespace WebCore { 46 namespace WebCore {
48 47
49 unsigned DOMWrapperWorld::isolatedWorldCount = 0; 48 unsigned DOMWrapperWorld::isolatedWorldCount = 0;
49 DOMWrapperWorld* DOMWrapperWorld::worldOfInitializingWindow = 0;
50 50
51 PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::create(int worldId, int extensionGr oup) 51 PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::create(int worldId, int extensionGr oup)
52 { 52 {
53 return adoptRef(new DOMWrapperWorld(worldId, extensionGroup)); 53 return adoptRef(new DOMWrapperWorld(worldId, extensionGroup));
54 } 54 }
55 55
56 DOMWrapperWorld::DOMWrapperWorld(int worldId, int extensionGroup) 56 DOMWrapperWorld::DOMWrapperWorld(int worldId, int extensionGroup)
57 : m_worldId(worldId) 57 : m_worldId(worldId)
58 , m_extensionGroup(extensionGroup) 58 , m_extensionGroup(extensionGroup)
59 , m_domDataStore(adoptPtr(new DOMDataStore(isMainWorld()))) 59 , m_domDataStore(adoptPtr(new DOMDataStore(isMainWorld())))
60 { 60 {
61 } 61 }
62 62
63 DOMWrapperWorld* DOMWrapperWorld::current(v8::Isolate* isolate)
64 {
65 v8::Handle<v8::Context> context = isolate->GetCurrentContext();
66 if (context.IsEmpty() || !toDOMWindow(context))
67 return 0;
68 return world(context);
69 }
70
71 DOMWrapperWorld* DOMWrapperWorld::mainWorld() 63 DOMWrapperWorld* DOMWrapperWorld::mainWorld()
72 { 64 {
73 ASSERT(isMainThread()); 65 ASSERT(isMainThread());
74 DEFINE_STATIC_REF(DOMWrapperWorld, cachedMainWorld, (DOMWrapperWorld::create (MainWorldId, mainWorldExtensionGroup))); 66 DEFINE_STATIC_REF(DOMWrapperWorld, cachedMainWorld, (DOMWrapperWorld::create (MainWorldId, mainWorldExtensionGroup)));
75 return cachedMainWorld; 67 return cachedMainWorld;
76 } 68 }
77 69
78 typedef HashMap<int, DOMWrapperWorld*> WorldMap; 70 typedef HashMap<int, DOMWrapperWorld*> WorldMap;
79 static WorldMap& isolatedWorldMap() 71 static WorldMap& isolatedWorldMap()
80 { 72 {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 else 187 else
196 isolatedWorldContentSecurityPolicies().remove(worldId); 188 isolatedWorldContentSecurityPolicies().remove(worldId);
197 } 189 }
198 190
199 void DOMWrapperWorld::clearIsolatedWorldContentSecurityPolicy(int worldId) 191 void DOMWrapperWorld::clearIsolatedWorldContentSecurityPolicy(int worldId)
200 { 192 {
201 ASSERT(isIsolatedWorldId(worldId)); 193 ASSERT(isIsolatedWorldId(worldId));
202 isolatedWorldContentSecurityPolicies().remove(worldId); 194 isolatedWorldContentSecurityPolicies().remove(worldId);
203 } 195 }
204 196
205 bool DOMWrapperWorld::contextHasCorrectPrototype(v8::Handle<v8::Context> context )
206 {
207 return V8WindowShell::contextHasCorrectPrototype(context);
208 }
209
210 } // namespace WebCore 197 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698