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 "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 Loading... |
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 } | 317 } |
316 } | 318 } |
317 | 319 |
318 request_body_blob_data_handle_ = | 320 request_body_blob_data_handle_ = |
319 blob_storage_context_->AddFinishedBlob(blob_data.get()); | 321 blob_storage_context_->AddFinishedBlob(blob_data.get()); |
320 *blob_uuid = uuid; | 322 *blob_uuid = uuid; |
321 *blob_size = size; | 323 *blob_size = size; |
322 return true; | 324 return true; |
323 } | 325 } |
324 | 326 |
| 327 void ServiceWorkerURLRequestJob::DidPrepareFetchEvent() { |
| 328 // TODO(shimazu): Set the timestamp to measure the time to launch SW |
| 329 // This is related to this (http://crbug.com/401389) |
| 330 } |
| 331 |
325 void ServiceWorkerURLRequestJob::DidDispatchFetchEvent( | 332 void ServiceWorkerURLRequestJob::DidDispatchFetchEvent( |
326 ServiceWorkerStatusCode status, | 333 ServiceWorkerStatusCode status, |
327 ServiceWorkerFetchEventResult fetch_result, | 334 ServiceWorkerFetchEventResult fetch_result, |
328 const ServiceWorkerResponse& response) { | 335 const ServiceWorkerResponse& response) { |
329 fetch_dispatcher_.reset(); | 336 fetch_dispatcher_.reset(); |
330 | 337 |
331 // Check if we're not orphaned. | 338 // Check if we're not orphaned. |
332 if (!request()) | 339 if (!request()) |
333 return; | 340 return; |
334 | 341 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 413 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
407 // TODO(falken): Print an error to the console of the ServiceWorker and of | 414 // TODO(falken): Print an error to the console of the ServiceWorker and of |
408 // the requesting page. | 415 // the requesting page. |
409 CreateResponseHeader(500, | 416 CreateResponseHeader(500, |
410 "Service Worker Response Error", | 417 "Service Worker Response Error", |
411 std::map<std::string, std::string>()); | 418 std::map<std::string, std::string>()); |
412 CommitResponseHeader(); | 419 CommitResponseHeader(); |
413 } | 420 } |
414 | 421 |
415 } // namespace content | 422 } // namespace content |
OLD | NEW |