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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ToV8.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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ToV8_h 5 #ifndef ToV8_h
6 #define ToV8_h 6 #define ToV8_h
7 7
8 // ToV8() provides C++ -> V8 conversion. Note that ToV8() can return an empty 8 // ToV8() provides C++ -> V8 conversion. Note that ToV8() can return an empty
9 // handle. Call sites must check IsEmpty() before using return value. 9 // handle. Call sites must check IsEmpty() before using return value.
10 10
11 #include "bindings/core/v8/DOMDataStore.h" 11 #include "bindings/core/v8/DOMDataStore.h"
12 #include "bindings/core/v8/IDLDictionaryBase.h" 12 #include "bindings/core/v8/IDLDictionaryBase.h"
13 #include "bindings/core/v8/ScriptState.h" 13 #include "bindings/core/v8/ScriptState.h"
14 #include "bindings/core/v8/ScriptValue.h" 14 #include "bindings/core/v8/ScriptValue.h"
15 #include "bindings/core/v8/ScriptWrappable.h" 15 #include "bindings/core/v8/ScriptWrappable.h"
16 #include "bindings/core/v8/V8Binding.h" 16 #include "bindings/core/v8/V8Binding.h"
17 #include "core/CoreExport.h" 17 #include "core/CoreExport.h"
18 #include "platform/heap/Handle.h" 18 #include "platform/heap/Handle.h"
19 #include "wtf/Forward.h" 19 #include "wtf/Forward.h"
20 #include <utility> 20 #include <utility>
21 #include <v8.h> 21 #include <v8.h>
22 22
23 namespace blink { 23 namespace blink {
24 24
25 class DOMWindow; 25 class DOMWindow;
26 class Dictionary; 26 class Dictionary;
27 class EventTarget; 27 class EventTarget;
28 class WorkerOrWorkletGlobalScope;
29 28
30 // ScriptWrappable 29 // ScriptWrappable
31 30
32 inline v8::Local<v8::Value> ToV8(ScriptWrappable* impl, 31 inline v8::Local<v8::Value> ToV8(ScriptWrappable* impl,
33 v8::Local<v8::Object> creationContext, 32 v8::Local<v8::Object> creationContext,
34 v8::Isolate* isolate) { 33 v8::Isolate* isolate) {
35 if (UNLIKELY(!impl)) 34 if (UNLIKELY(!impl))
36 return v8::Null(isolate); 35 return v8::Null(isolate);
37 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); 36 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
38 if (!wrapper.IsEmpty()) 37 if (!wrapper.IsEmpty())
(...skipping 11 matching lines...) Expand all
50 return v8::Null(isolate); 49 return v8::Null(isolate);
51 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); 50 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
52 if (!wrapper.IsEmpty()) 51 if (!wrapper.IsEmpty())
53 return wrapper; 52 return wrapper;
54 53
55 wrapper = ScriptWrappable::fromNode(impl)->wrap(isolate, creationContext); 54 wrapper = ScriptWrappable::fromNode(impl)->wrap(isolate, creationContext);
56 DCHECK(!wrapper.IsEmpty()); 55 DCHECK(!wrapper.IsEmpty());
57 return wrapper; 56 return wrapper;
58 } 57 }
59 58
60 // Special versions for DOMWindow, WorkerOrWorkletGlobalScope and EventTarget 59 // Special versions for DOMWindow and EventTarget
61 60
62 CORE_EXPORT v8::Local<v8::Value> ToV8(DOMWindow*, 61 CORE_EXPORT v8::Local<v8::Value> ToV8(DOMWindow*,
63 v8::Local<v8::Object> creationContext, 62 v8::Local<v8::Object> creationContext,
64 v8::Isolate*); 63 v8::Isolate*);
65 CORE_EXPORT v8::Local<v8::Value> ToV8(EventTarget*, 64 CORE_EXPORT v8::Local<v8::Value> ToV8(EventTarget*,
66 v8::Local<v8::Object> creationContext, 65 v8::Local<v8::Object> creationContext,
67 v8::Isolate*); 66 v8::Isolate*);
68 v8::Local<v8::Value> ToV8(WorkerOrWorkletGlobalScope*,
69 v8::Local<v8::Object> creationContext,
70 v8::Isolate*);
71 67
72 // Primitives 68 // Primitives
73 69
74 inline v8::Local<v8::Value> ToV8(const String& value, 70 inline v8::Local<v8::Value> ToV8(const String& value,
75 v8::Local<v8::Object> creationContext, 71 v8::Local<v8::Object> creationContext,
76 v8::Isolate* isolate) { 72 v8::Isolate* isolate) {
77 return v8String(isolate, value); 73 return v8String(isolate, value);
78 } 74 }
79 75
80 inline v8::Local<v8::Value> ToV8(const char* value, 76 inline v8::Local<v8::Value> ToV8(const char* value,
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // Cannot define in ScriptValue because of the circular dependency between toV8 299 // Cannot define in ScriptValue because of the circular dependency between toV8
304 // and ScriptValue 300 // and ScriptValue
305 template <typename T> 301 template <typename T>
306 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) { 302 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) {
307 return ScriptValue(scriptState, ToV8(std::forward<T>(value), scriptState)); 303 return ScriptValue(scriptState, ToV8(std::forward<T>(value), scriptState));
308 } 304 }
309 305
310 } // namespace blink 306 } // namespace blink
311 307
312 #endif // ToV8_h 308 #endif // ToV8_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698