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

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

Issue 2280893002: Make toV8(ScriptValue) never return an empty handle (Closed)
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 DISALLOW_NEW(); 178 DISALLOW_NEW();
179 }; // Used only for having toV8 return v8::Undefined. 179 }; // Used only for having toV8 return v8::Undefined.
180 180
181 inline v8::Local<v8::Value> toV8(const ToV8UndefinedGenerator& value, v8::Local <v8::Object> creationContext, v8::Isolate* isolate) 181 inline v8::Local<v8::Value> toV8(const ToV8UndefinedGenerator& value, v8::Local <v8::Object> creationContext, v8::Isolate* isolate)
182 { 182 {
183 return v8::Undefined(isolate); 183 return v8::Undefined(isolate);
184 } 184 }
185 185
186 // ScriptValue 186 // ScriptValue
187 187
188 inline v8::Local<v8::Value> toV8(const ScriptValue& value, v8::Local<v8::Object> creationContext, v8::Isolate*) 188 inline v8::Local<v8::Value> toV8(const ScriptValue& value, v8::Local<v8::Object> creationContext, v8::Isolate* isolate)
189 { 189 {
190 if (value.isEmpty())
191 return v8::Undefined(isolate);
190 return value.v8Value(); 192 return value.v8Value();
191 } 193 }
192 194
193 // Dictionary 195 // Dictionary
194 196
195 inline v8::Local<v8::Value> toV8(const Dictionary& value, v8::Local<v8::Object> creationContext, v8::Isolate*) 197 inline v8::Local<v8::Value> toV8(const Dictionary& value, v8::Local<v8::Object> creationContext, v8::Isolate* isolate)
196 { 198 {
197 RELEASE_NOTREACHED(); 199 NOTREACHED();
198 return v8::Local<v8::Value>(); 200 return v8::Undefined(isolate);
199 } 201 }
200 202
201 inline v8::Local<v8::Value> toV8(const IDLDictionaryBase& value, v8::Local<v8::O bject> creationContext, v8::Isolate* isolate) 203 inline v8::Local<v8::Value> toV8(const IDLDictionaryBase& value, v8::Local<v8::O bject> creationContext, v8::Isolate* isolate)
202 { 204 {
203 return value.toV8Impl(creationContext, isolate); 205 return value.toV8Impl(creationContext, isolate);
204 } 206 }
205 207
206 // Array 208 // Array
207 209
208 template<typename Sequence> 210 template<typename Sequence>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // Cannot define in ScriptValue because of the circular dependency between toV8 and ScriptValue 279 // Cannot define in ScriptValue because of the circular dependency between toV8 and ScriptValue
278 template<typename T> 280 template<typename T>
279 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) 281 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value)
280 { 282 {
281 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState)); 283 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState));
282 } 284 }
283 285
284 } // namespace blink 286 } // namespace blink
285 287
286 #endif // ToV8_h 288 #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