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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
531 // Treat a response whose status is 0 as a Network Error. | 531 // Treat a response whose status is 0 as a Network Error. |
532 if (response.status_code == 0) { | 532 if (response.status_code == 0) { |
533 NotifyDone( | 533 NotifyDone( |
534 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED)); | 534 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED)); |
535 return; | 535 return; |
536 } | 536 } |
537 | 537 |
538 fetch_end_time_ = base::TimeTicks::Now(); | 538 fetch_end_time_ = base::TimeTicks::Now(); |
539 load_timing_info_.send_end = fetch_end_time_; | 539 load_timing_info_.send_end = fetch_end_time_; |
540 | 540 |
541 // Fills SSLInfo using the ServiceWorker script's SSLInfo to show HTTPS | |
542 // padlock. | |
543 // TODO(horo): When we support mixed-content (HTTP) no-cors requests from a | |
544 // ServiceWorker, we have to check the security level of the responses. | |
falken
2015/01/27 06:39:58
can we DCHECK(!http_response_info_)
horo
2015/01/27 06:48:15
Done.
| |
545 http_response_info_.reset(new net::HttpResponseInfo()); | |
546 http_response_info_->ssl_info = | |
547 provider_host_->active_version()->GetMainScriptSSLInfo(); | |
548 | |
541 // Set up a request for reading the stream. | 549 // Set up a request for reading the stream. |
542 if (response.stream_url.is_valid()) { | 550 if (response.stream_url.is_valid()) { |
543 DCHECK(response.blob_uuid.empty()); | 551 DCHECK(response.blob_uuid.empty()); |
544 DCHECK(provider_host_->active_version()); | 552 DCHECK(provider_host_->active_version()); |
545 streaming_version_ = provider_host_->active_version(); | 553 streaming_version_ = provider_host_->active_version(); |
546 streaming_version_->AddStreamingURLRequestJob(this); | 554 streaming_version_->AddStreamingURLRequestJob(this); |
547 response_url_ = response.url; | 555 response_url_ = response.url; |
548 service_worker_response_type_ = response.response_type; | 556 service_worker_response_type_ = response.response_type; |
549 CreateResponseHeader( | 557 CreateResponseHeader( |
550 response.status_code, response.status_text, response.headers); | 558 response.status_code, response.status_text, response.headers); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 std::string header; | 611 std::string header; |
604 header.reserve(it->first.size() + 2 + it->second.size()); | 612 header.reserve(it->first.size() + 2 + it->second.size()); |
605 header.append(it->first); | 613 header.append(it->first); |
606 header.append(": "); | 614 header.append(": "); |
607 header.append(it->second); | 615 header.append(it->second); |
608 http_response_headers_->AddHeader(header); | 616 http_response_headers_->AddHeader(header); |
609 } | 617 } |
610 } | 618 } |
611 | 619 |
612 void ServiceWorkerURLRequestJob::CommitResponseHeader() { | 620 void ServiceWorkerURLRequestJob::CommitResponseHeader() { |
613 http_response_info_.reset(new net::HttpResponseInfo()); | 621 if (!http_response_info_) |
622 http_response_info_.reset(new net::HttpResponseInfo()); | |
614 http_response_info_->headers.swap(http_response_headers_); | 623 http_response_info_->headers.swap(http_response_headers_); |
615 NotifyHeadersComplete(); | 624 NotifyHeadersComplete(); |
616 } | 625 } |
617 | 626 |
618 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 627 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
619 // TODO(falken): Print an error to the console of the ServiceWorker and of | 628 // TODO(falken): Print an error to the console of the ServiceWorker and of |
620 // the requesting page. | 629 // the requesting page. |
621 CreateResponseHeader( | 630 CreateResponseHeader( |
622 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); | 631 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); |
623 CommitResponseHeader(); | 632 CommitResponseHeader(); |
(...skipping 11 matching lines...) Expand all Loading... | |
635 } | 644 } |
636 if (!waiting_stream_url_.is_empty()) { | 645 if (!waiting_stream_url_.is_empty()) { |
637 StreamRegistry* stream_registry = | 646 StreamRegistry* stream_registry = |
638 GetStreamContextForResourceContext(resource_context_)->registry(); | 647 GetStreamContextForResourceContext(resource_context_)->registry(); |
639 stream_registry->RemoveRegisterObserver(waiting_stream_url_); | 648 stream_registry->RemoveRegisterObserver(waiting_stream_url_); |
640 stream_registry->AbortPendingStream(waiting_stream_url_); | 649 stream_registry->AbortPendingStream(waiting_stream_url_); |
641 } | 650 } |
642 } | 651 } |
643 | 652 |
644 } // namespace content | 653 } // namespace content |
OLD | NEW |