| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 // FIXME: Consider using CallbackPromiseAdapter. | 86 // FIXME: Consider using CallbackPromiseAdapter. |
| 87 class CacheStorage::WithCacheCallbacks final : public WebServiceWorkerCacheStora
ge::CacheStorageWithCacheCallbacks { | 87 class CacheStorage::WithCacheCallbacks final : public WebServiceWorkerCacheStora
ge::CacheStorageWithCacheCallbacks { |
| 88 WTF_MAKE_NONCOPYABLE(WithCacheCallbacks); | 88 WTF_MAKE_NONCOPYABLE(WithCacheCallbacks); |
| 89 public: | 89 public: |
| 90 WithCacheCallbacks(const String& cacheName, CacheStorage* cacheStorage, Scri
ptPromiseResolver* resolver) | 90 WithCacheCallbacks(const String& cacheName, CacheStorage* cacheStorage, Scri
ptPromiseResolver* resolver) |
| 91 : m_cacheName(cacheName), m_cacheStorage(cacheStorage), m_resolver(resol
ver) { } | 91 : m_cacheName(cacheName), m_cacheStorage(cacheStorage), m_resolver(resol
ver) { } |
| 92 ~WithCacheCallbacks() override { } | 92 ~WithCacheCallbacks() override { } |
| 93 | 93 |
| 94 void onSuccess(WebPassOwnPtr<WebServiceWorkerCache> webCache) override | 94 void onSuccess(std::unique_ptr<WebServiceWorkerCache> webCache) override |
| 95 { | 95 { |
| 96 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) | 96 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) |
| 97 return; | 97 return; |
| 98 Cache* cache = Cache::create(m_cacheStorage->m_scopedFetcher, webCache.r
elease()); | 98 Cache* cache = Cache::create(m_cacheStorage->m_scopedFetcher, adoptPtr(w
ebCache.release())); |
| 99 m_cacheStorage->m_nameToCacheMap.set(m_cacheName, cache); | 99 m_cacheStorage->m_nameToCacheMap.set(m_cacheName, cache); |
| 100 m_resolver->resolve(cache); | 100 m_resolver->resolve(cache); |
| 101 m_resolver.clear(); | 101 m_resolver.clear(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void onError(WebServiceWorkerCacheError reason) override | 104 void onError(WebServiceWorkerCacheError reason) override |
| 105 { | 105 { |
| 106 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) | 106 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) |
| 107 return; | 107 return; |
| 108 if (reason == WebServiceWorkerCacheErrorNotFound) | 108 if (reason == WebServiceWorkerCacheErrorNotFound) |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 m_webCacheStorage.clear(); | 340 m_webCacheStorage.clear(); |
| 341 } | 341 } |
| 342 | 342 |
| 343 DEFINE_TRACE(CacheStorage) | 343 DEFINE_TRACE(CacheStorage) |
| 344 { | 344 { |
| 345 visitor->trace(m_scopedFetcher); | 345 visitor->trace(m_scopedFetcher); |
| 346 visitor->trace(m_nameToCacheMap); | 346 visitor->trace(m_nameToCacheMap); |
| 347 } | 347 } |
| 348 | 348 |
| 349 } // namespace blink | 349 } // namespace blink |
| OLD | NEW |