OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "modules/cachestorage/Cache.h" | 6 #include "modules/cachestorage/Cache.h" |
7 | 7 |
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 public: | 89 public: |
90 explicit CacheDeleteCallback(ScriptPromiseResolver* resolver) | 90 explicit CacheDeleteCallback(ScriptPromiseResolver* resolver) |
91 : m_resolver(resolver) { } | 91 : m_resolver(resolver) { } |
92 | 92 |
93 void onSuccess() override | 93 void onSuccess() override |
94 { | 94 { |
95 m_resolver->resolve(true); | 95 m_resolver->resolve(true); |
96 m_resolver.clear(); | 96 m_resolver.clear(); |
97 } | 97 } |
98 | 98 |
99 void onError(WebPassOwnPtr<WebServiceWorkerCacheError> rawReason) override | 99 void onError(WebServiceWorkerCacheError reason) override |
100 { | 100 { |
101 OwnPtr<WebServiceWorkerCacheError> reason = rawReason.release(); | 101 if (reason == WebServiceWorkerCacheErrorNotFound) |
102 if (*reason == WebServiceWorkerCacheErrorNotFound) | |
103 m_resolver->resolve(false); | 102 m_resolver->resolve(false); |
104 else | 103 else |
105 m_resolver->reject(CacheStorageError::createException(*reason)); | 104 m_resolver->reject(CacheStorageError::createException(reason)); |
106 m_resolver.clear(); | 105 m_resolver.clear(); |
107 } | 106 } |
108 | 107 |
109 private: | 108 private: |
110 Persistent<ScriptPromiseResolver> m_resolver; | 109 Persistent<ScriptPromiseResolver> m_resolver; |
111 }; | 110 }; |
112 | 111 |
113 // FIXME: Consider using CallbackPromiseAdapter. | 112 // FIXME: Consider using CallbackPromiseAdapter. |
114 class CacheWithRequestsCallbacks : public WebServiceWorkerCache::CacheWithReques
tsCallbacks { | 113 class CacheWithRequestsCallbacks : public WebServiceWorkerCache::CacheWithReques
tsCallbacks { |
115 WTF_MAKE_NONCOPYABLE(CacheWithRequestsCallbacks); | 114 WTF_MAKE_NONCOPYABLE(CacheWithRequestsCallbacks); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); | 511 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); |
513 return promise; | 512 return promise; |
514 } | 513 } |
515 | 514 |
516 WebServiceWorkerCache* Cache::webCache() const | 515 WebServiceWorkerCache* Cache::webCache() const |
517 { | 516 { |
518 return m_webCache.get(); | 517 return m_webCache.get(); |
519 } | 518 } |
520 | 519 |
521 } // namespace blink | 520 } // namespace blink |
OLD | NEW |