| 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/serviceworkers/CacheStorage.h" | 6 #include "modules/serviceworkers/CacheStorage.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 // FIXME: Consider using CallbackPromiseAdapter. | 50 // FIXME: Consider using CallbackPromiseAdapter. |
| 51 class CacheStorageWithCacheCallbacks : public WebServiceWorkerCacheStorage::Cach
eStorageWithCacheCallbacks { | 51 class CacheStorageWithCacheCallbacks : public WebServiceWorkerCacheStorage::Cach
eStorageWithCacheCallbacks { |
| 52 WTF_MAKE_NONCOPYABLE(CacheStorageWithCacheCallbacks); | 52 WTF_MAKE_NONCOPYABLE(CacheStorageWithCacheCallbacks); |
| 53 public: | 53 public: |
| 54 explicit CacheStorageWithCacheCallbacks(PassRefPtr<ScriptPromiseResolver> re
solver) : m_resolver(resolver) { } | 54 explicit CacheStorageWithCacheCallbacks(PassRefPtr<ScriptPromiseResolver> re
solver) : m_resolver(resolver) { } |
| 55 virtual ~CacheStorageWithCacheCallbacks() { } | 55 virtual ~CacheStorageWithCacheCallbacks() { } |
| 56 | 56 |
| 57 virtual void onSuccess(WebServiceWorkerCache* cache) OVERRIDE | 57 virtual void onSuccess(WebServiceWorkerCache* cache) OVERRIDE |
| 58 { | 58 { |
| 59 // FIXME: Remove this once content's WebServiceWorkerCache implementatio
n has landed. |
| 60 if (!cache) { |
| 61 m_resolver->reject("not implemented"); |
| 62 return; |
| 63 } |
| 59 m_resolver->resolve(Cache::fromWebServiceWorkerCache(cache)); | 64 m_resolver->resolve(Cache::fromWebServiceWorkerCache(cache)); |
| 60 m_resolver.clear(); | 65 m_resolver.clear(); |
| 61 } | 66 } |
| 62 | 67 |
| 63 virtual void onError(WebServiceWorkerCacheError* reason) OVERRIDE | 68 virtual void onError(WebServiceWorkerCacheError* reason) OVERRIDE |
| 64 { | 69 { |
| 65 if (*reason == WebServiceWorkerCacheErrorNotFound) | 70 if (*reason == WebServiceWorkerCacheErrorNotFound) |
| 66 m_resolver->resolve(); | 71 m_resolver->resolve(false); |
| 67 else | 72 else |
| 68 m_resolver->resolve(Cache::domExceptionForCacheError(*reason)); | 73 m_resolver->resolve(Cache::domExceptionForCacheError(*reason)); |
| 69 m_resolver.clear(); | 74 m_resolver.clear(); |
| 70 } | 75 } |
| 71 | 76 |
| 72 private: | 77 private: |
| 73 RefPtr<ScriptPromiseResolver> m_resolver; | 78 RefPtr<ScriptPromiseResolver> m_resolver; |
| 74 }; | 79 }; |
| 75 | 80 |
| 76 // FIXME: Consider using CallbackPromiseAdapter. | 81 // FIXME: Consider using CallbackPromiseAdapter. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 175 |
| 171 return promise; | 176 return promise; |
| 172 } | 177 } |
| 173 | 178 |
| 174 CacheStorage::CacheStorage(WebServiceWorkerCacheStorage* webCacheStorage) : m_we
bCacheStorage(webCacheStorage) | 179 CacheStorage::CacheStorage(WebServiceWorkerCacheStorage* webCacheStorage) : m_we
bCacheStorage(webCacheStorage) |
| 175 { | 180 { |
| 176 ScriptWrappable::init(this); | 181 ScriptWrappable::init(this); |
| 177 } | 182 } |
| 178 | 183 |
| 179 } // namespace blink | 184 } // namespace blink |
| OLD | NEW |