| Index: Source/modules/crypto/CryptoOperation.cpp
|
| diff --git a/Source/modules/crypto/CryptoOperation.cpp b/Source/modules/crypto/CryptoOperation.cpp
|
| index acb7e65d7c400a8d9d475bd6a3413f764f5d606d..dff9858af591a68d2da390252f04b337be0114f7 100644
|
| --- a/Source/modules/crypto/CryptoOperation.cpp
|
| +++ b/Source/modules/crypto/CryptoOperation.cpp
|
| @@ -31,105 +31,16 @@
|
| #include "config.h"
|
| #include "modules/crypto/CryptoOperation.h"
|
|
|
| -#include "bindings/v8/custom/V8ArrayBufferCustom.h" // MUST precede ScriptPromiseResolver for compilation to work.
|
| -#include "bindings/v8/ScriptPromiseResolver.h"
|
| #include "modules/crypto/Algorithm.h"
|
| -#include "public/platform/WebArrayBuffer.h"
|
| -#include "public/platform/WebCrypto.h"
|
| -#include "wtf/ArrayBuffer.h"
|
| -#include "wtf/ArrayBufferView.h"
|
|
|
| namespace WebCore {
|
|
|
| -class CryptoOperation::Result : public WebKit::WebCryptoOperationResult {
|
| -public:
|
| - explicit Result(CryptoOperation* parent) : m_parent(parent) { }
|
| -
|
| - virtual void setArrayBuffer(const WebKit::WebArrayBuffer& buffer) OVERRIDE
|
| - {
|
| - ASSERT(m_parent->m_state == Finishing);
|
| - m_parent->m_state = Done;
|
| - m_parent->m_impl = 0;
|
| -
|
| - m_parent->promiseResolver()->fulfill(PassRefPtr<ArrayBuffer>(buffer));
|
| - }
|
| -
|
| -private:
|
| - CryptoOperation* m_parent;
|
| -};
|
| -
|
| -CryptoOperation::~CryptoOperation()
|
| -{
|
| - abort();
|
| - ASSERT(!m_impl);
|
| -}
|
| -
|
| -PassRefPtr<CryptoOperation> CryptoOperation::create(const WebKit::WebCryptoAlgorithm& algorithm, WebKit::WebCryptoOperation* impl)
|
| -{
|
| - return adoptRef(new CryptoOperation(algorithm, impl));
|
| -}
|
| -
|
| -CryptoOperation::CryptoOperation(const WebKit::WebCryptoAlgorithm& algorithm, WebKit::WebCryptoOperation* impl)
|
| +CryptoOperation::CryptoOperation(const WebKit::WebCryptoAlgorithm& algorithm)
|
| : m_algorithm(algorithm)
|
| - , m_impl(impl)
|
| - , m_state(Processing)
|
| - , m_result(adoptPtr(new Result(this)))
|
| {
|
| - ASSERT(impl);
|
| ScriptWrappable::init(this);
|
| }
|
|
|
| -CryptoOperation* CryptoOperation::process(ArrayBuffer* data)
|
| -{
|
| - process(static_cast<unsigned char*>(data->data()), data->byteLength());
|
| - return this;
|
| -}
|
| -
|
| -CryptoOperation* CryptoOperation::process(ArrayBufferView* data)
|
| -{
|
| - process(static_cast<unsigned char*>(data->baseAddress()), data->byteLength());
|
| - return this;
|
| -}
|
| -
|
| -ScriptObject CryptoOperation::finish()
|
| -{
|
| - switch (m_state) {
|
| - case Processing:
|
| - m_state = Finishing;
|
| - // NOTE: The following line can result in re-entrancy to |this|
|
| - m_impl->finish(m_result.get());
|
| - break;
|
| - case Finishing:
|
| - // Calling finish() twice is a no-op.
|
| - break;
|
| - case Done:
|
| - // Calling finish() after already complete is a no-op.
|
| - ASSERT(!m_impl);
|
| - break;
|
| - }
|
| -
|
| - return promiseResolver()->promise();
|
| -}
|
| -
|
| -ScriptObject CryptoOperation::abort()
|
| -{
|
| - switch (m_state) {
|
| - case Processing:
|
| - case Finishing:
|
| - // This will cause m_impl to be deleted.
|
| - m_impl->abort();
|
| - m_state = Done;
|
| - m_impl = 0;
|
| - promiseResolver()->reject(ScriptValue::createNull());
|
| - break;
|
| - case Done:
|
| - ASSERT(!m_impl);
|
| - break;
|
| - }
|
| -
|
| - return promiseResolver()->promise();
|
| -}
|
| -
|
| Algorithm* CryptoOperation::algorithm()
|
| {
|
| if (!m_algorithmNode)
|
| @@ -137,23 +48,4 @@ Algorithm* CryptoOperation::algorithm()
|
| return m_algorithmNode.get();
|
| }
|
|
|
| -void CryptoOperation::process(const unsigned char* bytes, size_t size)
|
| -{
|
| - switch (m_state) {
|
| - case Processing:
|
| - m_impl->process(bytes, size);
|
| - break;
|
| - case Finishing:
|
| - case Done:
|
| - return;
|
| - }
|
| -}
|
| -
|
| -ScriptPromiseResolver* CryptoOperation::promiseResolver()
|
| -{
|
| - if (!m_promiseResolver)
|
| - m_promiseResolver = ScriptPromiseResolver::create();
|
| - return m_promiseResolver.get();
|
| -}
|
| -
|
| } // namespace WebCore
|
|
|