| 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/Cache.h" | 5 #include "modules/cachestorage/Cache.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 #include <utility> |
| 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 9 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 10 #include "bindings/core/v8/ExceptionState.h" |
| 11 #include "bindings/core/v8/IDLTypes.h" |
| 12 #include "bindings/core/v8/NativeValueTraitsImpl.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 13 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 14 #include "bindings/core/v8/ScriptState.h" |
| 11 #include "bindings/core/v8/V8Binding.h" | 15 #include "bindings/core/v8/V8Binding.h" |
| 12 #include "bindings/core/v8/V8ThrowException.h" | 16 #include "bindings/core/v8/V8ThrowException.h" |
| 13 #include "bindings/modules/v8/V8Response.h" | 17 #include "bindings/modules/v8/V8Response.h" |
| 14 #include "core/dom/DOMException.h" | 18 #include "core/dom/DOMException.h" |
| 15 #include "core/inspector/ConsoleMessage.h" | 19 #include "core/inspector/ConsoleMessage.h" |
| 16 #include "modules/cachestorage/CacheStorageError.h" | 20 #include "modules/cachestorage/CacheStorageError.h" |
| 17 #include "modules/fetch/BodyStreamBuffer.h" | 21 #include "modules/fetch/BodyStreamBuffer.h" |
| 18 #include "modules/fetch/FetchDataLoader.h" | 22 #include "modules/fetch/FetchDataLoader.h" |
| 19 #include "modules/fetch/GlobalFetch.h" | 23 #include "modules/fetch/GlobalFetch.h" |
| 20 #include "modules/fetch/Request.h" | 24 #include "modules/fetch/Request.h" |
| 21 #include "modules/fetch/Response.h" | 25 #include "modules/fetch/Response.h" |
| 22 #include "platform/HTTPNames.h" | 26 #include "platform/HTTPNames.h" |
| 23 #include "platform/Histogram.h" | 27 #include "platform/Histogram.h" |
| 24 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h" | 28 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h" |
| 25 #include <memory> | |
| 26 #include <utility> | |
| 27 | 29 |
| 28 namespace blink { | 30 namespace blink { |
| 29 | 31 |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| 32 // FIXME: Consider using CallbackPromiseAdapter. | 34 // FIXME: Consider using CallbackPromiseAdapter. |
| 33 class CacheMatchCallbacks : public WebServiceWorkerCache::CacheMatchCallbacks { | 35 class CacheMatchCallbacks : public WebServiceWorkerCache::CacheMatchCallbacks { |
| 34 WTF_MAKE_NONCOPYABLE(CacheMatchCallbacks); | 36 WTF_MAKE_NONCOPYABLE(CacheMatchCallbacks); |
| 35 | 37 |
| 36 public: | 38 public: |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 ScriptState* script_state, | 231 ScriptState* script_state, |
| 230 Cache* cache, | 232 Cache* cache, |
| 231 const HeapVector<Member<Request>>& requests) { | 233 const HeapVector<Member<Request>>& requests) { |
| 232 FetchResolvedForAdd* self = | 234 FetchResolvedForAdd* self = |
| 233 new FetchResolvedForAdd(script_state, cache, requests); | 235 new FetchResolvedForAdd(script_state, cache, requests); |
| 234 return self->BindToV8Function(); | 236 return self->BindToV8Function(); |
| 235 } | 237 } |
| 236 | 238 |
| 237 ScriptValue Call(ScriptValue value) override { | 239 ScriptValue Call(ScriptValue value) override { |
| 238 NonThrowableExceptionState exception_state; | 240 NonThrowableExceptionState exception_state; |
| 239 HeapVector<Member<Response>> responses = ToMemberNativeArray<Response>( | 241 HeapVector<Member<Response>> responses = |
| 240 value.V8Value(), requests_.size(), GetScriptState()->GetIsolate(), | 242 NativeValueTraits<IDLSequence<Response>>::NativeValue( |
| 241 exception_state); | 243 GetScriptState()->GetIsolate(), value.V8Value(), exception_state); |
| 242 | 244 |
| 243 for (const auto& response : responses) { | 245 for (const auto& response : responses) { |
| 244 if (!response->ok()) { | 246 if (!response->ok()) { |
| 245 ScriptPromise rejection = ScriptPromise::Reject( | 247 ScriptPromise rejection = ScriptPromise::Reject( |
| 246 GetScriptState(), | 248 GetScriptState(), |
| 247 V8ThrowException::CreateTypeError(GetScriptState()->GetIsolate(), | 249 V8ThrowException::CreateTypeError(GetScriptState()->GetIsolate(), |
| 248 "Request failed")); | 250 "Request failed")); |
| 249 return ScriptValue(GetScriptState(), rejection.V8Value()); | 251 return ScriptValue(GetScriptState(), rejection.V8Value()); |
| 250 } | 252 } |
| 251 if (VaryHeaderContainsAsterisk(response)) { | 253 if (VaryHeaderContainsAsterisk(response)) { |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 WTF::MakeUnique<CacheWithRequestsCallbacks>(resolver), web_request, | 703 WTF::MakeUnique<CacheWithRequestsCallbacks>(resolver), web_request, |
| 702 ToWebQueryParams(options)); | 704 ToWebQueryParams(options)); |
| 703 return promise; | 705 return promise; |
| 704 } | 706 } |
| 705 | 707 |
| 706 WebServiceWorkerCache* Cache::WebCache() const { | 708 WebServiceWorkerCache* Cache::WebCache() const { |
| 707 return web_cache_.get(); | 709 return web_cache_.get(); |
| 708 } | 710 } |
| 709 | 711 |
| 710 } // namespace blink | 712 } // namespace blink |
| OLD | NEW |