| 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" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 198 } |
| 199 DEFINE_THREAD_SAFE_STATIC_LOCAL( | 199 DEFINE_THREAD_SAFE_STATIC_LOCAL( |
| 200 EnumerationHistogram, response_type_histogram, | 200 EnumerationHistogram, response_type_histogram, |
| 201 new EnumerationHistogram("ServiceWorkerCache.Cache.AddResponseType", | 201 new EnumerationHistogram("ServiceWorkerCache.Cache.AddResponseType", |
| 202 static_cast<int>(ResponseType::kEnumMax))); | 202 static_cast<int>(ResponseType::kEnumMax))); |
| 203 response_type_histogram.Count(static_cast<int>(type)); | 203 response_type_histogram.Count(static_cast<int>(type)); |
| 204 }; | 204 }; |
| 205 | 205 |
| 206 bool VaryHeaderContainsAsterisk(const Response* response) { | 206 bool VaryHeaderContainsAsterisk(const Response* response) { |
| 207 const FetchHeaderList* headers = response->headers()->HeaderList(); | 207 const FetchHeaderList* headers = response->headers()->HeaderList(); |
| 208 for (size_t i = 0; i < headers->size(); ++i) { | 208 String varyHeader; |
| 209 const FetchHeaderList::Header& header = headers->Entry(i); | 209 if (headers->Get("vary", varyHeader)) { |
| 210 if (header.first == "vary") { | 210 Vector<String> fields; |
| 211 Vector<String> fields; | 211 varyHeader.Split(',', fields); |
| 212 header.second.Split(',', fields); | 212 return std::any_of(fields.begin(), fields.end(), [](const String& field) { |
| 213 for (size_t j = 0; j < fields.size(); ++j) { | 213 return field.StripWhiteSpace() == "*"; |
| 214 if (fields[j].StripWhiteSpace() == "*") | 214 }); |
| 215 return true; | |
| 216 } | |
| 217 } | |
| 218 } | 215 } |
| 219 return false; | 216 return false; |
| 220 } | 217 } |
| 221 | 218 |
| 222 } // namespace | 219 } // namespace |
| 223 | 220 |
| 224 // TODO(nhiroki): Unfortunately, we have to go through V8 to wait for the fetch | 221 // TODO(nhiroki): Unfortunately, we have to go through V8 to wait for the fetch |
| 225 // promise. It should be better to achieve this only within C++ world. | 222 // promise. It should be better to achieve this only within C++ world. |
| 226 class Cache::FetchResolvedForAdd final : public ScriptFunction { | 223 class Cache::FetchResolvedForAdd final : public ScriptFunction { |
| 227 public: | 224 public: |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 WTF::MakeUnique<CacheWithRequestsCallbacks>(resolver), web_request, | 698 WTF::MakeUnique<CacheWithRequestsCallbacks>(resolver), web_request, |
| 702 ToWebQueryParams(options)); | 699 ToWebQueryParams(options)); |
| 703 return promise; | 700 return promise; |
| 704 } | 701 } |
| 705 | 702 |
| 706 WebServiceWorkerCache* Cache::WebCache() const { | 703 WebServiceWorkerCache* Cache::WebCache() const { |
| 707 return web_cache_.get(); | 704 return web_cache_.get(); |
| 708 } | 705 } |
| 709 | 706 |
| 710 } // namespace blink | 707 } // namespace blink |
| OLD | NEW |