Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: third_party/WebKit/Source/modules/cachestorage/Cache.cpp

Issue 2833983004: bindings: Port away from ToImplArray/ToMemberNativeArray. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 ScriptState* script_state, 228 ScriptState* script_state,
227 Cache* cache, 229 Cache* cache,
228 const HeapVector<Member<Request>>& requests) { 230 const HeapVector<Member<Request>>& requests) {
229 FetchResolvedForAdd* self = 231 FetchResolvedForAdd* self =
230 new FetchResolvedForAdd(script_state, cache, requests); 232 new FetchResolvedForAdd(script_state, cache, requests);
231 return self->BindToV8Function(); 233 return self->BindToV8Function();
232 } 234 }
233 235
234 ScriptValue Call(ScriptValue value) override { 236 ScriptValue Call(ScriptValue value) override {
235 NonThrowableExceptionState exception_state; 237 NonThrowableExceptionState exception_state;
236 HeapVector<Member<Response>> responses = ToMemberNativeArray<Response>( 238 HeapVector<Member<Response>> responses =
237 value.V8Value(), requests_.size(), GetScriptState()->GetIsolate(), 239 NativeValueTraits<IDLSequence<Response>>::NativeValue(
238 exception_state); 240 GetScriptState()->GetIsolate(), value.V8Value(), exception_state);
239 241
240 for (const auto& response : responses) { 242 for (const auto& response : responses) {
241 if (!response->ok()) { 243 if (!response->ok()) {
242 ScriptPromise rejection = ScriptPromise::Reject( 244 ScriptPromise rejection = ScriptPromise::Reject(
243 GetScriptState(), 245 GetScriptState(),
244 V8ThrowException::CreateTypeError(GetScriptState()->GetIsolate(), 246 V8ThrowException::CreateTypeError(GetScriptState()->GetIsolate(),
245 "Request failed")); 247 "Request failed"));
246 return ScriptValue(GetScriptState(), rejection.V8Value()); 248 return ScriptValue(GetScriptState(), rejection.V8Value());
247 } 249 }
248 if (VaryHeaderContainsAsterisk(response)) { 250 if (VaryHeaderContainsAsterisk(response)) {
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 WTF::MakeUnique<CacheWithRequestsCallbacks>(resolver), web_request, 700 WTF::MakeUnique<CacheWithRequestsCallbacks>(resolver), web_request,
699 ToWebQueryParams(options)); 701 ToWebQueryParams(options));
700 return promise; 702 return promise;
701 } 703 }
702 704
703 WebServiceWorkerCache* Cache::WebCache() const { 705 WebServiceWorkerCache* Cache::WebCache() const {
704 return web_cache_.get(); 706 return web_cache_.get();
705 } 707 }
706 708
707 } // namespace blink 709 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/DOMTimerTest.cpp ('k') | third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698