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

Side by Side Diff: Source/bindings/core/v8/DictionaryHelperForCore.cpp

Issue 555133003: Use ExceptionState to throw exceptions when converting arrays (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 if (!dictionary.get(key, v8Value)) 258 if (!dictionary.get(key, v8Value))
259 return false; 259 return false;
260 260
261 // We need to handle a DOMWindow specially, because a DOMWindow wrapper 261 // We need to handle a DOMWindow specially, because a DOMWindow wrapper
262 // exists on a prototype chain of v8Value. 262 // exists on a prototype chain of v8Value.
263 value = toDOMWindow(v8Value, dictionary.isolate()); 263 value = toDOMWindow(v8Value, dictionary.isolate());
264 return true; 264 return true;
265 } 265 }
266 266
267 template <> 267 template <>
268 bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, Mess agePortArray& value)
269 {
270 v8::Local<v8::Value> v8Value;
271 if (!dictionary.get(key, v8Value))
272 return false;
273
274 ASSERT(dictionary.isolate());
275 ASSERT(dictionary.isolate() == v8::Isolate::GetCurrent());
276 if (blink::isUndefinedOrNull(v8Value))
277 return true;
278 bool success = false;
279 value = toRefPtrWillBeMemberNativeArray<MessagePort, V8MessagePort>(v8Value, key, dictionary.isolate(), &success);
280 return success;
281 }
282
283 template <>
284 bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, Hash Set<AtomicString>& value) 268 bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, Hash Set<AtomicString>& value)
285 { 269 {
286 v8::Local<v8::Value> v8Value; 270 v8::Local<v8::Value> v8Value;
287 if (!dictionary.get(key, v8Value)) 271 if (!dictionary.get(key, v8Value))
288 return false; 272 return false;
289 273
290 // FIXME: Support array-like objects 274 // FIXME: Support array-like objects
291 if (!v8Value->IsArray()) 275 if (!v8Value->IsArray())
292 return false; 276 return false;
293 277
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 633
650 template <> 634 template <>
651 bool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::Convers ionContext& context, const String& key, MessagePortArray& value) 635 bool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::Convers ionContext& context, const String& key, MessagePortArray& value)
652 { 636 {
653 Dictionary::ConversionContextScope scope(context); 637 Dictionary::ConversionContextScope scope(context);
654 638
655 v8::Local<v8::Value> v8Value; 639 v8::Local<v8::Value> v8Value;
656 if (!dictionary.get(key, v8Value)) 640 if (!dictionary.get(key, v8Value))
657 return true; 641 return true;
658 642
659 return DictionaryHelper::get(dictionary, key, value); 643 ASSERT(dictionary.isolate());
644 ASSERT(dictionary.isolate() == v8::Isolate::GetCurrent());
645
646 if (isUndefinedOrNull(v8Value))
647 return true;
648
649 value = toRefPtrWillBeMemberNativeArray<MessagePort, V8MessagePort>(v8Value, key, dictionary.isolate(), context.exceptionState());
650
651 if (context.exceptionState().throwIfNeeded())
652 return false;
653
654 return true;
660 } 655 }
661 656
662 } // namespace blink 657 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698