| 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 "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 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" |
| 11 #include "bindings/core/v8/V8Binding.h" | 11 #include "bindings/core/v8/V8Binding.h" |
| 12 #include "bindings/core/v8/V8ThrowException.h" | 12 #include "bindings/core/v8/V8ThrowException.h" |
| 13 #include "bindings/modules/v8/V8Response.h" | 13 #include "bindings/modules/v8/V8Response.h" |
| 14 #include "core/dom/DOMException.h" | 14 #include "core/dom/DOMException.h" |
| 15 #include "core/dom/ExceptionCode.h" | 15 #include "core/dom/ExceptionCode.h" |
| 16 #include "core/inspector/ConsoleMessage.h" | 16 #include "core/inspector/ConsoleMessage.h" |
| 17 #include "modules/cachestorage/CacheStorageError.h" | 17 #include "modules/cachestorage/CacheStorageError.h" |
| 18 #include "modules/fetch/BodyStreamBuffer.h" | 18 #include "modules/fetch/BodyStreamBuffer.h" |
| 19 #include "modules/fetch/FetchDataLoader.h" | 19 #include "modules/fetch/FetchDataLoader.h" |
| 20 #include "modules/fetch/GlobalFetch.h" | 20 #include "modules/fetch/GlobalFetch.h" |
| 21 #include "modules/fetch/Request.h" | 21 #include "modules/fetch/Request.h" |
| 22 #include "modules/fetch/Response.h" | 22 #include "modules/fetch/Response.h" |
| 23 #include "platform/HTTPNames.h" | 23 #include "platform/HTTPNames.h" |
| 24 #include "public/platform/Platform.h" | 24 #include "platform/Histogram.h" |
| 25 #include "public/platform/WebPassOwnPtr.h" | 25 #include "public/platform/WebPassOwnPtr.h" |
| 26 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h" | 26 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h" |
| 27 | 27 |
| 28 namespace blink { | 28 namespace blink { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 void checkCacheQueryOptions(const CacheQueryOptions& options, ExecutionContext*
context) | 32 void checkCacheQueryOptions(const CacheQueryOptions& options, ExecutionContext*
context) |
| 33 { | 33 { |
| 34 if (options.ignoreSearch()) | 34 if (options.ignoreSearch()) |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 case FetchResponseData::ErrorType: | 186 case FetchResponseData::ErrorType: |
| 187 type = ResponseType::ErrorType; | 187 type = ResponseType::ErrorType; |
| 188 break; | 188 break; |
| 189 case FetchResponseData::OpaqueType: | 189 case FetchResponseData::OpaqueType: |
| 190 type = ResponseType::OpaqueType; | 190 type = ResponseType::OpaqueType; |
| 191 break; | 191 break; |
| 192 case FetchResponseData::OpaqueRedirectType: | 192 case FetchResponseData::OpaqueRedirectType: |
| 193 type = ResponseType::OpaqueRedirectType; | 193 type = ResponseType::OpaqueRedirectType; |
| 194 break; | 194 break; |
| 195 } | 195 } |
| 196 Platform::current()->histogramEnumeration("ServiceWorkerCache.Cache.AddRespo
nseType", static_cast<int>(type), static_cast<int>(ResponseType::EnumMax)); | 196 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, responseTypeHistogram,
new EnumerationHistogram("ServiceWorkerCache.Cache.AddResponseType", static_cas
t<int>(ResponseType::EnumMax))); |
| 197 responseTypeHistogram.count(static_cast<int>(type)); |
| 197 }; | 198 }; |
| 198 | 199 |
| 199 } // namespace | 200 } // namespace |
| 200 | 201 |
| 201 // TODO(nhiroki): Unfortunately, we have to go through V8 to wait for the fetch | 202 // TODO(nhiroki): Unfortunately, we have to go through V8 to wait for the fetch |
| 202 // promise. It should be better to achieve this only within C++ world. | 203 // promise. It should be better to achieve this only within C++ world. |
| 203 class Cache::FetchResolvedForAdd final : public ScriptFunction { | 204 class Cache::FetchResolvedForAdd final : public ScriptFunction { |
| 204 public: | 205 public: |
| 205 static v8::Local<v8::Function> create(ScriptState* scriptState, Cache* cache
, const HeapVector<Member<Request>>& requests) | 206 static v8::Local<v8::Function> create(ScriptState* scriptState, Cache* cache
, const HeapVector<Member<Request>>& requests) |
| 206 { | 207 { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); | 590 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ
ueryParams(options)); |
| 590 return promise; | 591 return promise; |
| 591 } | 592 } |
| 592 | 593 |
| 593 WebServiceWorkerCache* Cache::webCache() const | 594 WebServiceWorkerCache* Cache::webCache() const |
| 594 { | 595 { |
| 595 return m_webCache.get(); | 596 return m_webCache.get(); |
| 596 } | 597 } |
| 597 | 598 |
| 598 } // namespace blink | 599 } // namespace blink |
| OLD | NEW |