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

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

Issue 493373002: ServiceWorker: Add prepare_callback in DispatchFetchEvent to notify the end of SW preparation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the test failure and rebase Created 6 years, 3 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_url_request_job.h" 5 #include "content/browser/service_worker/service_worker_url_request_job.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return; 222 return;
223 223
224 case FORWARD_TO_SERVICE_WORKER: 224 case FORWARD_TO_SERVICE_WORKER:
225 DCHECK(provider_host_ && provider_host_->active_version()); 225 DCHECK(provider_host_ && provider_host_->active_version());
226 DCHECK(!fetch_dispatcher_); 226 DCHECK(!fetch_dispatcher_);
227 // Send a fetch event to the ServiceWorker associated to the 227 // Send a fetch event to the ServiceWorker associated to the
228 // provider_host. 228 // provider_host.
229 fetch_dispatcher_.reset(new ServiceWorkerFetchDispatcher( 229 fetch_dispatcher_.reset(new ServiceWorkerFetchDispatcher(
230 CreateFetchRequest(), 230 CreateFetchRequest(),
231 provider_host_->active_version(), 231 provider_host_->active_version(),
232 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent,
233 weak_factory_.GetWeakPtr()),
232 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, 234 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent,
233 weak_factory_.GetWeakPtr()))); 235 weak_factory_.GetWeakPtr())));
234 fetch_dispatcher_->Run(); 236 fetch_dispatcher_->Run();
235 return; 237 return;
236 } 238 }
237 239
238 NOTREACHED(); 240 NOTREACHED();
239 } 241 }
240 242
241 scoped_ptr<ServiceWorkerFetchRequest> 243 scoped_ptr<ServiceWorkerFetchRequest>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 316 }
315 } 317 }
316 318
317 request_body_blob_data_handle_ = 319 request_body_blob_data_handle_ =
318 blob_storage_context_->AddFinishedBlob(blob_data.get()); 320 blob_storage_context_->AddFinishedBlob(blob_data.get());
319 *blob_uuid = uuid; 321 *blob_uuid = uuid;
320 *blob_size = size; 322 *blob_size = size;
321 return true; 323 return true;
322 } 324 }
323 325
326 void ServiceWorkerURLRequestJob::DidPrepareFetchEvent() {
327 // TODO(shimazu): Set the timestamp to measure the time to launch SW
328 // This is related to this (http://crbug.com/401389)
329 }
330
324 void ServiceWorkerURLRequestJob::DidDispatchFetchEvent( 331 void ServiceWorkerURLRequestJob::DidDispatchFetchEvent(
325 ServiceWorkerStatusCode status, 332 ServiceWorkerStatusCode status,
326 ServiceWorkerFetchEventResult fetch_result, 333 ServiceWorkerFetchEventResult fetch_result,
327 const ServiceWorkerResponse& response) { 334 const ServiceWorkerResponse& response) {
328 fetch_dispatcher_.reset(); 335 fetch_dispatcher_.reset();
329 336
330 // Check if we're not orphaned. 337 // Check if we're not orphaned.
331 if (!request()) 338 if (!request())
332 return; 339 return;
333 340
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { 412 void ServiceWorkerURLRequestJob::DeliverErrorResponse() {
406 // TODO(falken): Print an error to the console of the ServiceWorker and of 413 // TODO(falken): Print an error to the console of the ServiceWorker and of
407 // the requesting page. 414 // the requesting page.
408 CreateResponseHeader(500, 415 CreateResponseHeader(500,
409 "Service Worker Response Error", 416 "Service Worker Response Error",
410 std::map<std::string, std::string>()); 417 std::map<std::string, std::string>());
411 CommitResponseHeader(); 418 CommitResponseHeader();
412 } 419 }
413 420
414 } // namespace content 421 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698