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

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

Issue 2726593002: Use mayNotBeMainThread() for wrapper optimization (Closed)
Patch Set: Use V8TestingScope Created 3 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
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
(...skipping 28 matching lines...) Expand all
39 return wrapper; 39 return wrapper;
40 40
41 wrapper = impl->wrap(isolate, creationContext); 41 wrapper = impl->wrap(isolate, creationContext);
42 DCHECK(!wrapper.IsEmpty()); 42 DCHECK(!wrapper.IsEmpty());
43 return wrapper; 43 return wrapper;
44 } 44 }
45 45
46 inline v8::Local<v8::Value> ToV8(Node* impl, 46 inline v8::Local<v8::Value> ToV8(Node* impl,
47 v8::Local<v8::Object> creationContext, 47 v8::Local<v8::Object> creationContext,
48 v8::Isolate* isolate) { 48 v8::Isolate* isolate) {
49 if (UNLIKELY(!impl)) 49 return ToV8(ScriptWrappable::fromNode(impl), creationContext, isolate);
50 return v8::Null(isolate);
51 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
52 if (!wrapper.IsEmpty())
53 return wrapper;
54
55 wrapper = ScriptWrappable::fromNode(impl)->wrap(isolate, creationContext);
56 DCHECK(!wrapper.IsEmpty());
57 return wrapper;
58 } 50 }
59 51
60 // Special versions for DOMWindow and EventTarget 52 // Special versions for DOMWindow and EventTarget
61 53
62 CORE_EXPORT v8::Local<v8::Value> ToV8(DOMWindow*, 54 CORE_EXPORT v8::Local<v8::Value> ToV8(DOMWindow*,
63 v8::Local<v8::Object> creationContext, 55 v8::Local<v8::Object> creationContext,
64 v8::Isolate*); 56 v8::Isolate*);
65 CORE_EXPORT v8::Local<v8::Value> ToV8(EventTarget*, 57 CORE_EXPORT v8::Local<v8::Value> ToV8(EventTarget*,
66 v8::Local<v8::Object> creationContext, 58 v8::Local<v8::Object> creationContext,
67 v8::Isolate*); 59 v8::Isolate*);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // Cannot define in ScriptValue because of the circular dependency between toV8 321 // Cannot define in ScriptValue because of the circular dependency between toV8
330 // and ScriptValue 322 // and ScriptValue
331 template <typename T> 323 template <typename T>
332 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) { 324 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) {
333 return ScriptValue(scriptState, ToV8(std::forward<T>(value), scriptState)); 325 return ScriptValue(scriptState, ToV8(std::forward<T>(value), scriptState));
334 } 326 }
335 327
336 } // namespace blink 328 } // namespace blink
337 329
338 #endif // ToV8_h 330 #endif // ToV8_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp ('k') | third_party/WebKit/Source/bindings/core/v8/V8Binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698