Chromium Code Reviews| Index: Source/modules/crypto/CryptoKey.cpp |
| diff --git a/Source/modules/crypto/CryptoKey.cpp b/Source/modules/crypto/CryptoKey.cpp |
| index 01510cc809d667ccbe89817210063771780339a9..c692843a765cb284b1c1af50d5f8f9e2ce29eeff 100644 |
| --- a/Source/modules/crypto/CryptoKey.cpp |
| +++ b/Source/modules/crypto/CryptoKey.cpp |
| @@ -32,6 +32,7 @@ |
| #include "modules/crypto/CryptoKey.h" |
| #include "bindings/core/v8/ExceptionState.h" |
| +#include "bindings/core/v8/V8ObjectBuilder.h" |
| #include "bindings/core/v8/V8Uint8Array.h" |
| #include "core/dom/ExceptionCode.h" |
| #include "platform/CryptoResult.h" |
| @@ -100,40 +101,38 @@ WebCryptoKeyUsageMask keyUsageStringToMask(const String& usageString) |
| class DictionaryBuilder : public blink::WebCryptoKeyAlgorithmDictionary { |
| public: |
| explicit DictionaryBuilder(ScriptState* scriptState) |
| - : m_scriptState(scriptState) |
| - , m_dictionary(Dictionary::createEmpty(scriptState->isolate())) |
| + : m_builder(scriptState) |
| { |
| } |
| virtual void setString(const char* propertyName, const char* value) |
| { |
| - m_dictionary.set(propertyName, value); |
| + m_builder.addString(propertyName, value); |
| } |
| virtual void setUint(const char* propertyName, unsigned value) |
| { |
| - m_dictionary.set(propertyName, value); |
| + m_builder.addNumber(propertyName, value); |
| } |
| virtual void setAlgorithm(const char* propertyName, const blink::WebCryptoAlgorithm& algorithm) |
| { |
| ASSERT(algorithm.paramsType() == blink::WebCryptoAlgorithmParamsTypeNone); |
| - Dictionary algorithmValue = Dictionary::createEmpty(m_scriptState->isolate()); |
| - algorithmValue.set("name", blink::WebCryptoAlgorithm::lookupAlgorithmInfo(algorithm.id())->name); |
| - m_dictionary.set(propertyName, algorithmValue); |
| + V8ObjectBuilder algorithmValue(m_builder.scriptState()); |
| + algorithmValue.addString("name", blink::WebCryptoAlgorithm::lookupAlgorithmInfo(algorithm.id())->name); |
| + m_builder.add(propertyName, algorithmValue); |
| } |
| virtual void setUint8Array(const char* propertyName, const blink::WebVector<unsigned char>& vector) |
| { |
| - m_dictionary.set(propertyName, toV8(DOMUint8Array::create(vector.data(), vector.size()), m_scriptState->context()->Global(), m_scriptState->isolate())); |
| + m_builder.add(propertyName, ScriptValue::from(m_builder.scriptState(), DOMUint8Array::create(vector.data(), vector.size()))); |
|
bashi
2015/03/25 01:09:25
IMHO, having addUint8Array() in V8ObjectBuilder wo
Jens Widell
2015/03/25 11:16:04
I'm not sure. Supporting generic values (e.g. Scri
Jens Widell
2015/03/25 11:34:01
Generic add() added now, and the explicit ScriptVa
|
| } |
| - const Dictionary& dictionary() const { return m_dictionary; } |
| + ScriptValue value() const { return m_builder.scriptValue(); } |
| private: |
| - RefPtr<ScriptState> m_scriptState; |
| - Dictionary m_dictionary; |
| + V8ObjectBuilder m_builder; |
| }; |
| } // namespace |
| @@ -161,7 +160,7 @@ ScriptValue CryptoKey::algorithm(ScriptState* scriptState) |
| { |
| DictionaryBuilder builder(scriptState); |
| m_key.algorithm().writeToDictionary(&builder); |
| - return ScriptValue(scriptState, builder.dictionary().v8Value()); |
| + return builder.value(); |
| } |
| // FIXME: This creates a new javascript array each time. What should happen |