| 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" |
| 11 #include "bindings/core/v8/ScriptState.h" | 11 #include "bindings/core/v8/ScriptState.h" |
| 12 #include "bindings/core/v8/V8Binding.h" | 12 #include "bindings/core/v8/V8Binding.h" |
| 13 #include "bindings/core/v8/V8ThrowException.h" | 13 #include "bindings/core/v8/V8ThrowException.h" |
| 14 #include "bindings/modules/v8/V8Response.h" | 14 #include "bindings/modules/v8/V8Response.h" |
| 15 #include "core/dom/DOMException.h" | 15 #include "core/dom/DOMException.h" |
| 16 #include "core/dom/ExceptionCode.h" | 16 #include "core/dom/ExceptionCode.h" |
| 17 #include "modules/cachestorage/CacheStorageError.h" | 17 #include "modules/cachestorage/CacheStorageError.h" |
| 18 #include "modules/fetch/BodyStreamBuffer.h" | 18 #include "modules/fetch/BodyStreamBuffer.h" |
| 19 #include "modules/fetch/FetchDataLoader.h" | 19 #include "modules/fetch/FetchDataLoader.h" |
| 20 #include "modules/fetch/GlobalFetch.h" | 20 #include "modules/fetch/GlobalFetch.h" |
| 21 #include "modules/fetch/Request.h" | 21 #include "modules/fetch/Request.h" |
| 22 #include "modules/fetch/Response.h" | 22 #include "modules/fetch/Response.h" |
| 23 #include "public/platform/WebPassOwnPtr.h" |
| 23 #include "public/platform/WebServiceWorkerCache.h" | 24 #include "public/platform/WebServiceWorkerCache.h" |
| 24 | 25 |
| 25 namespace blink { | 26 namespace blink { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 // FIXME: Consider using CallbackPromiseAdapter. | 30 // FIXME: Consider using CallbackPromiseAdapter. |
| 30 class CacheMatchCallbacks : public WebServiceWorkerCache::CacheMatchCallbacks { | 31 class CacheMatchCallbacks : public WebServiceWorkerCache::CacheMatchCallbacks { |
| 31 WTF_MAKE_NONCOPYABLE(CacheMatchCallbacks); | 32 WTF_MAKE_NONCOPYABLE(CacheMatchCallbacks); |
| 32 public: | 33 public: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 public: | 89 public: |
| 89 explicit CacheDeleteCallback(ScriptPromiseResolver* resolver) | 90 explicit CacheDeleteCallback(ScriptPromiseResolver* resolver) |
| 90 : m_resolver(resolver) { } | 91 : m_resolver(resolver) { } |
| 91 | 92 |
| 92 void onSuccess() override | 93 void onSuccess() override |
| 93 { | 94 { |
| 94 m_resolver->resolve(true); | 95 m_resolver->resolve(true); |
| 95 m_resolver.clear(); | 96 m_resolver.clear(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 // Ownership of |rawReason| must be passed. | 99 void onError(WebPassOwnPtr<WebServiceWorkerCacheError> rawReason) override |
| 99 void onError(WebServiceWorkerCacheError* rawReason) override | |
| 100 { | 100 { |
| 101 OwnPtr<WebServiceWorkerCacheError> reason = adoptPtr(rawReason); | 101 OwnPtr<WebServiceWorkerCacheError> reason = rawReason.release(); |
| 102 if (*reason == WebServiceWorkerCacheErrorNotFound) | 102 if (*reason == WebServiceWorkerCacheErrorNotFound) |
| 103 m_resolver->resolve(false); | 103 m_resolver->resolve(false); |
| 104 else | 104 else |
| 105 m_resolver->reject(CacheStorageError::createException(*reason)); | 105 m_resolver->reject(CacheStorageError::createException(*reason)); |
| 106 m_resolver.clear(); | 106 m_resolver.clear(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 Persistent<ScriptPromiseResolver> m_resolver; | 110 Persistent<ScriptPromiseResolver> m_resolver; |
| 111 }; | 111 }; |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); | 512 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); |
| 513 return promise; | 513 return promise; |
| 514 } | 514 } |
| 515 | 515 |
| 516 WebServiceWorkerCache* Cache::webCache() const | 516 WebServiceWorkerCache* Cache::webCache() const |
| 517 { | 517 { |
| 518 return m_webCache.get(); | 518 return m_webCache.get(); |
| 519 } | 519 } |
| 520 | 520 |
| 521 } // namespace blink | 521 } // namespace blink |
| OLD | NEW |