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/Cache.h" | 6 #include "modules/serviceworkers/Cache.h" |
7 | 7 |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // FIXME: Consider using CallbackPromiseAdapter. | 48 // FIXME: Consider using CallbackPromiseAdapter. |
49 class CacheWithResponsesCallbacks : public WebServiceWorkerCache::CacheWithRespo
nsesCallbacks { | 49 class CacheWithResponsesCallbacks : public WebServiceWorkerCache::CacheWithRespo
nsesCallbacks { |
50 WTF_MAKE_NONCOPYABLE(CacheWithResponsesCallbacks); | 50 WTF_MAKE_NONCOPYABLE(CacheWithResponsesCallbacks); |
51 public: | 51 public: |
52 CacheWithResponsesCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> re
solver) | 52 CacheWithResponsesCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> re
solver) |
53 : m_resolver(resolver) { } | 53 : m_resolver(resolver) { } |
54 | 54 |
55 virtual void onSuccess(WebVector<WebServiceWorkerResponse>* webResponses) ov
erride | 55 virtual void onSuccess(WebVector<WebServiceWorkerResponse>* webResponses) ov
erride |
56 { | 56 { |
57 HeapVector<Member<Response> > responses; | 57 HeapVector<Member<Response>> responses; |
58 for (size_t i = 0; i < webResponses->size(); ++i) | 58 for (size_t i = 0; i < webResponses->size(); ++i) |
59 responses.append(Response::create(m_resolver->scriptState()->executi
onContext(), (*webResponses)[i])); | 59 responses.append(Response::create(m_resolver->scriptState()->executi
onContext(), (*webResponses)[i])); |
60 m_resolver->resolve(responses); | 60 m_resolver->resolve(responses); |
61 m_resolver.clear(); | 61 m_resolver.clear(); |
62 } | 62 } |
63 | 63 |
64 virtual void onError(WebServiceWorkerCacheError* reason) override | 64 virtual void onError(WebServiceWorkerCacheError* reason) override |
65 { | 65 { |
66 m_resolver->reject(Cache::domExceptionForCacheError(*reason)); | 66 m_resolver->reject(Cache::domExceptionForCacheError(*reason)); |
67 m_resolver.clear(); | 67 m_resolver.clear(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 // FIXME: Consider using CallbackPromiseAdapter. | 116 // FIXME: Consider using CallbackPromiseAdapter. |
117 class CacheWithRequestsCallbacks : public WebServiceWorkerCache::CacheWithReques
tsCallbacks { | 117 class CacheWithRequestsCallbacks : public WebServiceWorkerCache::CacheWithReques
tsCallbacks { |
118 WTF_MAKE_NONCOPYABLE(CacheWithRequestsCallbacks); | 118 WTF_MAKE_NONCOPYABLE(CacheWithRequestsCallbacks); |
119 public: | 119 public: |
120 CacheWithRequestsCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> res
olver) | 120 CacheWithRequestsCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> res
olver) |
121 : m_resolver(resolver) { } | 121 : m_resolver(resolver) { } |
122 | 122 |
123 virtual void onSuccess(WebVector<WebServiceWorkerRequest>* webRequests) over
ride | 123 virtual void onSuccess(WebVector<WebServiceWorkerRequest>* webRequests) over
ride |
124 { | 124 { |
125 HeapVector<Member<Request> > requests; | 125 HeapVector<Member<Request>> requests; |
126 for (size_t i = 0; i < webRequests->size(); ++i) | 126 for (size_t i = 0; i < webRequests->size(); ++i) |
127 requests.append(Request::create(m_resolver->scriptState()->execution
Context(), (*webRequests)[i])); | 127 requests.append(Request::create(m_resolver->scriptState()->execution
Context(), (*webRequests)[i])); |
128 m_resolver->resolve(requests); | 128 m_resolver->resolve(requests); |
129 m_resolver.clear(); | 129 m_resolver.clear(); |
130 } | 130 } |
131 | 131 |
132 virtual void onError(WebServiceWorkerCacheError* reason) override | 132 virtual void onError(WebServiceWorkerCacheError* reason) override |
133 { | 133 { |
134 m_resolver->reject(Cache::domExceptionForCacheError(*reason)); | 134 m_resolver->reject(Cache::domExceptionForCacheError(*reason)); |
135 m_resolver.clear(); | 135 m_resolver.clear(); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); | 406 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); |
407 return promise; | 407 return promise; |
408 } | 408 } |
409 | 409 |
410 WebServiceWorkerCache* Cache::webCache() const | 410 WebServiceWorkerCache* Cache::webCache() const |
411 { | 411 { |
412 return m_webCache.get(); | 412 return m_webCache.get(); |
413 } | 413 } |
414 | 414 |
415 } // namespace blink | 415 } // namespace blink |
OLD | NEW |