| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 ServiceWorkerMetrics::RecordFallbackedRequestMode(request_mode_); | 580 ServiceWorkerMetrics::RecordFallbackedRequestMode(request_mode_); |
| 581 if (IsFallbackToRendererNeeded()) { | 581 if (IsFallbackToRendererNeeded()) { |
| 582 FinalizeFallbackToRenderer(); | 582 FinalizeFallbackToRenderer(); |
| 583 } else { | 583 } else { |
| 584 FinalizeFallbackToNetwork(); | 584 FinalizeFallbackToNetwork(); |
| 585 } | 585 } |
| 586 return; | 586 return; |
| 587 } | 587 } |
| 588 | 588 |
| 589 // We should have a response now. | 589 // We should have a response now. |
| 590 DCHECK_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, fetch_result); | 590 // TODO(falken): Turn to DCHECK once https://crbug.com/485900 is resolved. |
| 591 CHECK_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, fetch_result); |
| 591 | 592 |
| 592 // A response with status code 0 is Blink telling us to respond with network | 593 // A response with status code 0 is Blink telling us to respond with network |
| 593 // error. | 594 // error. |
| 594 if (response.status_code == 0) { | 595 if (response.status_code == 0) { |
| 595 RecordStatusZeroResponseError(response.error); | 596 RecordStatusZeroResponseError(response.error); |
| 596 NotifyStartError( | 597 NotifyStartError( |
| 597 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED)); | 598 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED)); |
| 598 return; | 599 return; |
| 599 } | 600 } |
| 600 | 601 |
| 601 load_timing_info_.send_end = base::TimeTicks::Now(); | 602 load_timing_info_.send_end = base::TimeTicks::Now(); |
| 602 | 603 |
| 603 // Creates a new HttpResponseInfo using the the ServiceWorker script's | 604 // Creates a new HttpResponseInfo using the the ServiceWorker script's |
| 604 // HttpResponseInfo to show HTTPS padlock. | 605 // HttpResponseInfo to show HTTPS padlock. |
| 605 // TODO(horo): When we support mixed-content (HTTP) no-cors requests from a | 606 // TODO(horo): When we support mixed-content (HTTP) no-cors requests from a |
| 606 // ServiceWorker, we have to check the security level of the responses. | 607 // ServiceWorker, we have to check the security level of the responses. |
| 607 DCHECK(!http_response_info_); | 608 DCHECK(!http_response_info_); |
| 608 DCHECK(version); | 609 DCHECK(version); |
| 609 const net::HttpResponseInfo* main_script_http_info = | 610 const net::HttpResponseInfo* main_script_http_info = |
| 610 version->GetMainScriptHttpResponseInfo(); | 611 version->GetMainScriptHttpResponseInfo(); |
| 612 CHECK(main_script_http_info); |
| 611 if (main_script_http_info) { | 613 if (main_script_http_info) { |
| 612 // In normal case |main_script_http_info| must be set while starting the | 614 // In normal case |main_script_http_info| must be set while starting the |
| 613 // ServiceWorker. But when the ServiceWorker registration database was not | 615 // ServiceWorker. But when the ServiceWorker registration database was not |
| 614 // written correctly, it may be null. | 616 // written correctly, it may be null. |
| 615 // TODO(horo): Change this line to DCHECK when crbug.com/485900 is fixed. | 617 // TODO(horo): Change this line to DCHECK when crbug.com/485900 is fixed. |
| 616 http_response_info_.reset( | 618 http_response_info_.reset( |
| 617 new net::HttpResponseInfo(*main_script_http_info)); | 619 new net::HttpResponseInfo(*main_script_http_info)); |
| 618 } | 620 } |
| 619 | 621 |
| 620 // Set up a request for reading the stream. | 622 // Set up a request for reading the stream. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, | 862 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, |
| 861 weak_factory_.GetWeakPtr(), active_worker), | 863 weak_factory_.GetWeakPtr(), active_worker), |
| 862 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, | 864 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, |
| 863 weak_factory_.GetWeakPtr()))); | 865 weak_factory_.GetWeakPtr()))); |
| 864 worker_start_time_ = base::TimeTicks::Now(); | 866 worker_start_time_ = base::TimeTicks::Now(); |
| 865 fetch_dispatcher_->MaybeStartNavigationPreload(request()); | 867 fetch_dispatcher_->MaybeStartNavigationPreload(request()); |
| 866 fetch_dispatcher_->Run(); | 868 fetch_dispatcher_->Run(); |
| 867 } | 869 } |
| 868 | 870 |
| 869 } // namespace content | 871 } // namespace content |
| OLD | NEW |