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

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

Issue 780793002: Make CryptoResultImpl not to use WeakPtr. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
Index: Source/modules/crypto/CryptoResultImpl.cpp
diff --git a/Source/modules/crypto/CryptoResultImpl.cpp b/Source/modules/crypto/CryptoResultImpl.cpp
index 18f45f92f91164f107de07d2b54f144feaee3bcf..9c5161b31c1fa66c2cd7e605b840f90a9775c475 100644
--- a/Source/modules/crypto/CryptoResultImpl.cpp
+++ b/Source/modules/crypto/CryptoResultImpl.cpp
@@ -50,26 +50,24 @@ namespace blink {
class CryptoResultImpl::WeakResolver : public ScriptPromiseResolver {
public:
- static WeakPtr<ScriptPromiseResolver> create(ScriptState* scriptState, CryptoResultImpl* result)
+ static PassRefPtr<ScriptPromiseResolver> create(ScriptState* scriptState, CryptoResultImpl* result)
{
RefPtr<WeakResolver> p = adoptRef(new WeakResolver(scriptState, result));
p->suspendIfNeeded();
p->keepAliveWhilePending();
- return p->m_weakPtrFactory.createWeakPtr();
+ return p.release();
}
- virtual ~WeakResolver()
+private:
+ virtual void resolverCleared() override
{
m_result->cancel();
}
-private:
WeakResolver(ScriptState* scriptState, CryptoResultImpl* result)
: ScriptPromiseResolver(scriptState)
- , m_weakPtrFactory(this)
, m_result(result) { }
- WeakPtrFactory<ScriptPromiseResolver> m_weakPtrFactory;
- RefPtr<CryptoResultImpl> m_result;
+ CryptoResultImpl* m_result;
};
ExceptionCode webCryptoErrorToExceptionCode(WebCryptoErrorType errorType)
@@ -102,6 +100,7 @@ ExceptionCode webCryptoErrorToExceptionCode(WebCryptoErrorType errorType)
CryptoResultImpl::~CryptoResultImpl()
{
+ ASSERT(!m_resolver || m_resolver->stopped());
tasak 2014/12/04 08:08:01 Check whether WeakResoler has been already stopped
}
PassRefPtr<CryptoResultImpl> CryptoResultImpl::create(ScriptState* scriptState)
@@ -179,6 +178,7 @@ bool CryptoResultImpl::cancelled() const
void CryptoResultImpl::cancel()
{
releaseStore(&m_cancelled, 1);
+ m_resolver = nullptr;
tasak 2014/12/04 08:08:01 To avoid the following ASSERTION failure, CryptoRe
}
CryptoResultImpl::CryptoResultImpl(ScriptState* scriptState)
« Source/bindings/core/v8/ScriptPromiseResolver.h ('K') | « Source/modules/crypto/CryptoResultImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698