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

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

Issue 343723003: [webcrypto] Allow crypto operations to be cancelled by the platform implementation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix comment typo Created 6 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/CryptoResultImpl.h ('k') | Source/platform/CryptoResult.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/crypto/CryptoResultImpl.cpp
diff --git a/Source/modules/crypto/CryptoResultImpl.cpp b/Source/modules/crypto/CryptoResultImpl.cpp
index e2d4f9edc5497be693b8a6d4db6f7190f9b56955..92891da37bba93b6a8a6f57a12f095382a0551bc 100644
--- a/Source/modules/crypto/CryptoResultImpl.cpp
+++ b/Source/modules/crypto/CryptoResultImpl.cpp
@@ -47,27 +47,30 @@
namespace WebCore {
-namespace {
-
-class WeakResolver : public ScriptPromiseResolverWithContext {
+class CryptoResultImpl::WeakResolver : public ScriptPromiseResolverWithContext {
public:
- static WeakPtr<ScriptPromiseResolverWithContext> create(ScriptState* scriptState)
+ static WeakPtr<ScriptPromiseResolverWithContext> create(ScriptState* scriptState, CryptoResultImpl* result)
{
- RefPtr<WeakResolver> p = adoptRef(new WeakResolver(scriptState));
+ RefPtr<WeakResolver> p = adoptRef(new WeakResolver(scriptState, result));
p->suspendIfNeeded();
p->keepAliveWhilePending();
return p->m_weakPtrFactory.createWeakPtr();
}
+ virtual ~WeakResolver()
+ {
+ m_result->cancel();
+ }
+
private:
- explicit WeakResolver(ScriptState* scriptState)
+ WeakResolver(ScriptState* scriptState, CryptoResultImpl* result)
: ScriptPromiseResolverWithContext(scriptState)
- , m_weakPtrFactory(this) { }
+ , m_weakPtrFactory(this)
+ , m_result(result) { }
WeakPtrFactory<ScriptPromiseResolverWithContext> m_weakPtrFactory;
+ RefPtr<CryptoResultImpl> m_result;
};
-} // namespace
-
ExceptionCode webCryptoErrorToExceptionCode(blink::WebCryptoErrorType errorType)
{
switch (errorType) {
@@ -155,8 +158,19 @@ void CryptoResultImpl::completeWithKeyPair(const blink::WebCryptoKey& publicKey,
m_resolver->resolve(KeyPair::create(publicKey, privateKey));
}
+bool CryptoResultImpl::cancelled() const
+{
+ return acquireLoad(&m_cancelled);
+}
+
+void CryptoResultImpl::cancel()
+{
+ releaseStore(&m_cancelled, 1);
+}
+
CryptoResultImpl::CryptoResultImpl(ScriptState* scriptState)
- : m_resolver(WeakResolver::create(scriptState))
+ : m_resolver(WeakResolver::create(scriptState, this))
+ , m_cancelled(0)
{
}
« no previous file with comments | « Source/modules/crypto/CryptoResultImpl.h ('k') | Source/platform/CryptoResult.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698