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_provider_host.h" | 16 #include "content/browser/service_worker/service_worker_provider_host.h" |
17 #include "content/common/resource_request_body.h" | 17 #include "content/common/resource_request_body.h" |
18 #include "content/common/service_worker/service_worker_types.h" | 18 #include "content/common/service_worker/service_worker_types.h" |
19 #include "content/public/browser/blob_handle.h" | 19 #include "content/public/browser/blob_handle.h" |
20 #include "content/public/browser/resource_request_info.h" | 20 #include "content/public/browser/resource_request_info.h" |
21 #include "net/base/net_errors.h" | |
21 #include "net/http/http_request_headers.h" | 22 #include "net/http/http_request_headers.h" |
22 #include "net/http/http_response_headers.h" | 23 #include "net/http/http_response_headers.h" |
23 #include "net/http/http_response_info.h" | 24 #include "net/http/http_response_info.h" |
24 #include "net/http/http_util.h" | 25 #include "net/http/http_util.h" |
25 #include "storage/browser/blob/blob_data_handle.h" | 26 #include "storage/browser/blob/blob_data_handle.h" |
26 #include "storage/browser/blob/blob_storage_context.h" | 27 #include "storage/browser/blob/blob_storage_context.h" |
27 #include "storage/browser/blob/blob_url_request_job_factory.h" | 28 #include "storage/browser/blob/blob_url_request_job_factory.h" |
28 #include "ui/base/page_transition_types.h" | 29 #include "ui/base/page_transition_types.h" |
29 | 30 |
30 namespace content { | 31 namespace content { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 // Change the response type and restart the request to fallback to | 374 // Change the response type and restart the request to fallback to |
374 // the network. | 375 // the network. |
375 response_type_ = FALLBACK_TO_NETWORK; | 376 response_type_ = FALLBACK_TO_NETWORK; |
376 NotifyRestartRequired(); | 377 NotifyRestartRequired(); |
377 return; | 378 return; |
378 } | 379 } |
379 | 380 |
380 // We should have a response now. | 381 // We should have a response now. |
381 DCHECK_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, fetch_result); | 382 DCHECK_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, fetch_result); |
382 | 383 |
383 // Treat a response whose status is 0 as an error. | 384 // Treat a response whose status is 0 as an error. |
yhirano
2014/09/22 07:42:35
mentioning "Network Error" makes more sense becaus
horo
2014/09/22 08:38:20
Done.
| |
384 if (response.status_code == 0) { | 385 if (response.status_code == 0) { |
385 DeliverErrorResponse(); | 386 NotifyDone( |
387 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED)); | |
386 return; | 388 return; |
387 } | 389 } |
388 | 390 |
389 fetch_end_time_ = base::TimeTicks::Now(); | 391 fetch_end_time_ = base::TimeTicks::Now(); |
390 load_timing_info_.send_end = fetch_end_time_; | 392 load_timing_info_.send_end = fetch_end_time_; |
391 | 393 |
392 // Set up a request for reading the blob. | 394 // Set up a request for reading the blob. |
393 if (!response.blob_uuid.empty() && blob_storage_context_) { | 395 if (!response.blob_uuid.empty() && blob_storage_context_) { |
394 scoped_ptr<storage::BlobDataHandle> blob_data_handle = | 396 scoped_ptr<storage::BlobDataHandle> blob_data_handle = |
395 blob_storage_context_->GetBlobDataFromUUID(response.blob_uuid); | 397 blob_storage_context_->GetBlobDataFromUUID(response.blob_uuid); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 444 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
443 // TODO(falken): Print an error to the console of the ServiceWorker and of | 445 // TODO(falken): Print an error to the console of the ServiceWorker and of |
444 // the requesting page. | 446 // the requesting page. |
445 CreateResponseHeader(500, | 447 CreateResponseHeader(500, |
446 "Service Worker Response Error", | 448 "Service Worker Response Error", |
447 std::map<std::string, std::string>()); | 449 std::map<std::string, std::string>()); |
448 CommitResponseHeader(); | 450 CommitResponseHeader(); |
449 } | 451 } |
450 | 452 |
451 } // namespace content | 453 } // namespace content |
OLD | NEW |