| 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 "modules/cachestorage/CacheStorage.h" | 5 #include "modules/cachestorage/CacheStorage.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 : m_cacheName(cacheName), | 87 : m_cacheName(cacheName), |
| 88 m_cacheStorage(cacheStorage), | 88 m_cacheStorage(cacheStorage), |
| 89 m_resolver(resolver) {} | 89 m_resolver(resolver) {} |
| 90 ~WithCacheCallbacks() override {} | 90 ~WithCacheCallbacks() override {} |
| 91 | 91 |
| 92 void onSuccess(std::unique_ptr<WebServiceWorkerCache> webCache) override { | 92 void onSuccess(std::unique_ptr<WebServiceWorkerCache> webCache) override { |
| 93 if (!m_resolver->getExecutionContext() || | 93 if (!m_resolver->getExecutionContext() || |
| 94 m_resolver->getExecutionContext()->isContextDestroyed()) | 94 m_resolver->getExecutionContext()->isContextDestroyed()) |
| 95 return; | 95 return; |
| 96 Cache* cache = Cache::create(m_cacheStorage->m_scopedFetcher, | 96 Cache* cache = Cache::create(m_cacheStorage->m_scopedFetcher, |
| 97 wrapUnique(webCache.release())); | 97 WTF::wrapUnique(webCache.release())); |
| 98 m_resolver->resolve(cache); | 98 m_resolver->resolve(cache); |
| 99 m_resolver.clear(); | 99 m_resolver.clear(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void onError(WebServiceWorkerCacheError reason) override { | 102 void onError(WebServiceWorkerCacheError reason) override { |
| 103 if (!m_resolver->getExecutionContext() || | 103 if (!m_resolver->getExecutionContext() || |
| 104 m_resolver->getExecutionContext()->isContextDestroyed()) | 104 m_resolver->getExecutionContext()->isContextDestroyed()) |
| 105 return; | 105 return; |
| 106 if (reason == WebServiceWorkerCacheErrorNotFound) | 106 if (reason == WebServiceWorkerCacheErrorNotFound) |
| 107 m_resolver->resolve(); | 107 m_resolver->resolve(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 m_resolver.clear(); | 219 m_resolver.clear(); |
| 220 } | 220 } |
| 221 | 221 |
| 222 private: | 222 private: |
| 223 Persistent<ScriptPromiseResolver> m_resolver; | 223 Persistent<ScriptPromiseResolver> m_resolver; |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 CacheStorage* CacheStorage::create( | 226 CacheStorage* CacheStorage::create( |
| 227 GlobalFetch::ScopedFetcher* fetcher, | 227 GlobalFetch::ScopedFetcher* fetcher, |
| 228 WebServiceWorkerCacheStorage* webCacheStorage) { | 228 WebServiceWorkerCacheStorage* webCacheStorage) { |
| 229 return new CacheStorage(fetcher, wrapUnique(webCacheStorage)); | 229 return new CacheStorage(fetcher, WTF::wrapUnique(webCacheStorage)); |
| 230 } | 230 } |
| 231 | 231 |
| 232 ScriptPromise CacheStorage::open(ScriptState* scriptState, | 232 ScriptPromise CacheStorage::open(ScriptState* scriptState, |
| 233 const String& cacheName, | 233 const String& cacheName, |
| 234 ExceptionState& exceptionState) { | 234 ExceptionState& exceptionState) { |
| 235 if (!commonChecks(scriptState, exceptionState)) | 235 if (!commonChecks(scriptState, exceptionState)) |
| 236 return ScriptPromise(); | 236 return ScriptPromise(); |
| 237 | 237 |
| 238 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 238 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 239 const ScriptPromise promise = resolver->promise(); | 239 const ScriptPromise promise = resolver->promise(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 353 |
| 354 void CacheStorage::dispose() { | 354 void CacheStorage::dispose() { |
| 355 m_webCacheStorage.reset(); | 355 m_webCacheStorage.reset(); |
| 356 } | 356 } |
| 357 | 357 |
| 358 DEFINE_TRACE(CacheStorage) { | 358 DEFINE_TRACE(CacheStorage) { |
| 359 visitor->trace(m_scopedFetcher); | 359 visitor->trace(m_scopedFetcher); |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace blink | 362 } // namespace blink |
| OLD | NEW |