Index: Source/platform/exported/WebCryptoResult.cpp |
diff --git a/Source/platform/exported/WebCryptoResult.cpp b/Source/platform/exported/WebCryptoResult.cpp |
index d5515064a86e9aa829d129b2828f678f1820fadf..a01b3bd02f233de76c0884060011cd8d980a97d6 100644 |
--- a/Source/platform/exported/WebCryptoResult.cpp |
+++ b/Source/platform/exported/WebCryptoResult.cpp |
@@ -33,58 +33,72 @@ |
#include "platform/CryptoResult.h" |
#include "platform/heap/Heap.h" |
-#include <string.h> |
+#include "wtf/Atomics.h" |
namespace blink { |
void WebCryptoResult::completeWithError(WebCryptoErrorType errorType, const WebString& errorDetails) |
{ |
+ if (cancelled()) |
+ return; |
m_impl->completeWithError(errorType, errorDetails); |
- reset(); |
+ clear(); |
} |
void WebCryptoResult::completeWithBuffer(const void* bytes, unsigned bytesSize) |
{ |
+ if (cancelled()) |
+ return; |
m_impl->completeWithBuffer(bytes, bytesSize); |
- reset(); |
+ clear(); |
} |
void WebCryptoResult::completeWithJson(const char* utf8Data, unsigned length) |
{ |
+ if (cancelled()) |
+ return; |
m_impl->completeWithJson(utf8Data, length); |
- reset(); |
+ clear(); |
} |
void WebCryptoResult::completeWithBoolean(bool b) |
{ |
+ if (cancelled()) |
+ return; |
m_impl->completeWithBoolean(b); |
- reset(); |
+ clear(); |
} |
void WebCryptoResult::completeWithKey(const WebCryptoKey& key) |
{ |
+ if (cancelled()) |
+ return; |
ASSERT(!key.isNull()); |
m_impl->completeWithKey(key); |
- reset(); |
+ clear(); |
} |
void WebCryptoResult::completeWithKeyPair(const WebCryptoKey& publicKey, const WebCryptoKey& privateKey) |
{ |
+ if (cancelled()) |
+ return; |
ASSERT(!publicKey.isNull()); |
ASSERT(!privateKey.isNull()); |
m_impl->completeWithKeyPair(publicKey, privateKey); |
- reset(); |
+ clear(); |
} |
bool WebCryptoResult::cancelled() const |
{ |
- return m_impl->cancelled(); |
+ return acquireLoad(&m_cancelled); |
} |
WebCryptoResult::WebCryptoResult(const PassRefPtrWillBeRawPtr<CryptoResult>& impl) |
- : m_impl(impl) |
+ : m_cancelled(0) |
+ , m_impl(impl) |
{ |
ASSERT(m_impl.get()); |
+ m_impl->assignedTo(this); |
} |
void WebCryptoResult::reset() |
@@ -92,9 +106,22 @@ void WebCryptoResult::reset() |
m_impl.reset(); |
} |
+void WebCryptoResult::clear() |
+{ |
+ if (!m_impl.isNull()) { |
+ releaseStore(&m_cancelled, 1); |
+ m_impl->assignedTo(nullptr); |
+ } |
+ reset(); |
+} |
+ |
void WebCryptoResult::assign(const WebCryptoResult& o) |
{ |
+ ASSERT(!o.m_cancelled); |
+ ASSERT(!o.m_impl.isNull()); |
+ m_cancelled = o.m_cancelled; |
m_impl = o.m_impl; |
+ m_impl->assignedTo(this); |
} |
} // namespace blink |