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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/guid.h" | 12 #include "base/guid.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" | 15 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" |
| 16 #include "content/browser/service_worker/service_worker_metrics.h" |
16 #include "content/browser/service_worker/service_worker_provider_host.h" | 17 #include "content/browser/service_worker/service_worker_provider_host.h" |
17 #include "content/common/resource_request_body.h" | 18 #include "content/common/resource_request_body.h" |
18 #include "content/common/service_worker/service_worker_types.h" | 19 #include "content/common/service_worker/service_worker_types.h" |
19 #include "content/public/browser/blob_handle.h" | 20 #include "content/public/browser/blob_handle.h" |
20 #include "content/public/browser/resource_request_info.h" | 21 #include "content/public/browser/resource_request_info.h" |
21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
22 #include "net/http/http_request_headers.h" | 23 #include "net/http/http_request_headers.h" |
23 #include "net/http/http_response_headers.h" | 24 #include "net/http/http_response_headers.h" |
24 #include "net/http/http_response_info.h" | 25 #include "net/http/http_response_info.h" |
25 #include "net/http/http_util.h" | 26 #include "net/http/http_util.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 384 |
384 // Treat a response whose status is 0 as a Network Error. | 385 // Treat a response whose status is 0 as a Network Error. |
385 if (response.status_code == 0) { | 386 if (response.status_code == 0) { |
386 NotifyDone( | 387 NotifyDone( |
387 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED)); | 388 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED)); |
388 return; | 389 return; |
389 } | 390 } |
390 | 391 |
391 fetch_end_time_ = base::TimeTicks::Now(); | 392 fetch_end_time_ = base::TimeTicks::Now(); |
392 load_timing_info_.send_end = fetch_end_time_; | 393 load_timing_info_.send_end = fetch_end_time_; |
| 394 ServiceWorkerMetrics::MeasureFetchEventExecutionTime( |
| 395 fetch_end_time_ - fetch_start_time_); |
393 | 396 |
394 // Set up a request for reading the blob. | 397 // Set up a request for reading the blob. |
395 if (!response.blob_uuid.empty() && blob_storage_context_) { | 398 if (!response.blob_uuid.empty() && blob_storage_context_) { |
396 scoped_ptr<storage::BlobDataHandle> blob_data_handle = | 399 scoped_ptr<storage::BlobDataHandle> blob_data_handle = |
397 blob_storage_context_->GetBlobDataFromUUID(response.blob_uuid); | 400 blob_storage_context_->GetBlobDataFromUUID(response.blob_uuid); |
398 if (!blob_data_handle) { | 401 if (!blob_data_handle) { |
399 // The renderer gave us a bad blob UUID. | 402 // The renderer gave us a bad blob UUID. |
400 DeliverErrorResponse(); | 403 DeliverErrorResponse(); |
401 return; | 404 return; |
402 } | 405 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 446 |
444 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 447 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
445 // TODO(falken): Print an error to the console of the ServiceWorker and of | 448 // TODO(falken): Print an error to the console of the ServiceWorker and of |
446 // the requesting page. | 449 // the requesting page. |
447 CreateResponseHeader( | 450 CreateResponseHeader( |
448 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); | 451 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); |
449 CommitResponseHeader(); | 452 CommitResponseHeader(); |
450 } | 453 } |
451 | 454 |
452 } // namespace content | 455 } // namespace content |
OLD | NEW |