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

Unified Diff: Source/bindings/modules/v8/DictionaryHelperForModules.cpp

Issue 386883008: Converted IDBVersionChangeEvent.dataLoss to an enumeration: IDBDataLossAmount (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added link to W3C's IDL spec Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/modules/v8/DictionaryHelperForModules.cpp
diff --git a/Source/bindings/modules/v8/DictionaryHelperForModules.cpp b/Source/bindings/modules/v8/DictionaryHelperForModules.cpp
index 931123fd3239cd204d8ec99c45d1053cc97bd4d9..930c3b5f45ba81213e2ada80e9c887c1bea1d3ca 100644
--- a/Source/bindings/modules/v8/DictionaryHelperForModules.cpp
+++ b/Source/bindings/modules/v8/DictionaryHelperForModules.cpp
@@ -36,9 +36,11 @@
#include "bindings/modules/v8/V8SpeechRecognitionResult.h"
#include "bindings/modules/v8/V8SpeechRecognitionResultList.h"
#include "modules/gamepad/Gamepad.h"
+#include "modules/indexeddb/IDBVersionChangeEvent.h"
#include "modules/mediastream/MediaStream.h"
#include "modules/speech/SpeechRecognitionResult.h"
#include "modules/speech/SpeechRecognitionResultList.h"
+#include "public/platform/WebIDBTypes.h"
jsbell 2014/07/11 18:42:48 It'd be nice to drop this dependency...
cmumford 2014/07/11 20:53:05 Yes, this is obviously so that we can get at the W
namespace WebCore {
@@ -72,6 +74,38 @@ struct DictionaryHelperTraits<Headers> {
typedef V8Headers type;
};
+template <typename T>
jsbell 2014/07/11 18:42:48 This is basically doing two things: * Dig the IDL
cmumford 2014/07/11 20:53:05 Well the string conversion is in IDBVersionChangeE
jsbell 2014/07/11 23:08:30 Right... I'm assuming that the DictionaryHelper.co
bashi 2014/07/13 04:53:32 I agree with jsbell here. Some classes are doing t
+struct IntegralTypeTraits {
+};
+
+template <>
+struct IntegralTypeTraits<blink::WebIDBDataLoss> {
+ static inline blink::WebIDBDataLoss toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState)
+ {
+ blink::WebIDBDataLoss dataLoss = blink::WebIDBDataLossNone;
+ if (!IDBVersionChangeEvent::toNativeDataLoss(value, &dataLoss))
+ exceptionState.throwTypeError("Invalid IDBDataLossAmount value");
+ return dataLoss;
+ }
+ static const String typeName() { return "IDBDataLossAmount"; }
+};
+
+template<typename T>
+bool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, T& value)
+{
+ Dictionary::ConversionContextScope scope(context);
+
+ v8::Local<v8::Value> v8Value;
+ if (!dictionary.get(key, v8Value))
+ return true;
+
+ value = IntegralTypeTraits<T>::toIntegral(v8Value, NormalConversion, context.exceptionState());
+ if (context.exceptionState().throwIfNeeded())
+ return false;
+
+ return true;
+}
bashi 2014/07/13 04:53:32 This looks exactly the same as DictionaryHelper::c
cmumford 2014/07/14 22:09:37 Done.
+
template bool DictionaryHelper::get(const Dictionary&, const String& key, Member<MIDIPort>& value);
template bool DictionaryHelper::get(const Dictionary&, const String& key, Member<SpeechRecognitionResult>& value);
template bool DictionaryHelper::get(const Dictionary&, const String& key, Member<SpeechRecognitionResultList>& value);
@@ -85,5 +119,6 @@ template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio
template bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Member<Gamepad>& value);
template bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Member<MediaStream>& value);
template bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, RefPtrWillBeMember<Headers>& value);
+template bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, blink::WebIDBDataLoss& value);
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698