Index: Source/modules/crypto/CryptoOperation.cpp |
diff --git a/Source/core/fileapi/Stream.cpp b/Source/modules/crypto/CryptoOperation.cpp |
similarity index 65% |
copy from Source/core/fileapi/Stream.cpp |
copy to Source/modules/crypto/CryptoOperation.cpp |
index 2400e2b69665d8e532eb642d6bab50f41c276bbb..2628a56d093abf7a11f253ca557d0b68335c9afd 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::NoParams: |
+ return Algorithm::create(algorithm); |
+ case WebKit::AesCbcParams: |
+ return AesCbcParams::create(algorithm); |
+ case WebKit::AesKeyGenParams: |
+ 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() |
+PassRefPtr<Algorithm> CryptoOperation::algorithm() |
{ |
- BlobRegistry::unregisterBlobURL(m_internalURL); |
+ if (!m_algorithmNode) |
+ m_algorithmNode = createAlgorithm(m_algorithm); |
+ return m_algorithmNode.get(); |
} |
} // namespace WebCore |