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

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

Issue 2518523003: Limit timeout for foreign fetch events when triggered by another service worker. (Closed)
Patch Set: don't intercept worker main resource fetches 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 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_url_request_job.h" 5 #include "content/browser/service_worker/service_worker_url_request_job.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 227 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
228 const ResourceContext* resource_context, 228 const ResourceContext* resource_context,
229 FetchRequestMode request_mode, 229 FetchRequestMode request_mode,
230 FetchCredentialsMode credentials_mode, 230 FetchCredentialsMode credentials_mode,
231 FetchRedirectMode redirect_mode, 231 FetchRedirectMode redirect_mode,
232 ResourceType resource_type, 232 ResourceType resource_type,
233 RequestContextType request_context_type, 233 RequestContextType request_context_type,
234 RequestContextFrameType frame_type, 234 RequestContextFrameType frame_type,
235 scoped_refptr<ResourceRequestBodyImpl> body, 235 scoped_refptr<ResourceRequestBodyImpl> body,
236 ServiceWorkerFetchType fetch_type, 236 ServiceWorkerFetchType fetch_type,
237 const base::Optional<base::TimeDelta>& timeout,
237 Delegate* delegate) 238 Delegate* delegate)
238 : net::URLRequestJob(request, network_delegate), 239 : net::URLRequestJob(request, network_delegate),
239 delegate_(delegate), 240 delegate_(delegate),
240 response_type_(NOT_DETERMINED), 241 response_type_(NOT_DETERMINED),
241 is_started_(false), 242 is_started_(false),
242 service_worker_response_type_(blink::WebServiceWorkerResponseTypeDefault), 243 service_worker_response_type_(blink::WebServiceWorkerResponseTypeDefault),
243 client_id_(client_id), 244 client_id_(client_id),
244 blob_storage_context_(blob_storage_context), 245 blob_storage_context_(blob_storage_context),
245 resource_context_(resource_context), 246 resource_context_(resource_context),
246 request_mode_(request_mode), 247 request_mode_(request_mode),
247 credentials_mode_(credentials_mode), 248 credentials_mode_(credentials_mode),
248 redirect_mode_(redirect_mode), 249 redirect_mode_(redirect_mode),
249 resource_type_(resource_type), 250 resource_type_(resource_type),
250 request_context_type_(request_context_type), 251 request_context_type_(request_context_type),
251 frame_type_(frame_type), 252 frame_type_(frame_type),
252 fall_back_required_(false), 253 fall_back_required_(false),
253 body_(body), 254 body_(body),
254 fetch_type_(fetch_type), 255 fetch_type_(fetch_type),
256 timeout_(timeout),
255 weak_factory_(this) { 257 weak_factory_(this) {
256 DCHECK(delegate_) << "ServiceWorkerURLRequestJob requires a delegate"; 258 DCHECK(delegate_) << "ServiceWorkerURLRequestJob requires a delegate";
257 } 259 }
258 260
259 ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() { 261 ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() {
260 stream_reader_.reset(); 262 stream_reader_.reset();
261 file_size_resolver_.reset(); 263 file_size_resolver_.reset();
262 264
263 if (!ShouldRecordResult()) 265 if (!ShouldRecordResult())
264 return; 266 return;
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 DeliverErrorResponse(); 847 DeliverErrorResponse();
846 return; 848 return;
847 } 849 }
848 850
849 worker_already_activated_ = 851 worker_already_activated_ =
850 active_worker->status() == ServiceWorkerVersion::ACTIVATED; 852 active_worker->status() == ServiceWorkerVersion::ACTIVATED;
851 initial_worker_status_ = active_worker->running_status(); 853 initial_worker_status_ = active_worker->running_status();
852 854
853 DCHECK(!fetch_dispatcher_); 855 DCHECK(!fetch_dispatcher_);
854 fetch_dispatcher_.reset(new ServiceWorkerFetchDispatcher( 856 fetch_dispatcher_.reset(new ServiceWorkerFetchDispatcher(
855 CreateFetchRequest(), active_worker, resource_type_, request()->net_log(), 857 CreateFetchRequest(), active_worker, resource_type_, timeout_,
858 request()->net_log(),
856 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, 859 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent,
857 weak_factory_.GetWeakPtr(), active_worker), 860 weak_factory_.GetWeakPtr(), active_worker),
858 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, 861 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent,
859 weak_factory_.GetWeakPtr()))); 862 weak_factory_.GetWeakPtr())));
860 worker_start_time_ = base::TimeTicks::Now(); 863 worker_start_time_ = base::TimeTicks::Now();
861 fetch_dispatcher_->MaybeStartNavigationPreload(request()); 864 fetch_dispatcher_->MaybeStartNavigationPreload(request());
862 fetch_dispatcher_->Run(); 865 fetch_dispatcher_->Run();
863 } 866 }
864 867
865 } // namespace content 868 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698