| Index: Source/modules/crypto/CryptoResultImpl.cpp
|
| diff --git a/Source/modules/crypto/CryptoResultImpl.cpp b/Source/modules/crypto/CryptoResultImpl.cpp
|
| index 2360727a13a91f34ae1e4352523c2068b1c2c2e2..d35fbcadbd43d0d76ca336d9760ed1f7cdc67ca2 100644
|
| --- a/Source/modules/crypto/CryptoResultImpl.cpp
|
| +++ b/Source/modules/crypto/CryptoResultImpl.cpp
|
| @@ -63,12 +63,13 @@ static void rejectWithTypeError(const String& errorDetails, ScriptPromiseResolve
|
|
|
| class CryptoResultImpl::Resolver final : public ScriptPromiseResolver {
|
| public:
|
| - static PassRefPtrWillBeRawPtr<ScriptPromiseResolver> create(ScriptState* scriptState, CryptoResultImpl* result)
|
| + static Resolver* create(ScriptState* scriptState, CryptoResultImpl* result)
|
| {
|
| - RefPtrWillBeRawPtr<Resolver> resolver = adoptRefWillBeNoop(new Resolver(scriptState, result));
|
| + ASSERT(scriptState->contextIsValid());
|
| + Resolver* resolver = new Resolver(scriptState, result);
|
| resolver->suspendIfNeeded();
|
| resolver->keepAliveWhilePending();
|
| - return resolver.release();
|
| + return resolver;
|
| }
|
|
|
| void stop() override
|
| @@ -79,11 +80,18 @@ public:
|
| ScriptPromiseResolver::stop();
|
| }
|
|
|
| + DEFINE_INLINE_VIRTUAL_TRACE()
|
| + {
|
| + visitor->trace(m_result);
|
| + ScriptPromiseResolver::trace(visitor);
|
| + }
|
| +
|
| private:
|
| Resolver(ScriptState* scriptState, CryptoResultImpl* result)
|
| : ScriptPromiseResolver(scriptState)
|
| , m_result(result) { }
|
| - RefPtr<CryptoResultImpl> m_result;
|
| +
|
| + Member<CryptoResultImpl> m_result;
|
| };
|
|
|
| ExceptionCode webCryptoErrorToExceptionCode(WebCryptoErrorType errorType)
|
| @@ -107,19 +115,31 @@ ExceptionCode webCryptoErrorToExceptionCode(WebCryptoErrorType errorType)
|
| return 0;
|
| }
|
|
|
| +CryptoResultImpl::CryptoResultImpl(ScriptState* scriptState)
|
| + : m_cancelled(0)
|
| +{
|
| + m_resolver = Resolver::create(scriptState, this);
|
| +}
|
| +
|
| CryptoResultImpl::~CryptoResultImpl()
|
| {
|
| ASSERT(!m_resolver);
|
| }
|
|
|
| +DEFINE_TRACE(CryptoResultImpl)
|
| +{
|
| + visitor->trace(m_resolver);
|
| + CryptoResult::trace(visitor);
|
| +}
|
| +
|
| void CryptoResultImpl::clearResolver()
|
| {
|
| m_resolver = nullptr;
|
| }
|
|
|
| -PassRefPtrWillBeRawPtr<CryptoResultImpl> CryptoResultImpl::create(ScriptState* scriptState)
|
| +CryptoResultImpl* CryptoResultImpl::create(ScriptState* scriptState)
|
| {
|
| - return adoptRefWillBeNoop(new CryptoResultImpl(scriptState));
|
| + return new CryptoResultImpl(scriptState);
|
| }
|
|
|
| void CryptoResultImpl::completeWithError(WebCryptoErrorType errorType, const WebString& errorDetails)
|
| @@ -203,19 +223,6 @@ void CryptoResultImpl::cancel()
|
| releaseStore(&m_cancelled, 1);
|
| }
|
|
|
| -CryptoResultImpl::CryptoResultImpl(ScriptState* scriptState)
|
| - : m_cancelled(0)
|
| -{
|
| - ASSERT(scriptState->contextIsValid());
|
| - if (scriptState->executionContext()->activeDOMObjectsAreStopped()) {
|
| - // If active dom objects have been stopped, avoid creating
|
| - // CryptoResultResolver.
|
| - m_resolver = nullptr;
|
| - } else {
|
| - m_resolver = Resolver::create(scriptState, this).get();
|
| - }
|
| -}
|
| -
|
| ScriptPromise CryptoResultImpl::promise()
|
| {
|
| return m_resolver ? m_resolver->promise() : ScriptPromise();
|
|
|