Chromium Code Reviews| Index: Source/modules/crypto/SubtleCrypto.h |
| diff --git a/Source/modules/crypto/SubtleCrypto.h b/Source/modules/crypto/SubtleCrypto.h |
| index 830cdc7bd07818b826b4a41476409a38749fe5d9..9e0f6b9a27a51b1ad28ed79ca297d9eaf5d461fe 100644 |
| --- a/Source/modules/crypto/SubtleCrypto.h |
| +++ b/Source/modules/crypto/SubtleCrypto.h |
| @@ -45,24 +45,40 @@ class Key; |
| class SubtleCrypto : public GarbageCollectedFinalized<SubtleCrypto>, public ScriptWrappable { |
| public: |
| + // Adapter to implicitly convert an ArrayBuffer* or ArrayBufferView* to a |
| + // common data type. This simplifies having to define a bunch of overloads |
| + // for functions that take either parameter. |
| + struct Bytes { |
| + Bytes(); |
| + Bytes(ArrayBuffer*); |
| + Bytes(ArrayBufferView*); |
| + |
| + const unsigned char* bytes; |
| + unsigned size; |
| + bool isNull; |
| + |
| + private: |
| + void initNull(); |
| + }; |
|
abarth-chromium
2014/05/06 05:30:49
Can you move this class in WTF? It seems generall
eroman
2014/05/06 21:27:26
Done.
|
| + |
| static SubtleCrypto* create() |
| { |
| return new SubtleCrypto(); |
| } |
| - ScriptPromise encrypt(const Dictionary&, Key*, ArrayBufferView* data); |
| - ScriptPromise decrypt(const Dictionary&, Key*, ArrayBufferView* data); |
| - ScriptPromise sign(const Dictionary&, Key*, ArrayBufferView* data); |
| + ScriptPromise encrypt(const Dictionary&, Key*, const Bytes&); |
| + ScriptPromise decrypt(const Dictionary&, Key*, const Bytes&); |
| + ScriptPromise sign(const Dictionary&, Key*, const Bytes&); |
| // Note that this is not named "verify" because when compiling on Mac that expands to a macro and breaks. |
| - ScriptPromise verifySignature(const Dictionary&, Key*, ArrayBufferView* signature, ArrayBufferView* data); |
| - ScriptPromise digest(const Dictionary&, ArrayBufferView* data); |
| + ScriptPromise verifySignature(const Dictionary&, Key*, const Bytes& signature, const Bytes& data); |
| + ScriptPromise digest(const Dictionary&, const Bytes& data); |
| ScriptPromise generateKey(const Dictionary&, bool extractable, const Vector<String>& keyUsages); |
| - ScriptPromise importKey(const String&, ArrayBufferView*, const Dictionary&, bool extractable, const Vector<String>& keyUsages); |
| + ScriptPromise importKey(const String&, const Bytes&, const Dictionary&, bool extractable, const Vector<String>& keyUsages); |
| ScriptPromise exportKey(const String&, Key*); |
| ScriptPromise wrapKey(const String&, Key*, Key*, const Dictionary&); |
| - ScriptPromise unwrapKey(const String&, ArrayBufferView*, Key*, const Dictionary&, const Dictionary&, bool, const Vector<String>&); |
| + ScriptPromise unwrapKey(const String&, const Bytes&, Key*, const Dictionary&, const Dictionary&, bool, const Vector<String>&); |
| void trace(Visitor*) { } |