| 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/CacheStorage.h" | 6 #include "modules/cachestorage/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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 196 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
| 197 return; | 197 return; |
| 198 m_resolver->reject(CacheStorageError::createException(reason)); | 198 m_resolver->reject(CacheStorageError::createException(reason)); |
| 199 m_resolver.clear(); | 199 m_resolver.clear(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 private: | 202 private: |
| 203 Persistent<ScriptPromiseResolver> m_resolver; | 203 Persistent<ScriptPromiseResolver> m_resolver; |
| 204 }; | 204 }; |
| 205 | 205 |
| 206 CacheStorage* CacheStorage::create(WeakPtr<GlobalFetch::ScopedFetcher> fetcher,
WebServiceWorkerCacheStorage* webCacheStorage) | 206 CacheStorage* CacheStorage::create(WeakPtrWillBeRawPtr<GlobalFetch::ScopedFetche
r> fetcher, WebServiceWorkerCacheStorage* webCacheStorage) |
| 207 { | 207 { |
| 208 return new CacheStorage(fetcher, adoptPtr(webCacheStorage)); | 208 return new CacheStorage(fetcher, adoptPtr(webCacheStorage)); |
| 209 } | 209 } |
| 210 | 210 |
| 211 ScriptPromise CacheStorage::open(ScriptState* scriptState, const String& cacheNa
me, ExceptionState& exceptionState) | 211 ScriptPromise CacheStorage::open(ScriptState* scriptState, const String& cacheNa
me, ExceptionState& exceptionState) |
| 212 { | 212 { |
| 213 if (!commonChecks(scriptState, exceptionState)) | 213 if (!commonChecks(scriptState, exceptionState)) |
| 214 return ScriptPromise(); | 214 return ScriptPromise(); |
| 215 | 215 |
| 216 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 216 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 const ScriptPromise promise = resolver->promise(); | 306 const ScriptPromise promise = resolver->promise(); |
| 307 | 307 |
| 308 if (m_webCacheStorage) | 308 if (m_webCacheStorage) |
| 309 m_webCacheStorage->dispatchMatch(new MatchCallbacks(resolver), webReques
t, Cache::toWebQueryParams(options)); | 309 m_webCacheStorage->dispatchMatch(new MatchCallbacks(resolver), webReques
t, Cache::toWebQueryParams(options)); |
| 310 else | 310 else |
| 311 resolver->reject(createNoImplementationException()); | 311 resolver->reject(createNoImplementationException()); |
| 312 | 312 |
| 313 return promise; | 313 return promise; |
| 314 } | 314 } |
| 315 | 315 |
| 316 CacheStorage::CacheStorage(WeakPtr<GlobalFetch::ScopedFetcher> fetcher, PassOwnP
tr<WebServiceWorkerCacheStorage> webCacheStorage) | 316 CacheStorage::CacheStorage(WeakPtrWillBeRawPtr<GlobalFetch::ScopedFetcher> fetch
er, PassOwnPtr<WebServiceWorkerCacheStorage> webCacheStorage) |
| 317 : m_scopedFetcher(fetcher) | 317 : m_scopedFetcher(fetcher) |
| 318 , m_webCacheStorage(webCacheStorage) | 318 , m_webCacheStorage(webCacheStorage) |
| 319 { | 319 { |
| 320 } | 320 } |
| 321 | 321 |
| 322 CacheStorage::~CacheStorage() | 322 CacheStorage::~CacheStorage() |
| 323 { | 323 { |
| 324 } | 324 } |
| 325 | 325 |
| 326 void CacheStorage::dispose() | 326 void CacheStorage::dispose() |
| 327 { | 327 { |
| 328 m_webCacheStorage.clear(); | 328 m_webCacheStorage.clear(); |
| 329 } | 329 } |
| 330 | 330 |
| 331 DEFINE_TRACE(CacheStorage) | 331 DEFINE_TRACE(CacheStorage) |
| 332 { | 332 { |
| 333 visitor->trace(m_scopedFetcher); |
| 333 visitor->trace(m_nameToCacheMap); | 334 visitor->trace(m_nameToCacheMap); |
| 334 } | 335 } |
| 335 | 336 |
| 336 } // namespace blink | 337 } // namespace blink |
| OLD | NEW |