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

Side by Side Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 2516353002: Introduce url_list to the Response scheme of CacheStorage. (Closed)
Patch Set: Created 4 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/renderer/service_worker/service_worker_context_client.h" 5 #include "content/renderer/service_worker/service_worker_context_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 base::MakeUnique<blink::WebServiceWorkerError>( 244 base::MakeUnique<blink::WebServiceWorkerError>(
245 blink::WebServiceWorkerError::ErrorTypeAbort, 245 blink::WebServiceWorkerError::ErrorTypeAbort,
246 blink::WebString::fromUTF8( 246 blink::WebString::fromUTF8(
247 "Service Worker navigation preload aborted. Need to guard with " 247 "Service Worker navigation preload aborted. Need to guard with "
248 "respondWith or waitUntil."))); 248 "respondWith or waitUntil.")));
249 } 249 }
250 250
251 void OnReceiveResponse(const ResourceResponseHead& response_head) override { 251 void OnReceiveResponse(const ResourceResponseHead& response_head) override {
252 DCHECK(!response_); 252 DCHECK(!response_);
253 response_ = base::MakeUnique<blink::WebServiceWorkerResponse>(); 253 response_ = base::MakeUnique<blink::WebServiceWorkerResponse>();
254 response_->setURL(url_); 254 std::vector<blink::WebURL> url_list;
255 url_list.push_back(url_);
256 response_->setURLList(url_list);
255 DCHECK(response_head.headers); 257 DCHECK(response_head.headers);
256 response_->setStatus(response_head.headers->response_code()); 258 response_->setStatus(response_head.headers->response_code());
257 response_->setStatusText( 259 response_->setStatusText(
258 blink::WebString::fromUTF8(response_head.headers->GetStatusText())); 260 blink::WebString::fromUTF8(response_head.headers->GetStatusText()));
259 response_->setResponseType(blink::WebServiceWorkerResponseTypeBasic); 261 response_->setResponseType(blink::WebServiceWorkerResponseTypeBasic);
260 size_t iter = 0; 262 size_t iter = 0;
261 std::string header_name; 263 std::string header_name;
262 std::string header_value; 264 std::string header_value;
263 while (response_head.headers->EnumerateHeaderLines(&iter, &header_name, 265 while (response_head.headers->EnumerateHeaderLines(&iter, &header_name,
264 &header_value)) { 266 &header_value)) {
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 Send(new ServiceWorkerHostMsg_FetchEventResponse( 686 Send(new ServiceWorkerHostMsg_FetchEventResponse(
685 GetRoutingID(), fetch_event_id, 687 GetRoutingID(), fetch_event_id,
686 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse(), 688 SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, ServiceWorkerResponse(),
687 base::Time::FromDoubleT(event_dispatch_time))); 689 base::Time::FromDoubleT(event_dispatch_time)));
688 } 690 }
689 691
690 void ServiceWorkerContextClient::respondToFetchEvent( 692 void ServiceWorkerContextClient::respondToFetchEvent(
691 int fetch_event_id, 693 int fetch_event_id,
692 const blink::WebServiceWorkerResponse& web_response, 694 const blink::WebServiceWorkerResponse& web_response,
693 double event_dispatch_time) { 695 double event_dispatch_time) {
694 ServiceWorkerHeaderMap headers;
695 GetServiceWorkerHeaderMapFromWebResponse(web_response, &headers);
696 ServiceWorkerHeaderList cors_exposed_header_names;
697 GetCorsExposedHeaderNamesFromWebResponse(web_response,
698 &cors_exposed_header_names);
699 ServiceWorkerResponse response(
700 web_response.url(), web_response.status(),
701 web_response.statusText().utf8(), web_response.responseType(), headers,
702 web_response.blobUUID().utf8(), web_response.blobSize(),
703 web_response.streamURL(), web_response.error(),
704 base::Time::FromInternalValue(web_response.responseTime()),
705 !web_response.cacheStorageCacheName().isNull(),
706 web_response.cacheStorageCacheName().utf8(), cors_exposed_header_names);
707 Send(new ServiceWorkerHostMsg_FetchEventResponse( 696 Send(new ServiceWorkerHostMsg_FetchEventResponse(
708 GetRoutingID(), fetch_event_id, 697 GetRoutingID(), fetch_event_id,
709 SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, response, 698 SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE,
699 GetServiceWorkerResponseFromWebResponse(web_response),
falken 2016/11/30 14:57:37 ah this is nicer
710 base::Time::FromDoubleT(event_dispatch_time))); 700 base::Time::FromDoubleT(event_dispatch_time)));
711 } 701 }
712 702
713 void ServiceWorkerContextClient::didHandleFetchEvent( 703 void ServiceWorkerContextClient::didHandleFetchEvent(
714 int fetch_event_id, 704 int fetch_event_id,
715 blink::WebServiceWorkerEventResult result, 705 blink::WebServiceWorkerEventResult result,
716 double event_dispatch_time) { 706 double event_dispatch_time) {
717 if (context_->preload_requests.Lookup(fetch_event_id)) { 707 if (context_->preload_requests.Lookup(fetch_event_id)) {
718 // Deletes NavigationPreloadRequest. If the network request is ongoing, it 708 // Deletes NavigationPreloadRequest. If the network request is ongoing, it
719 // will be canceled by deleting the mojom::URLLoaderPtr in the 709 // will be canceled by deleting the mojom::URLLoaderPtr in the
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 } 1263 }
1274 1264
1275 base::WeakPtr<ServiceWorkerContextClient> 1265 base::WeakPtr<ServiceWorkerContextClient>
1276 ServiceWorkerContextClient::GetWeakPtr() { 1266 ServiceWorkerContextClient::GetWeakPtr() {
1277 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 1267 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
1278 DCHECK(context_); 1268 DCHECK(context_);
1279 return context_->weak_factory.GetWeakPtr(); 1269 return context_->weak_factory.GetWeakPtr();
1280 } 1270 }
1281 1271
1282 } // namespace content 1272 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698