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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 m_resolver->reject(Cache::domExceptionForCacheError(*reason)); | 167 m_resolver->reject(Cache::domExceptionForCacheError(*reason)); |
168 m_resolver.clear(); | 168 m_resolver.clear(); |
169 } | 169 } |
170 | 170 |
171 private: | 171 private: |
172 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; | 172 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; |
173 }; | 173 }; |
174 | 174 |
175 CacheStorage* CacheStorage::create(WebServiceWorkerCacheStorage* webCacheStorage
) | 175 CacheStorage* CacheStorage::create(WebServiceWorkerCacheStorage* webCacheStorage
) |
176 { | 176 { |
177 return new CacheStorage(webCacheStorage); | 177 return new CacheStorage(adoptPtr(webCacheStorage)); |
178 } | 178 } |
179 | 179 |
180 ScriptPromise CacheStorage::open(ScriptState* scriptState, const String& cacheNa
me) | 180 ScriptPromise CacheStorage::open(ScriptState* scriptState, const String& cacheNa
me) |
181 { | 181 { |
182 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 182 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
183 const ScriptPromise promise = resolver->promise(); | 183 const ScriptPromise promise = resolver->promise(); |
184 | 184 |
185 if (m_nameToCacheMap.contains(cacheName)) { | 185 if (m_nameToCacheMap.contains(cacheName)) { |
186 Cache* cache = m_nameToCacheMap.find(cacheName)->value; | 186 Cache* cache = m_nameToCacheMap.find(cacheName)->value; |
187 resolver->resolve(cache); | 187 resolver->resolve(cache); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 resolver->reject(createNoImplementationException()); | 266 resolver->reject(createNoImplementationException()); |
267 | 267 |
268 return promise; | 268 return promise; |
269 } | 269 } |
270 | 270 |
271 DEFINE_TRACE(CacheStorage) | 271 DEFINE_TRACE(CacheStorage) |
272 { | 272 { |
273 visitor->trace(m_nameToCacheMap); | 273 visitor->trace(m_nameToCacheMap); |
274 } | 274 } |
275 | 275 |
276 CacheStorage::CacheStorage(WebServiceWorkerCacheStorage* webCacheStorage) | 276 CacheStorage::CacheStorage(PassOwnPtr<WebServiceWorkerCacheStorage> webCacheStor
age) |
277 : m_webCacheStorage(webCacheStorage) | 277 : m_webCacheStorage(webCacheStorage) |
278 { | 278 { |
279 } | 279 } |
280 | 280 |
281 } // namespace blink | 281 } // namespace blink |
OLD | NEW |