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

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

Issue 23338006: Cleanup: remove WebCryptoResultPrivate from blink API. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove extra newline Created 7 years, 4 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/CryptoResult.h ('k') | Source/modules/crypto/SubtleCrypto.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/crypto/CryptoResult.cpp
diff --git a/Source/core/platform/chromium/support/WebCrypto.cpp b/Source/modules/crypto/CryptoResult.cpp
similarity index 54%
copy from Source/core/platform/chromium/support/WebCrypto.cpp
copy to Source/modules/crypto/CryptoResult.cpp
index cd4e17994c0a1e2ef82dac335249a385579ac96f..d2885527dc1e733361917d1427cb9569d9e01fed 100644
--- a/Source/core/platform/chromium/support/WebCrypto.cpp
+++ b/Source/modules/crypto/CryptoResult.cpp
@@ -29,58 +29,68 @@
*/
#include "config.h"
+#include "modules/crypto/CryptoResult.h"
+
+#include "V8Key.h" // Must precede ScriptPromiseResolver.h
+#include "bindings/v8/custom/V8ArrayBufferCustom.h" // Must precede ScriptPromiseResolver.h
+#include "bindings/v8/ScriptPromiseResolver.h"
+#include "modules/crypto/Key.h"
+#include "modules/crypto/NormalizeAlgorithm.h"
+#include "public/platform/Platform.h"
#include "public/platform/WebArrayBuffer.h"
#include "public/platform/WebCrypto.h"
-#include <string.h>
+#include "public/platform/WebCryptoAlgorithm.h"
+#include "wtf/ArrayBufferView.h"
-namespace WebKit {
+namespace WebCore {
-void WebCryptoResult::completeWithError()
+CryptoResult::~CryptoResult()
{
- m_impl->completeWithError();
- reset();
+ ASSERT(m_finished);
}
-void WebCryptoResult::completeWithBuffer(const WebArrayBuffer& buffer)
+PassRefPtr<CryptoResult> CryptoResult::create()
{
- RELEASE_ASSERT(!buffer.isNull());
- m_impl->completeWithBuffer(buffer);
- reset();
+ return adoptRef(new CryptoResult);
}
-void WebCryptoResult::completeWithBuffer(const void* bytes, size_t bytesSize)
+void CryptoResult::completeWithError()
{
- WebArrayBuffer buffer = WebKit::WebArrayBuffer::create(bytesSize, 1);
- RELEASE_ASSERT(!buffer.isNull());
- memcpy(buffer.data(), bytes, bytesSize);
- completeWithBuffer(buffer);
+ m_promiseResolver->reject(ScriptValue::createNull());
+ finish();
}
-void WebCryptoResult::completeWithBoolean(bool b)
+void CryptoResult::completeWithBuffer(const WebKit::WebArrayBuffer& buffer)
{
- m_impl->completeWithBoolean(b);
- reset();
+ m_promiseResolver->fulfill(PassRefPtr<ArrayBuffer>(buffer));
+ finish();
}
-void WebCryptoResult::completeWithKey(const WebCryptoKey& key)
+void CryptoResult::completeWithBoolean(bool b)
{
- m_impl->completeWithKey(key);
- reset();
+ m_promiseResolver->fulfill(ScriptValue::createBoolean(b));
+ finish();
}
-void WebCryptoResult::reset()
+void CryptoResult::completeWithKey(const WebKit::WebCryptoKey& key)
{
- m_impl.reset();
+ m_promiseResolver->fulfill(Key::create(key));
+ finish();
}
-void WebCryptoResult::assign(const WebCryptoResult& o)
+ScriptObject CryptoResult::promise()
{
- m_impl = o.m_impl;
+ return m_promiseResolver->promise();
}
-void WebCryptoResult::assign(WebCryptoResultPrivate* impl)
+CryptoResult::CryptoResult()
+ : m_promiseResolver(ScriptPromiseResolver::create())
+ , m_finished(false) { }
+
+void CryptoResult::finish()
{
- m_impl = impl;
+ ASSERT(!m_finished);
+ m_finished = true;
}
-} // namespace WebKit
+} // namespace WebCore
« no previous file with comments | « Source/modules/crypto/CryptoResult.h ('k') | Source/modules/crypto/SubtleCrypto.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698