Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: content/browser/service_worker/service_worker_url_request_job.cc

Issue 877623002: [ServiceWorker] Fills SSLInfo of the response from a SW with the SSLInfo of the SW script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 bool ServiceWorkerURLRequestJob::GetMimeType(std::string* mime_type) const { 106 bool ServiceWorkerURLRequestJob::GetMimeType(std::string* mime_type) const {
107 if (!http_info()) 107 if (!http_info())
108 return false; 108 return false;
109 return http_info()->headers->GetMimeType(mime_type); 109 return http_info()->headers->GetMimeType(mime_type);
110 } 110 }
111 111
112 void ServiceWorkerURLRequestJob::GetResponseInfo(net::HttpResponseInfo* info) { 112 void ServiceWorkerURLRequestJob::GetResponseInfo(net::HttpResponseInfo* info) {
113 if (!http_info()) 113 if (!http_info())
114 return; 114 return;
115 const base::Time request_time = info->request_time;
115 *info = *http_info(); 116 *info = *http_info();
117 info->request_time = request_time;
116 info->response_time = response_time_; 118 info->response_time = response_time_;
117 } 119 }
118 120
119 void ServiceWorkerURLRequestJob::GetLoadTimingInfo( 121 void ServiceWorkerURLRequestJob::GetLoadTimingInfo(
120 net::LoadTimingInfo* load_timing_info) const { 122 net::LoadTimingInfo* load_timing_info) const {
121 *load_timing_info = load_timing_info_; 123 *load_timing_info = load_timing_info_;
122 } 124 }
123 125
124 int ServiceWorkerURLRequestJob::GetResponseCode() const { 126 int ServiceWorkerURLRequestJob::GetResponseCode() const {
125 if (!http_info()) 127 if (!http_info())
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // Treat a response whose status is 0 as a Network Error. 533 // Treat a response whose status is 0 as a Network Error.
532 if (response.status_code == 0) { 534 if (response.status_code == 0) {
533 NotifyDone( 535 NotifyDone(
534 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED)); 536 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED));
535 return; 537 return;
536 } 538 }
537 539
538 fetch_end_time_ = base::TimeTicks::Now(); 540 fetch_end_time_ = base::TimeTicks::Now();
539 load_timing_info_.send_end = fetch_end_time_; 541 load_timing_info_.send_end = fetch_end_time_;
540 542
543 // Creates a new HttpResponseInfo using the the ServiceWorker script's
544 // HttpResponseInfo to show HTTPS padlock.
545 // TODO(horo): When we support mixed-content (HTTP) no-cors requests from a
546 // ServiceWorker, we have to check the security level of the responses.
547 DCHECK(!http_response_info_);
548 const net::HttpResponseInfo* main_script_http_info =
549 provider_host_->active_version()->GetMainScriptHttpResponseInfo();
550 DCHECK(main_script_http_info);
551 http_response_info_.reset(new net::HttpResponseInfo(*main_script_http_info));
552
541 // Set up a request for reading the stream. 553 // Set up a request for reading the stream.
542 if (response.stream_url.is_valid()) { 554 if (response.stream_url.is_valid()) {
543 DCHECK(response.blob_uuid.empty()); 555 DCHECK(response.blob_uuid.empty());
544 DCHECK(provider_host_->active_version()); 556 DCHECK(provider_host_->active_version());
545 streaming_version_ = provider_host_->active_version(); 557 streaming_version_ = provider_host_->active_version();
546 streaming_version_->AddStreamingURLRequestJob(this); 558 streaming_version_->AddStreamingURLRequestJob(this);
547 response_url_ = response.url; 559 response_url_ = response.url;
548 service_worker_response_type_ = response.response_type; 560 service_worker_response_type_ = response.response_type;
549 CreateResponseHeader( 561 CreateResponseHeader(
550 response.status_code, response.status_text, response.headers); 562 response.status_code, response.status_text, response.headers);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 std::string header; 615 std::string header;
604 header.reserve(it->first.size() + 2 + it->second.size()); 616 header.reserve(it->first.size() + 2 + it->second.size());
605 header.append(it->first); 617 header.append(it->first);
606 header.append(": "); 618 header.append(": ");
607 header.append(it->second); 619 header.append(it->second);
608 http_response_headers_->AddHeader(header); 620 http_response_headers_->AddHeader(header);
609 } 621 }
610 } 622 }
611 623
612 void ServiceWorkerURLRequestJob::CommitResponseHeader() { 624 void ServiceWorkerURLRequestJob::CommitResponseHeader() {
613 http_response_info_.reset(new net::HttpResponseInfo()); 625 if (!http_response_info_)
626 http_response_info_.reset(new net::HttpResponseInfo());
614 http_response_info_->headers.swap(http_response_headers_); 627 http_response_info_->headers.swap(http_response_headers_);
628 http_response_info_->vary_data = net::HttpVaryData();
629 http_response_info_->metadata = nullptr;
615 NotifyHeadersComplete(); 630 NotifyHeadersComplete();
616 } 631 }
617 632
618 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { 633 void ServiceWorkerURLRequestJob::DeliverErrorResponse() {
619 // TODO(falken): Print an error to the console of the ServiceWorker and of 634 // TODO(falken): Print an error to the console of the ServiceWorker and of
620 // the requesting page. 635 // the requesting page.
621 CreateResponseHeader( 636 CreateResponseHeader(
622 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); 637 500, "Service Worker Response Error", ServiceWorkerHeaderMap());
623 CommitResponseHeader(); 638 CommitResponseHeader();
624 } 639 }
(...skipping 10 matching lines...) Expand all
635 } 650 }
636 if (!waiting_stream_url_.is_empty()) { 651 if (!waiting_stream_url_.is_empty()) {
637 StreamRegistry* stream_registry = 652 StreamRegistry* stream_registry =
638 GetStreamContextForResourceContext(resource_context_)->registry(); 653 GetStreamContextForResourceContext(resource_context_)->registry();
639 stream_registry->RemoveRegisterObserver(waiting_stream_url_); 654 stream_registry->RemoveRegisterObserver(waiting_stream_url_);
640 stream_registry->AbortPendingStream(waiting_stream_url_); 655 stream_registry->AbortPendingStream(waiting_stream_url_);
641 } 656 }
642 } 657 }
643 658
644 } // namespace content 659 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698