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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8Binding.h

Issue 2620493002: binding: Changes the association among global-proxy/global/worker-instance. (Closed)
Patch Set: Synced. Created 3 years, 11 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 * Copyright (C) 2012 Ericsson AB. All rights reserved. 3 * Copyright (C) 2012 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 class DOMWindow; 57 class DOMWindow;
58 class EventListener; 58 class EventListener;
59 class EventTarget; 59 class EventTarget;
60 class ExceptionState; 60 class ExceptionState;
61 class ExecutionContext; 61 class ExecutionContext;
62 class FlexibleArrayBufferView; 62 class FlexibleArrayBufferView;
63 class Frame; 63 class Frame;
64 class LocalDOMWindow; 64 class LocalDOMWindow;
65 class LocalFrame; 65 class LocalFrame;
66 class NodeFilter; 66 class NodeFilter;
67 class WorkerGlobalScope;
68 class WorkerOrWorkletGlobalScope;
69 class XPathNSResolver; 67 class XPathNSResolver;
70 68
71 template <typename T> 69 template <typename T>
72 struct V8TypeOf { 70 struct V8TypeOf {
73 STATIC_ONLY(V8TypeOf); 71 STATIC_ONLY(V8TypeOf);
74 // |Type| provides C++ -> V8 type conversion for DOM wrappers. 72 // |Type| provides C++ -> V8 type conversion for DOM wrappers.
75 // The Blink binding code generator will generate specialized version of 73 // The Blink binding code generator will generate specialized version of
76 // V8TypeOf for each wrapper class. 74 // V8TypeOf for each wrapper class.
77 typedef void Type; 75 typedef void Type;
78 }; 76 };
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 v8SetReturnValueNull(callbackInfo); 195 v8SetReturnValueNull(callbackInfo);
198 return; 196 return;
199 } 197 }
200 if (DOMDataStore::setReturnValue(callbackInfo.GetReturnValue(), impl)) 198 if (DOMDataStore::setReturnValue(callbackInfo.GetReturnValue(), impl))
201 return; 199 return;
202 v8::Local<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap( 200 v8::Local<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap(
203 callbackInfo.GetIsolate(), callbackInfo.Holder()); 201 callbackInfo.GetIsolate(), callbackInfo.Holder());
204 v8SetReturnValue(callbackInfo, wrapper); 202 v8SetReturnValue(callbackInfo, wrapper);
205 } 203 }
206 204
207 // Special versions for DOMWindow, WorkerGlobalScope and EventTarget 205 // Special versions for DOMWindow and EventTarget
208 206
209 template <typename CallbackInfo> 207 template <typename CallbackInfo>
210 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, 208 inline void v8SetReturnValue(const CallbackInfo& callbackInfo,
211 DOMWindow* impl) { 209 DOMWindow* impl) {
212 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), 210 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
213 callbackInfo.GetIsolate())); 211 callbackInfo.GetIsolate()));
214 } 212 }
215 213
216 template <typename CallbackInfo> 214 template <typename CallbackInfo>
217 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, 215 inline void v8SetReturnValue(const CallbackInfo& callbackInfo,
218 EventTarget* impl) { 216 EventTarget* impl) {
219 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), 217 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
220 callbackInfo.GetIsolate())); 218 callbackInfo.GetIsolate()));
221 } 219 }
222 220
223 template <typename CallbackInfo>
224 inline void v8SetReturnValue(const CallbackInfo& callbackInfo,
225 WorkerGlobalScope* impl) {
226 v8SetReturnValue(callbackInfo,
227 ToV8((WorkerOrWorkletGlobalScope*)impl,
228 callbackInfo.Holder(), callbackInfo.GetIsolate()));
229 }
230
231 template <typename CallbackInfo, typename T> 221 template <typename CallbackInfo, typename T>
232 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, 222 inline void v8SetReturnValue(const CallbackInfo& callbackInfo,
233 PassRefPtr<T> impl) { 223 PassRefPtr<T> impl) {
234 v8SetReturnValue(callbackInfo, impl.get()); 224 v8SetReturnValue(callbackInfo, impl.get());
235 } 225 }
236 226
237 template <typename CallbackInfo> 227 template <typename CallbackInfo>
238 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, 228 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
239 ScriptWrappable* impl) { 229 ScriptWrappable* impl) {
240 ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld()); 230 ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
(...skipping 26 matching lines...) Expand all
267 // Optimized and very fast. 257 // Optimized and very fast.
268 // v8SetReturnValueForMainWorld(EventTarget*) 258 // v8SetReturnValueForMainWorld(EventTarget*)
269 // Uses custom toV8 function and slow. 259 // Uses custom toV8 function and slow.
270 // v8SetReturnValueForMainWorld(Node*) 260 // v8SetReturnValueForMainWorld(Node*)
271 // Optimized and very fast. 261 // Optimized and very fast.
272 // v8SetReturnValueForMainWorld(Window*) 262 // v8SetReturnValueForMainWorld(Window*)
273 // Uses custom toV8 function and slow. 263 // Uses custom toV8 function and slow.
274 v8SetReturnValueForMainWorld(callbackInfo, ScriptWrappable::fromNode(impl)); 264 v8SetReturnValueForMainWorld(callbackInfo, ScriptWrappable::fromNode(impl));
275 } 265 }
276 266
277 // Special versions for DOMWindow, WorkerGlobalScope and EventTarget 267 // Special versions for DOMWindow and EventTarget
278 268
279 template <typename CallbackInfo> 269 template <typename CallbackInfo>
280 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, 270 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
281 DOMWindow* impl) { 271 DOMWindow* impl) {
282 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), 272 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
283 callbackInfo.GetIsolate())); 273 callbackInfo.GetIsolate()));
284 } 274 }
285 275
286 template <typename CallbackInfo> 276 template <typename CallbackInfo>
287 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, 277 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
288 EventTarget* impl) { 278 EventTarget* impl) {
289 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), 279 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
290 callbackInfo.GetIsolate())); 280 callbackInfo.GetIsolate()));
291 } 281 }
292 282
293 template <typename CallbackInfo>
294 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
295 WorkerGlobalScope* impl) {
296 v8SetReturnValue(callbackInfo,
297 ToV8((WorkerOrWorkletGlobalScope*)impl,
298 callbackInfo.Holder(), callbackInfo.GetIsolate()));
299 }
300
301 template <typename CallbackInfo, typename T> 283 template <typename CallbackInfo, typename T>
302 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, 284 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo,
303 PassRefPtr<T> impl) { 285 PassRefPtr<T> impl) {
304 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); 286 v8SetReturnValueForMainWorld(callbackInfo, impl.get());
305 } 287 }
306 288
307 template <typename CallbackInfo> 289 template <typename CallbackInfo>
308 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, 290 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
309 ScriptWrappable* impl, 291 ScriptWrappable* impl,
310 const ScriptWrappable* wrappable) { 292 const ScriptWrappable* wrappable) {
(...skipping 18 matching lines...) Expand all
329 return; 311 return;
330 } 312 }
331 if (DOMDataStore::setReturnValueFast(callbackInfo.GetReturnValue(), impl, 313 if (DOMDataStore::setReturnValueFast(callbackInfo.GetReturnValue(), impl,
332 callbackInfo.Holder(), wrappable)) 314 callbackInfo.Holder(), wrappable))
333 return; 315 return;
334 v8::Local<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap( 316 v8::Local<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap(
335 callbackInfo.GetIsolate(), callbackInfo.Holder()); 317 callbackInfo.GetIsolate(), callbackInfo.Holder());
336 v8SetReturnValue(callbackInfo, wrapper); 318 v8SetReturnValue(callbackInfo, wrapper);
337 } 319 }
338 320
339 // Special versions for DOMWindow, WorkerGlobalScope and EventTarget 321 // Special versions for DOMWindow and EventTarget
340 322
341 template <typename CallbackInfo> 323 template <typename CallbackInfo>
342 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, 324 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
343 DOMWindow* impl, 325 DOMWindow* impl,
344 const ScriptWrappable*) { 326 const ScriptWrappable*) {
345 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), 327 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
346 callbackInfo.GetIsolate())); 328 callbackInfo.GetIsolate()));
347 } 329 }
348 330
349 template <typename CallbackInfo> 331 template <typename CallbackInfo>
350 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, 332 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
351 EventTarget* impl, 333 EventTarget* impl,
352 const ScriptWrappable*) { 334 const ScriptWrappable*) {
353 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), 335 v8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(),
354 callbackInfo.GetIsolate())); 336 callbackInfo.GetIsolate()));
355 } 337 }
356 338
357 template <typename CallbackInfo>
358 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
359 WorkerGlobalScope* impl,
360 const ScriptWrappable*) {
361 v8SetReturnValue(callbackInfo,
362 ToV8((WorkerOrWorkletGlobalScope*)impl,
363 callbackInfo.Holder(), callbackInfo.GetIsolate()));
364 }
365
366 template <typename CallbackInfo, typename T, typename Wrappable> 339 template <typename CallbackInfo, typename T, typename Wrappable>
367 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, 340 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
368 PassRefPtr<T> impl, 341 PassRefPtr<T> impl,
369 const Wrappable* wrappable) { 342 const Wrappable* wrappable) {
370 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); 343 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable);
371 } 344 }
372 345
373 template <typename CallbackInfo, typename T> 346 template <typename CallbackInfo, typename T>
374 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, 347 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo,
375 const v8::Local<T> handle, 348 const v8::Local<T> handle,
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 // If the argument isn't an object, this will crash. 1138 // If the argument isn't an object, this will crash.
1166 CORE_EXPORT v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value>, 1139 CORE_EXPORT v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value>,
1167 v8::Isolate*); 1140 v8::Isolate*);
1168 1141
1169 CORE_EXPORT v8::Local<v8::Value> fromJSONString(v8::Isolate*, 1142 CORE_EXPORT v8::Local<v8::Value> fromJSONString(v8::Isolate*,
1170 const String& stringifiedJSON, 1143 const String& stringifiedJSON,
1171 ExceptionState&); 1144 ExceptionState&);
1172 } // namespace blink 1145 } // namespace blink
1173 1146
1174 #endif // V8Binding_h 1147 #endif // V8Binding_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698