| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) | 206 if (!m_resolver->executionContext() || m_resolver->executionContext()->a
ctiveDOMObjectsAreStopped()) |
| 207 return; | 207 return; |
| 208 m_resolver->reject(CacheStorageError::createException(reason)); | 208 m_resolver->reject(CacheStorageError::createException(reason)); |
| 209 m_resolver.clear(); | 209 m_resolver.clear(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 private: | 212 private: |
| 213 Persistent<ScriptPromiseResolver> m_resolver; | 213 Persistent<ScriptPromiseResolver> m_resolver; |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 CacheStorage* CacheStorage::create(WeakPtrWillBeRawPtr<GlobalFetch::ScopedFetche
r> fetcher, WebServiceWorkerCacheStorage* webCacheStorage) | 216 CacheStorage* CacheStorage::create(RawPtr<GlobalFetch::ScopedFetcher> fetcher, W
ebServiceWorkerCacheStorage* webCacheStorage) |
| 217 { | 217 { |
| 218 return new CacheStorage(fetcher, adoptPtr(webCacheStorage)); | 218 return new CacheStorage(fetcher, adoptPtr(webCacheStorage)); |
| 219 } | 219 } |
| 220 | 220 |
| 221 ScriptPromise CacheStorage::open(ScriptState* scriptState, const String& cacheNa
me, ExceptionState& exceptionState) | 221 ScriptPromise CacheStorage::open(ScriptState* scriptState, const String& cacheNa
me, ExceptionState& exceptionState) |
| 222 { | 222 { |
| 223 if (!commonChecks(scriptState, exceptionState)) | 223 if (!commonChecks(scriptState, exceptionState)) |
| 224 return ScriptPromise(); | 224 return ScriptPromise(); |
| 225 | 225 |
| 226 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 226 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 const ScriptPromise promise = resolver->promise(); | 317 const ScriptPromise promise = resolver->promise(); |
| 318 | 318 |
| 319 if (m_webCacheStorage) | 319 if (m_webCacheStorage) |
| 320 m_webCacheStorage->dispatchMatch(new MatchCallbacks(resolver), webReques
t, Cache::toWebQueryParams(options)); | 320 m_webCacheStorage->dispatchMatch(new MatchCallbacks(resolver), webReques
t, Cache::toWebQueryParams(options)); |
| 321 else | 321 else |
| 322 resolver->reject(createNoImplementationException()); | 322 resolver->reject(createNoImplementationException()); |
| 323 | 323 |
| 324 return promise; | 324 return promise; |
| 325 } | 325 } |
| 326 | 326 |
| 327 CacheStorage::CacheStorage(WeakPtrWillBeRawPtr<GlobalFetch::ScopedFetcher> fetch
er, PassOwnPtr<WebServiceWorkerCacheStorage> webCacheStorage) | 327 CacheStorage::CacheStorage(RawPtr<GlobalFetch::ScopedFetcher> fetcher, PassOwnPt
r<WebServiceWorkerCacheStorage> webCacheStorage) |
| 328 : m_scopedFetcher(fetcher) | 328 : m_scopedFetcher(fetcher) |
| 329 , m_webCacheStorage(webCacheStorage) | 329 , m_webCacheStorage(webCacheStorage) |
| 330 { | 330 { |
| 331 } | 331 } |
| 332 | 332 |
| 333 CacheStorage::~CacheStorage() | 333 CacheStorage::~CacheStorage() |
| 334 { | 334 { |
| 335 } | 335 } |
| 336 | 336 |
| 337 void CacheStorage::dispose() | 337 void CacheStorage::dispose() |
| 338 { | 338 { |
| 339 m_webCacheStorage.clear(); | 339 m_webCacheStorage.clear(); |
| 340 } | 340 } |
| 341 | 341 |
| 342 DEFINE_TRACE(CacheStorage) | 342 DEFINE_TRACE(CacheStorage) |
| 343 { | 343 { |
| 344 visitor->trace(m_scopedFetcher); | 344 visitor->trace(m_scopedFetcher); |
| 345 visitor->trace(m_nameToCacheMap); | 345 visitor->trace(m_nameToCacheMap); |
| 346 } | 346 } |
| 347 | 347 |
| 348 } // namespace blink | 348 } // namespace blink |
| OLD | NEW |