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

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

Issue 2267423003: Add DCHECKs to check that toV8 never returns an empty handle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 19 matching lines...) Expand all
30 // ScriptWrappable 30 // ScriptWrappable
31 31
32 inline v8::Local<v8::Value> toV8(ScriptWrappable* impl, v8::Local<v8::Object> cr eationContext, v8::Isolate* isolate) 32 inline v8::Local<v8::Value> toV8(ScriptWrappable* impl, v8::Local<v8::Object> cr eationContext, v8::Isolate* isolate)
33 { 33 {
34 if (UNLIKELY(!impl)) 34 if (UNLIKELY(!impl))
35 return v8::Null(isolate); 35 return v8::Null(isolate);
36 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); 36 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
37 if (!wrapper.IsEmpty()) 37 if (!wrapper.IsEmpty())
38 return wrapper; 38 return wrapper;
39 39
40 return impl->wrap(isolate, creationContext); 40 wrapper = impl->wrap(isolate, creationContext);
41 DCHECK(!wrapper.IsEmpty());
42 return wrapper;
41 } 43 }
42 44
43 inline v8::Local<v8::Value> toV8(Node* impl, v8::Local<v8::Object> creationConte xt, v8::Isolate* isolate) 45 inline v8::Local<v8::Value> toV8(Node* impl, v8::Local<v8::Object> creationConte xt, v8::Isolate* isolate)
44 { 46 {
45 if (UNLIKELY(!impl)) 47 if (UNLIKELY(!impl))
46 return v8::Null(isolate); 48 return v8::Null(isolate);
47 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); 49 v8::Local<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
48 if (!wrapper.IsEmpty()) 50 if (!wrapper.IsEmpty())
49 return wrapper; 51 return wrapper;
50 52
51 return ScriptWrappable::fromNode(impl)->wrap(isolate, creationContext); 53 wrapper = ScriptWrappable::fromNode(impl)->wrap(isolate, creationContext);
54 DCHECK(!wrapper.IsEmpty());
55 return wrapper;
52 } 56 }
53 57
54 // Special versions for DOMWindow, WorkerOrWorkletGlobalScope and EventTarget 58 // Special versions for DOMWindow, WorkerOrWorkletGlobalScope and EventTarget
55 59
56 CORE_EXPORT v8::Local<v8::Value> toV8(DOMWindow*, v8::Local<v8::Object> creation Context, v8::Isolate*); 60 CORE_EXPORT v8::Local<v8::Value> toV8(DOMWindow*, v8::Local<v8::Object> creation Context, v8::Isolate*);
57 CORE_EXPORT v8::Local<v8::Value> toV8(EventTarget*, v8::Local<v8::Object> creati onContext, v8::Isolate*); 61 CORE_EXPORT v8::Local<v8::Value> toV8(EventTarget*, v8::Local<v8::Object> creati onContext, v8::Isolate*);
58 v8::Local<v8::Value> toV8(WorkerOrWorkletGlobalScope*, v8::Local<v8::Object> cre ationContext, v8::Isolate*); 62 v8::Local<v8::Value> toV8(WorkerOrWorkletGlobalScope*, v8::Local<v8::Object> cre ationContext, v8::Isolate*);
59 63
60 // PassRefPtr and RefPtr 64 // PassRefPtr and RefPtr
61 65
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 // Cannot define in ScriptValue because of the circular dependency between toV8 and ScriptValue 277 // Cannot define in ScriptValue because of the circular dependency between toV8 and ScriptValue
274 template<typename T> 278 template<typename T>
275 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) 279 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value)
276 { 280 {
277 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState)); 281 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState));
278 } 282 }
279 283
280 } // namespace blink 284 } // namespace blink
281 285
282 #endif // ToV8_h 286 #endif // ToV8_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698