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

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

Issue 168583005: Remove DOMWrapperWorld::isIsolatedWorldId and DOMWrapperWorld::context (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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
« no previous file with comments | « Source/bindings/v8/DOMWrapperWorld.h ('k') | Source/bindings/v8/PageScriptDebugServer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ASSERT_NOT_REACHED(); 112 ASSERT_NOT_REACHED();
113 return; 113 return;
114 } 114 }
115 ASSERT(i->value == this); 115 ASSERT(i->value == this);
116 116
117 map.remove(i); 117 map.remove(i);
118 isolatedWorldCount--; 118 isolatedWorldCount--;
119 ASSERT(map.size() == isolatedWorldCount); 119 ASSERT(map.size() == isolatedWorldCount);
120 } 120 }
121 121
122 #ifndef NDEBUG
123 static bool isIsolatedWorldId(int worldId)
124 {
125 return worldId != MainWorldId && worldId != WorkerWorldId;
126 }
127 #endif
128
122 PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::ensureIsolatedWorld(int worldId, in t extensionGroup) 129 PassRefPtr<DOMWrapperWorld> DOMWrapperWorld::ensureIsolatedWorld(int worldId, in t extensionGroup)
123 { 130 {
124 ASSERT(isIsolatedWorldId(worldId)); 131 ASSERT(isIsolatedWorldId(worldId));
125 132
126 WorldMap& map = isolatedWorldMap(); 133 WorldMap& map = isolatedWorldMap();
127 WorldMap::AddResult result = map.add(worldId, 0); 134 WorldMap::AddResult result = map.add(worldId, 0);
128 RefPtr<DOMWrapperWorld> world = result.storedValue->value; 135 RefPtr<DOMWrapperWorld> world = result.storedValue->value;
129 if (world) { 136 if (world) {
130 ASSERT(world->worldId() == worldId); 137 ASSERT(world->worldId() == worldId);
131 ASSERT(world->extensionGroup() == extensionGroup); 138 ASSERT(world->extensionGroup() == extensionGroup);
132 return world.release(); 139 return world.release();
133 } 140 }
134 141
135 world = DOMWrapperWorld::create(worldId, extensionGroup); 142 world = DOMWrapperWorld::create(worldId, extensionGroup);
136 result.storedValue->value = world.get(); 143 result.storedValue->value = world.get();
137 isolatedWorldCount++; 144 isolatedWorldCount++;
138 ASSERT(map.size() == isolatedWorldCount); 145 ASSERT(map.size() == isolatedWorldCount);
139 146
140 return world.release(); 147 return world.release();
141 } 148 }
142 149
143 v8::Handle<v8::Context> DOMWrapperWorld::context(ScriptController& controller)
144 {
145 return controller.windowShell(this)->context();
146 }
147
148 typedef HashMap<int, RefPtr<SecurityOrigin> > IsolatedWorldSecurityOriginMap; 150 typedef HashMap<int, RefPtr<SecurityOrigin> > IsolatedWorldSecurityOriginMap;
149 static IsolatedWorldSecurityOriginMap& isolatedWorldSecurityOrigins() 151 static IsolatedWorldSecurityOriginMap& isolatedWorldSecurityOrigins()
150 { 152 {
151 ASSERT(isMainThread()); 153 ASSERT(isMainThread());
152 DEFINE_STATIC_LOCAL(IsolatedWorldSecurityOriginMap, map, ()); 154 DEFINE_STATIC_LOCAL(IsolatedWorldSecurityOriginMap, map, ());
153 return map; 155 return map;
154 } 156 }
155 157
156 SecurityOrigin* DOMWrapperWorld::isolatedWorldSecurityOrigin() 158 SecurityOrigin* DOMWrapperWorld::isolatedWorldSecurityOrigin()
157 { 159 {
158 ASSERT(this->isIsolatedWorld()); 160 ASSERT(this->isIsolatedWorld());
159 IsolatedWorldSecurityOriginMap& origins = isolatedWorldSecurityOrigins(); 161 IsolatedWorldSecurityOriginMap& origins = isolatedWorldSecurityOrigins();
160 IsolatedWorldSecurityOriginMap::iterator it = origins.find(worldId()); 162 IsolatedWorldSecurityOriginMap::iterator it = origins.find(worldId());
161 return it == origins.end() ? 0 : it->value.get(); 163 return it == origins.end() ? 0 : it->value.get();
162 } 164 }
163 165
164 void DOMWrapperWorld::setIsolatedWorldSecurityOrigin(int worldId, PassRefPtr<Sec urityOrigin> securityOrigin) 166 void DOMWrapperWorld::setIsolatedWorldSecurityOrigin(int worldId, PassRefPtr<Sec urityOrigin> securityOrigin)
165 { 167 {
166 ASSERT(DOMWrapperWorld::isIsolatedWorldId(worldId)); 168 ASSERT(isIsolatedWorldId(worldId));
167 if (securityOrigin) 169 if (securityOrigin)
168 isolatedWorldSecurityOrigins().set(worldId, securityOrigin); 170 isolatedWorldSecurityOrigins().set(worldId, securityOrigin);
169 else 171 else
170 isolatedWorldSecurityOrigins().remove(worldId); 172 isolatedWorldSecurityOrigins().remove(worldId);
171 } 173 }
172 174
173 void DOMWrapperWorld::clearIsolatedWorldSecurityOrigin(int worldId) 175 void DOMWrapperWorld::clearIsolatedWorldSecurityOrigin(int worldId)
174 { 176 {
175 ASSERT(DOMWrapperWorld::isIsolatedWorldId(worldId)); 177 ASSERT(isIsolatedWorldId(worldId));
176 isolatedWorldSecurityOrigins().remove(worldId); 178 isolatedWorldSecurityOrigins().remove(worldId);
177 } 179 }
178 180
179 typedef HashMap<int, bool> IsolatedWorldContentSecurityPolicyMap; 181 typedef HashMap<int, bool> IsolatedWorldContentSecurityPolicyMap;
180 static IsolatedWorldContentSecurityPolicyMap& isolatedWorldContentSecurityPolici es() 182 static IsolatedWorldContentSecurityPolicyMap& isolatedWorldContentSecurityPolici es()
181 { 183 {
182 ASSERT(isMainThread()); 184 ASSERT(isMainThread());
183 DEFINE_STATIC_LOCAL(IsolatedWorldContentSecurityPolicyMap, map, ()); 185 DEFINE_STATIC_LOCAL(IsolatedWorldContentSecurityPolicyMap, map, ());
184 return map; 186 return map;
185 } 187 }
186 188
187 bool DOMWrapperWorld::isolatedWorldHasContentSecurityPolicy() 189 bool DOMWrapperWorld::isolatedWorldHasContentSecurityPolicy()
188 { 190 {
189 ASSERT(this->isIsolatedWorld()); 191 ASSERT(this->isIsolatedWorld());
190 IsolatedWorldContentSecurityPolicyMap& policies = isolatedWorldContentSecuri tyPolicies(); 192 IsolatedWorldContentSecurityPolicyMap& policies = isolatedWorldContentSecuri tyPolicies();
191 IsolatedWorldContentSecurityPolicyMap::iterator it = policies.find(worldId() ); 193 IsolatedWorldContentSecurityPolicyMap::iterator it = policies.find(worldId() );
192 return it == policies.end() ? false : it->value; 194 return it == policies.end() ? false : it->value;
193 } 195 }
194 196
195 void DOMWrapperWorld::setIsolatedWorldContentSecurityPolicy(int worldId, const S tring& policy) 197 void DOMWrapperWorld::setIsolatedWorldContentSecurityPolicy(int worldId, const S tring& policy)
196 { 198 {
197 ASSERT(DOMWrapperWorld::isIsolatedWorldId(worldId)); 199 ASSERT(isIsolatedWorldId(worldId));
198 if (!policy.isEmpty()) 200 if (!policy.isEmpty())
199 isolatedWorldContentSecurityPolicies().set(worldId, true); 201 isolatedWorldContentSecurityPolicies().set(worldId, true);
200 else 202 else
201 isolatedWorldContentSecurityPolicies().remove(worldId); 203 isolatedWorldContentSecurityPolicies().remove(worldId);
202 } 204 }
203 205
204 void DOMWrapperWorld::clearIsolatedWorldContentSecurityPolicy(int worldId) 206 void DOMWrapperWorld::clearIsolatedWorldContentSecurityPolicy(int worldId)
205 { 207 {
206 ASSERT(DOMWrapperWorld::isIsolatedWorldId(worldId)); 208 ASSERT(isIsolatedWorldId(worldId));
207 isolatedWorldContentSecurityPolicies().remove(worldId); 209 isolatedWorldContentSecurityPolicies().remove(worldId);
208 } 210 }
209 211
210 typedef HashMap<int, OwnPtr<V8DOMActivityLogger>, WTF::IntHash<int>, WTF::Unsign edWithZeroKeyHashTraits<int> > DOMActivityLoggerMap; 212 typedef HashMap<int, OwnPtr<V8DOMActivityLogger>, WTF::IntHash<int>, WTF::Unsign edWithZeroKeyHashTraits<int> > DOMActivityLoggerMap;
211 static DOMActivityLoggerMap& domActivityLoggers() 213 static DOMActivityLoggerMap& domActivityLoggers()
212 { 214 {
213 ASSERT(isMainThread()); 215 ASSERT(isMainThread());
214 DEFINE_STATIC_LOCAL(DOMActivityLoggerMap, map, ()); 216 DEFINE_STATIC_LOCAL(DOMActivityLoggerMap, map, ());
215 return map; 217 return map;
216 } 218 }
217 219
218 void DOMWrapperWorld::setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLog ger> logger) 220 void DOMWrapperWorld::setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLog ger> logger)
219 { 221 {
220 domActivityLoggers().set(worldId, logger); 222 domActivityLoggers().set(worldId, logger);
221 } 223 }
222 224
223 V8DOMActivityLogger* DOMWrapperWorld::activityLogger(int worldId) 225 V8DOMActivityLogger* DOMWrapperWorld::activityLogger(int worldId)
224 { 226 {
225 DOMActivityLoggerMap& loggers = domActivityLoggers(); 227 DOMActivityLoggerMap& loggers = domActivityLoggers();
226 DOMActivityLoggerMap::iterator it = loggers.find(worldId); 228 DOMActivityLoggerMap::iterator it = loggers.find(worldId);
227 return it == loggers.end() ? 0 : it->value.get(); 229 return it == loggers.end() ? 0 : it->value.get();
228 } 230 }
229 231
230 bool DOMWrapperWorld::contextHasCorrectPrototype(v8::Handle<v8::Context> context ) 232 bool DOMWrapperWorld::contextHasCorrectPrototype(v8::Handle<v8::Context> context )
231 { 233 {
232 return V8WindowShell::contextHasCorrectPrototype(context); 234 return V8WindowShell::contextHasCorrectPrototype(context);
233 } 235 }
234 236
235 } // namespace WebCore 237 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/DOMWrapperWorld.h ('k') | Source/bindings/v8/PageScriptDebugServer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698