Chromium Code Reviews| 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. | |
| 545 DCHECK(!http_response_info_); | |
| 546 http_response_info_.reset(new net::HttpResponseInfo()); | |
| 547 http_response_info_->ssl_info = | |
| 548 provider_host_->active_version()->GetMainScriptSSLInfo(); | |
|
Ryan Sleevi
2015/01/28 01:04:02
Why do you only copy the SSLInfo? Why not the full
horo
2015/01/28 02:32:05
Done.
| |
| 549 | |
| 541 // Set up a request for reading the stream. | 550 // Set up a request for reading the stream. |
| 542 if (response.stream_url.is_valid()) { | 551 if (response.stream_url.is_valid()) { |
| 543 DCHECK(response.blob_uuid.empty()); | 552 DCHECK(response.blob_uuid.empty()); |
| 544 DCHECK(provider_host_->active_version()); | 553 DCHECK(provider_host_->active_version()); |
| 545 streaming_version_ = provider_host_->active_version(); | 554 streaming_version_ = provider_host_->active_version(); |
| 546 streaming_version_->AddStreamingURLRequestJob(this); | 555 streaming_version_->AddStreamingURLRequestJob(this); |
| 547 response_url_ = response.url; | 556 response_url_ = response.url; |
| 548 service_worker_response_type_ = response.response_type; | 557 service_worker_response_type_ = response.response_type; |
| 549 CreateResponseHeader( | 558 CreateResponseHeader( |
| 550 response.status_code, response.status_text, response.headers); | 559 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; | 612 std::string header; |
| 604 header.reserve(it->first.size() + 2 + it->second.size()); | 613 header.reserve(it->first.size() + 2 + it->second.size()); |
| 605 header.append(it->first); | 614 header.append(it->first); |
| 606 header.append(": "); | 615 header.append(": "); |
| 607 header.append(it->second); | 616 header.append(it->second); |
| 608 http_response_headers_->AddHeader(header); | 617 http_response_headers_->AddHeader(header); |
| 609 } | 618 } |
| 610 } | 619 } |
| 611 | 620 |
| 612 void ServiceWorkerURLRequestJob::CommitResponseHeader() { | 621 void ServiceWorkerURLRequestJob::CommitResponseHeader() { |
| 613 http_response_info_.reset(new net::HttpResponseInfo()); | 622 if (!http_response_info_) |
| 623 http_response_info_.reset(new net::HttpResponseInfo()); | |
| 614 http_response_info_->headers.swap(http_response_headers_); | 624 http_response_info_->headers.swap(http_response_headers_); |
| 615 NotifyHeadersComplete(); | 625 NotifyHeadersComplete(); |
| 616 } | 626 } |
| 617 | 627 |
| 618 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 628 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
| 619 // TODO(falken): Print an error to the console of the ServiceWorker and of | 629 // TODO(falken): Print an error to the console of the ServiceWorker and of |
| 620 // the requesting page. | 630 // the requesting page. |
| 621 CreateResponseHeader( | 631 CreateResponseHeader( |
| 622 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); | 632 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); |
| 623 CommitResponseHeader(); | 633 CommitResponseHeader(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 635 } | 645 } |
| 636 if (!waiting_stream_url_.is_empty()) { | 646 if (!waiting_stream_url_.is_empty()) { |
| 637 StreamRegistry* stream_registry = | 647 StreamRegistry* stream_registry = |
| 638 GetStreamContextForResourceContext(resource_context_)->registry(); | 648 GetStreamContextForResourceContext(resource_context_)->registry(); |
| 639 stream_registry->RemoveRegisterObserver(waiting_stream_url_); | 649 stream_registry->RemoveRegisterObserver(waiting_stream_url_); |
| 640 stream_registry->AbortPendingStream(waiting_stream_url_); | 650 stream_registry->AbortPendingStream(waiting_stream_url_); |
| 641 } | 651 } |
| 642 } | 652 } |
| 643 | 653 |
| 644 } // namespace content | 654 } // namespace content |
| OLD | NEW |