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

Unified Diff: Source/modules/crypto/CryptoOperation.cpp

Issue 18475002: WebCrypto: Add framework for AlgorithmIdentifier normalization. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rename verify --> verifySignature (because "verify" is a macro on Mac) Created 7 years, 6 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
« no previous file with comments | « Source/modules/crypto/CryptoOperation.h ('k') | Source/modules/crypto/CryptoOperation.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/crypto/CryptoOperation.cpp
diff --git a/Source/core/fileapi/Stream.cpp b/Source/modules/crypto/CryptoOperation.cpp
similarity index 64%
copy from Source/core/fileapi/Stream.cpp
copy to Source/modules/crypto/CryptoOperation.cpp
index 2400e2b69665d8e532eb642d6bab50f41c276bbb..a3a9fd7495cafe35784db42593cf357e61d833d9 100644
--- a/Source/core/fileapi/Stream.cpp
+++ b/Source/modules/crypto/CryptoOperation.cpp
@@ -29,42 +29,43 @@
*/
#include "config.h"
-#include "core/fileapi/Stream.h"
+#include "modules/crypto/CryptoOperation.h"
-#include "core/fileapi/BlobRegistry.h"
-#include "core/fileapi/BlobURL.h"
-#include "core/platform/network/BlobData.h"
+#include "modules/crypto/AesCbcParams.h"
+#include "modules/crypto/AesKeyGenParams.h"
+#include "modules/crypto/Algorithm.h"
namespace WebCore {
-Stream::Stream(const String& mediaType)
- : m_mediaType(mediaType)
- , m_isNeutered(false)
-{
- ScriptWrappable::init(this);
-
- // Create a new internal URL for a stream and register it with the provided
- // media type.
- m_internalURL = BlobURL::createInternalURL();
- BlobRegistry::registerStreamURL(m_internalURL, m_mediaType);
-}
+namespace {
-void Stream::addData(const char* data, size_t len)
+PassRefPtr<Algorithm> createAlgorithm(const WebKit::WebCryptoAlgorithm& algorithm)
{
- RefPtr<RawData> buffer(RawData::create());
- buffer->mutableData()->resize(len);
- memcpy(buffer->mutableData()->data(), data, len);
- BlobRegistry::addDataToStream(m_internalURL, buffer);
+ switch (algorithm.paramsType()) {
+ case WebKit::WebCryptoAlgorithmParamsTypeNone:
+ return Algorithm::create(algorithm);
+ case WebKit::WebCryptoAlgorithmParamsTypeAesCbcParams:
+ return AesCbcParams::create(algorithm);
+ case WebKit::WebCryptoAlgorithmParamsTypeAesKeyGenParams:
+ return AesKeyGenParams::create(algorithm);
+ }
+ ASSERT_NOT_REACHED();
+ return 0;
}
-void Stream::finalize()
+} // namespace
+
+CryptoOperation::CryptoOperation(const WebKit::WebCryptoAlgorithm& algorithm)
+ : m_algorithm(algorithm)
{
- BlobRegistry::finalizeStream(m_internalURL);
+ ScriptWrappable::init(this);
}
-Stream::~Stream()
+Algorithm* CryptoOperation::algorithm()
{
- BlobRegistry::unregisterBlobURL(m_internalURL);
+ if (!m_algorithmNode)
+ m_algorithmNode = createAlgorithm(m_algorithm);
+ return m_algorithmNode.get();
}
} // namespace WebCore
« no previous file with comments | « Source/modules/crypto/CryptoOperation.h ('k') | Source/modules/crypto/CryptoOperation.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698