OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 if (!resolver->executionContext() || resolver->executionContext()->activeDOM
ObjectsAreStopped()) | 55 if (!resolver->executionContext() || resolver->executionContext()->activeDOM
ObjectsAreStopped()) |
56 return; | 56 return; |
57 | 57 |
58 ScriptState::Scope scope(resolver->scriptState()); | 58 ScriptState::Scope scope(resolver->scriptState()); |
59 v8::Isolate* isolate = resolver->scriptState()->isolate(); | 59 v8::Isolate* isolate = resolver->scriptState()->isolate(); |
60 resolver->reject(v8::Exception::TypeError(v8String(isolate, errorDetails))); | 60 resolver->reject(v8::Exception::TypeError(v8String(isolate, errorDetails))); |
61 } | 61 } |
62 | 62 |
63 class CryptoResultImpl::Resolver final : public ScriptPromiseResolver { | 63 class CryptoResultImpl::Resolver final : public ScriptPromiseResolver { |
64 public: | 64 public: |
65 static PassRefPtr<ScriptPromiseResolver> create(ScriptState* scriptState, Cr
yptoResultImpl* result) | 65 static PassRefPtrWillBeRawPtr<ScriptPromiseResolver> create(ScriptState* scr
iptState, CryptoResultImpl* result) |
66 { | 66 { |
67 RefPtr<Resolver> resolver = adoptRef(new Resolver(scriptState, result)); | 67 RefPtrWillBeRawPtr<Resolver> resolver = adoptRefWillBeNoop(new Resolver(
scriptState, result)); |
68 resolver->suspendIfNeeded(); | 68 resolver->suspendIfNeeded(); |
69 resolver->keepAliveWhilePending(); | 69 resolver->keepAliveWhilePending(); |
70 return resolver.release(); | 70 return resolver.release(); |
71 } | 71 } |
72 | 72 |
73 virtual void stop() override | 73 virtual void stop() override |
74 { | 74 { |
75 m_result->cancel(); | 75 m_result->cancel(); |
76 m_result->clearResolver(); | 76 m_result->clearResolver(); |
77 m_result = nullptr; | 77 m_result = nullptr; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 CryptoResultImpl::~CryptoResultImpl() | 109 CryptoResultImpl::~CryptoResultImpl() |
110 { | 110 { |
111 ASSERT(!m_resolver); | 111 ASSERT(!m_resolver); |
112 } | 112 } |
113 | 113 |
114 void CryptoResultImpl::clearResolver() | 114 void CryptoResultImpl::clearResolver() |
115 { | 115 { |
116 m_resolver = nullptr; | 116 m_resolver = nullptr; |
117 } | 117 } |
118 | 118 |
119 PassRefPtr<CryptoResultImpl> CryptoResultImpl::create(ScriptState* scriptState) | 119 PassRefPtrWillBeRawPtr<CryptoResultImpl> CryptoResultImpl::create(ScriptState* s
criptState) |
120 { | 120 { |
121 return adoptRef(new CryptoResultImpl(scriptState)); | 121 return adoptRefWillBeNoop(new CryptoResultImpl(scriptState)); |
122 } | 122 } |
123 | 123 |
124 void CryptoResultImpl::completeWithError(WebCryptoErrorType errorType, const Web
String& errorDetails) | 124 void CryptoResultImpl::completeWithError(WebCryptoErrorType errorType, const Web
String& errorDetails) |
125 { | 125 { |
126 if (m_resolver) { | 126 if (m_resolver) { |
127 ExceptionCode ec = webCryptoErrorToExceptionCode(errorType); | 127 ExceptionCode ec = webCryptoErrorToExceptionCode(errorType); |
128 | 128 |
129 // Handle TypeError separately, as it cannot be created using | 129 // Handle TypeError separately, as it cannot be created using |
130 // DOMException. | 130 // DOMException. |
131 if (ec == V8TypeError) | 131 if (ec == V8TypeError) |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 m_resolver = Resolver::create(scriptState, this).get(); | 219 m_resolver = Resolver::create(scriptState, this).get(); |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 ScriptPromise CryptoResultImpl::promise() | 223 ScriptPromise CryptoResultImpl::promise() |
224 { | 224 { |
225 return m_resolver ? m_resolver->promise() : ScriptPromise(); | 225 return m_resolver ? m_resolver->promise() : ScriptPromise(); |
226 } | 226 } |
227 | 227 |
228 } // namespace blink | 228 } // namespace blink |
OLD | NEW |