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

Side by Side Diff: content/browser/service_worker/service_worker_cache.cc

Issue 576973004: Make ServiceWorkerFetchRequest and ServiceWorkerResponse header maps case insensitive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses comment from PS4 Created 6 years, 2 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 "content/browser/service_worker/service_worker_cache.h" 5 #include "content/browser/service_worker/service_worker_cache.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/guid.h" 10 #include "base/guid.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 242
243 DCHECK(entryptr); 243 DCHECK(entryptr);
244 disk_cache::ScopedEntryPtr entry(*entryptr); 244 disk_cache::ScopedEntryPtr entry(*entryptr);
245 245
246 ServiceWorkerRequestResponseHeaders headers; 246 ServiceWorkerRequestResponseHeaders headers;
247 headers.set_method(request->method); 247 headers.set_method(request->method);
248 248
249 headers.set_status_code(response->status_code); 249 headers.set_status_code(response->status_code);
250 headers.set_status_text(response->status_text); 250 headers.set_status_text(response->status_text);
251 for (std::map<std::string, std::string>::const_iterator it = 251 for (ServiceWorkerHeaderMap::const_iterator it = request->headers.begin();
252 request->headers.begin();
253 it != request->headers.end(); 252 it != request->headers.end();
254 ++it) { 253 ++it) {
255 ServiceWorkerRequestResponseHeaders::HeaderMap* header_map = 254 ServiceWorkerRequestResponseHeaders::HeaderMap* header_map =
256 headers.add_request_headers(); 255 headers.add_request_headers();
257 header_map->set_name(it->first); 256 header_map->set_name(it->first);
258 header_map->set_value(it->second); 257 header_map->set_value(it->second);
259 } 258 }
260 259
261 for (std::map<std::string, std::string>::const_iterator it = 260 for (ServiceWorkerHeaderMap::const_iterator it = response->headers.begin();
262 response->headers.begin();
263 it != response->headers.end(); 261 it != response->headers.end();
264 ++it) { 262 ++it) {
265 ServiceWorkerRequestResponseHeaders::HeaderMap* header_map = 263 ServiceWorkerRequestResponseHeaders::HeaderMap* header_map =
266 headers.add_response_headers(); 264 headers.add_response_headers();
267 header_map->set_name(it->first); 265 header_map->set_name(it->first);
268 header_map->set_value(it->second); 266 header_map->set_value(it->second);
269 } 267 }
270 268
271 scoped_ptr<std::string> serialized(new std::string()); 269 scoped_ptr<std::string> serialized(new std::string());
272 if (!headers.SerializeToString(serialized.get())) { 270 if (!headers.SerializeToString(serialized.get())) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 callback.Run(ServiceWorkerCache::ErrorTypeStorage, 381 callback.Run(ServiceWorkerCache::ErrorTypeStorage,
384 scoped_ptr<ServiceWorkerResponse>(), 382 scoped_ptr<ServiceWorkerResponse>(),
385 scoped_ptr<storage::BlobDataHandle>()); 383 scoped_ptr<storage::BlobDataHandle>());
386 return; 384 return;
387 } 385 }
388 386
389 scoped_ptr<ServiceWorkerResponse> response( 387 scoped_ptr<ServiceWorkerResponse> response(
390 new ServiceWorkerResponse(request->url, 388 new ServiceWorkerResponse(request->url,
391 headers->status_code(), 389 headers->status_code(),
392 headers->status_text(), 390 headers->status_text(),
393 std::map<std::string, std::string>(), 391 ServiceWorkerHeaderMap(),
394 "")); 392 ""));
395 393
396 for (int i = 0; i < headers->response_headers_size(); ++i) { 394 for (int i = 0; i < headers->response_headers_size(); ++i) {
397 const ServiceWorkerRequestResponseHeaders::HeaderMap header = 395 const ServiceWorkerRequestResponseHeaders::HeaderMap header =
398 headers->response_headers(i); 396 headers->response_headers(i);
399 response->headers.insert(std::make_pair(header.name(), header.value())); 397 response->headers.insert(std::make_pair(header.name(), header.value()));
400 } 398 }
401 399
402 // TODO(jkarlin): Insert vary validation here. 400 // TODO(jkarlin): Insert vary validation here.
403 401
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 void ServiceWorkerCache::KeysDidReadHeaders( 895 void ServiceWorkerCache::KeysDidReadHeaders(
898 scoped_ptr<KeysContext> keys_context, 896 scoped_ptr<KeysContext> keys_context,
899 const Entries::iterator& iter, 897 const Entries::iterator& iter,
900 scoped_ptr<ServiceWorkerRequestResponseHeaders> headers) { 898 scoped_ptr<ServiceWorkerRequestResponseHeaders> headers) {
901 disk_cache::Entry* entry = *iter; 899 disk_cache::Entry* entry = *iter;
902 900
903 if (headers) { 901 if (headers) {
904 keys_context->out_keys->push_back( 902 keys_context->out_keys->push_back(
905 ServiceWorkerFetchRequest(GURL(entry->GetKey()), 903 ServiceWorkerFetchRequest(GURL(entry->GetKey()),
906 headers->method(), 904 headers->method(),
907 std::map<std::string, std::string>(), 905 ServiceWorkerHeaderMap(),
908 GURL(), 906 GURL(),
909 false)); 907 false));
910 908
911 std::map<std::string, std::string>& req_headers = 909 ServiceWorkerHeaderMap& req_headers =
912 keys_context->out_keys->back().headers; 910 keys_context->out_keys->back().headers;
913 911
914 for (int i = 0; i < headers->request_headers_size(); ++i) { 912 for (int i = 0; i < headers->request_headers_size(); ++i) {
915 const ServiceWorkerRequestResponseHeaders::HeaderMap header = 913 const ServiceWorkerRequestResponseHeaders::HeaderMap header =
916 headers->request_headers(i); 914 headers->request_headers(i);
917 req_headers.insert(std::make_pair(header.name(), header.value())); 915 req_headers.insert(std::make_pair(header.name(), header.value()));
918 } 916 }
919 } else { 917 } else {
920 entry->Doom(); 918 entry->Doom();
921 } 919 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 initialized_ = true; 971 initialized_ = true;
974 for (std::vector<base::Closure>::iterator it = init_callbacks_.begin(); 972 for (std::vector<base::Closure>::iterator it = init_callbacks_.begin();
975 it != init_callbacks_.end(); 973 it != init_callbacks_.end();
976 ++it) { 974 ++it) {
977 it->Run(); 975 it->Run();
978 } 976 }
979 init_callbacks_.clear(); 977 init_callbacks_.clear();
980 } 978 }
981 979
982 } // namespace content 980 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698