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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return; | 163 return; |
164 } | 164 } |
165 m_resolver->reject(T::take(m_resolver.get(), error)); | 165 m_resolver->reject(T::take(m_resolver.get(), error)); |
166 } | 166 } |
167 | 167 |
168 private: | 168 private: |
169 RefPtr<ScriptPromiseResolver> m_resolver; | 169 RefPtr<ScriptPromiseResolver> m_resolver; |
170 WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter); | 170 WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter); |
171 }; | 171 }; |
172 | 172 |
| 173 template<> |
| 174 class CallbackPromiseAdapter<void, void> final : public blink::WebCallbacks<void
, void> { |
| 175 public: |
| 176 explicit CallbackPromiseAdapter(PassRefPtr<ScriptPromiseResolver> resolver) |
| 177 : m_resolver(resolver) |
| 178 { |
| 179 ASSERT(m_resolver); |
| 180 } |
| 181 virtual ~CallbackPromiseAdapter() { } |
| 182 |
| 183 virtual void onSuccess() override |
| 184 { |
| 185 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
| 186 return; |
| 187 m_resolver->resolve(); |
| 188 } |
| 189 |
| 190 virtual void onError() override |
| 191 { |
| 192 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
| 193 return; |
| 194 m_resolver->reject(); |
| 195 } |
| 196 |
| 197 private: |
| 198 RefPtr<ScriptPromiseResolver> m_resolver; |
| 199 WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter); |
| 200 }; |
| 201 |
173 } // namespace blink | 202 } // namespace blink |
174 | 203 |
175 #endif | 204 #endif |
OLD | NEW |