| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 T::dispose(error); | 137 T::dispose(error); |
| 138 return; | 138 return; |
| 139 } | 139 } |
| 140 m_resolver->reject(T::take(m_resolver.get(), error)); | 140 m_resolver->reject(T::take(m_resolver.get(), error)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 private: | 143 private: |
| 144 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; | 144 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 template<typename S> |
| 148 class CallbackPromiseAdapter<S, void> final : public blink::WebCallbacks<typenam
e S::WebType, void> { |
| 149 WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter); |
| 150 public: |
| 151 explicit CallbackPromiseAdapter(PassRefPtrWillBeRawPtr<ScriptPromiseResolver
> resolver) |
| 152 : m_resolver(resolver) |
| 153 { |
| 154 ASSERT(m_resolver); |
| 155 } |
| 156 virtual ~CallbackPromiseAdapter() { } |
| 157 |
| 158 virtual void onSuccess(typename S::WebType* result) override |
| 159 { |
| 160 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) { |
| 161 S::dispose(result); |
| 162 return; |
| 163 } |
| 164 m_resolver->resolve(S::take(m_resolver.get(), result)); |
| 165 } |
| 166 |
| 167 virtual void onError() override |
| 168 { |
| 169 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
| 170 return; |
| 171 m_resolver->reject(); |
| 172 } |
| 173 |
| 174 private: |
| 175 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; |
| 176 }; |
| 177 |
| 147 template<typename T> | 178 template<typename T> |
| 148 class CallbackPromiseAdapter<bool, T> final : public blink::WebCallbacks<bool, t
ypename T::WebType> { | 179 class CallbackPromiseAdapter<bool, T> final : public blink::WebCallbacks<bool, t
ypename T::WebType> { |
| 149 WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter); | 180 WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter); |
| 150 public: | 181 public: |
| 151 explicit CallbackPromiseAdapter(PassRefPtrWillBeRawPtr<ScriptPromiseResolver
> resolver) | 182 explicit CallbackPromiseAdapter(PassRefPtrWillBeRawPtr<ScriptPromiseResolver
> resolver) |
| 152 : m_resolver(resolver) | 183 : m_resolver(resolver) |
| 153 { | 184 { |
| 154 ASSERT(m_resolver); | 185 ASSERT(m_resolver); |
| 155 } | 186 } |
| 156 virtual ~CallbackPromiseAdapter() { } | 187 virtual ~CallbackPromiseAdapter() { } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 m_resolver->reject(); | 260 m_resolver->reject(); |
| 230 } | 261 } |
| 231 | 262 |
| 232 private: | 263 private: |
| 233 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; | 264 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; |
| 234 }; | 265 }; |
| 235 | 266 |
| 236 } // namespace blink | 267 } // namespace blink |
| 237 | 268 |
| 238 #endif | 269 #endif |
| OLD | NEW |