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

Side by Side Diff: content/browser/loader/resource_loader.cc

Issue 1275743005: Attach security info to redirect responses (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 302 Found capitalization Created 5 years, 4 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
« no previous file with comments | « no previous file | content/browser/loader/resource_loader_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/loader/resource_loader.h" 5 #include "content/browser/loader/resource_loader.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
(...skipping 29 matching lines...) Expand all
40 40
41 using base::TimeDelta; 41 using base::TimeDelta;
42 using base::TimeTicks; 42 using base::TimeTicks;
43 43
44 namespace content { 44 namespace content {
45 namespace { 45 namespace {
46 46
47 // The interval for calls to ResourceLoader::ReportUploadProgress. 47 // The interval for calls to ResourceLoader::ReportUploadProgress.
48 const int kUploadProgressIntervalMsec = 100; 48 const int kUploadProgressIntervalMsec = 100;
49 49
50 void PopulateResourceResponse(ResourceRequestInfoImpl* info,
51 net::URLRequest* request,
52 ResourceResponse* response) {
53 response->head.request_time = request->request_time();
54 response->head.response_time = request->response_time();
55 response->head.headers = request->response_headers();
56 request->GetCharset(&response->head.charset);
57 response->head.content_length = request->GetExpectedContentSize();
58 request->GetMimeType(&response->head.mime_type);
59 net::HttpResponseInfo response_info = request->response_info();
60 response->head.was_fetched_via_spdy = response_info.was_fetched_via_spdy;
61 response->head.was_npn_negotiated = response_info.was_npn_negotiated;
62 response->head.npn_negotiated_protocol =
63 response_info.npn_negotiated_protocol;
64 response->head.connection_info = response_info.connection_info;
65 response->head.was_fetched_via_proxy = request->was_fetched_via_proxy();
66 response->head.proxy_server = response_info.proxy_server;
67 response->head.socket_address = request->GetSocketAddress();
68 if (ServiceWorkerRequestHandler* handler =
69 ServiceWorkerRequestHandler::GetHandler(request)) {
70 handler->GetExtraResponseInfo(&response->head);
71 }
72 AppCacheInterceptor::GetExtraResponseInfo(
73 request,
74 &response->head.appcache_id,
75 &response->head.appcache_manifest_url);
76 if (info->is_load_timing_enabled())
77 request->GetLoadTimingInfo(&response->head.load_timing);
78 }
79
80 void StoreSignedCertificateTimestamps( 50 void StoreSignedCertificateTimestamps(
81 const net::SignedCertificateTimestampAndStatusList& sct_list, 51 const net::SignedCertificateTimestampAndStatusList& sct_list,
82 int process_id, 52 int process_id,
83 SignedCertificateTimestampIDStatusList* sct_ids) { 53 SignedCertificateTimestampIDStatusList* sct_ids) {
84 SignedCertificateTimestampStore* sct_store( 54 SignedCertificateTimestampStore* sct_store(
85 SignedCertificateTimestampStore::GetInstance()); 55 SignedCertificateTimestampStore::GetInstance());
86 56
87 for (auto iter = sct_list.begin(); iter != sct_list.end(); ++iter) { 57 for (auto iter = sct_list.begin(); iter != sct_list.end(); ++iter) {
88 const int sct_id(sct_store->Store(iter->sct.get(), process_id)); 58 const int sct_id(sct_store->Store(iter->sct.get(), process_id));
89 sct_ids->push_back( 59 sct_ids->push_back(
(...skipping 17 matching lines...) Expand all
107 ssl_status->cert_id = cert_id; 77 ssl_status->cert_id = cert_id;
108 ssl_status->cert_status = ssl_info.cert_status; 78 ssl_status->cert_status = ssl_info.cert_status;
109 ssl_status->security_bits = ssl_info.security_bits; 79 ssl_status->security_bits = ssl_info.security_bits;
110 ssl_status->connection_status = ssl_info.connection_status; 80 ssl_status->connection_status = ssl_info.connection_status;
111 ssl_status->signed_certificate_timestamp_ids = 81 ssl_status->signed_certificate_timestamp_ids =
112 signed_certificate_timestamp_ids; 82 signed_certificate_timestamp_ids;
113 ssl_status->security_style = 83 ssl_status->security_style =
114 SSLPolicy::GetSecurityStyleForResource(url, *ssl_status); 84 SSLPolicy::GetSecurityStyleForResource(url, *ssl_status);
115 } 85 }
116 86
87 void PopulateResourceResponse(ResourceRequestInfoImpl* info,
88 net::URLRequest* request,
89 ResourceResponse* response) {
90 response->head.request_time = request->request_time();
91 response->head.response_time = request->response_time();
92 response->head.headers = request->response_headers();
93 request->GetCharset(&response->head.charset);
94 response->head.content_length = request->GetExpectedContentSize();
95 request->GetMimeType(&response->head.mime_type);
96 net::HttpResponseInfo response_info = request->response_info();
97 response->head.was_fetched_via_spdy = response_info.was_fetched_via_spdy;
98 response->head.was_npn_negotiated = response_info.was_npn_negotiated;
99 response->head.npn_negotiated_protocol =
100 response_info.npn_negotiated_protocol;
101 response->head.connection_info = response_info.connection_info;
102 response->head.was_fetched_via_proxy = request->was_fetched_via_proxy();
103 response->head.proxy_server = response_info.proxy_server;
104 response->head.socket_address = request->GetSocketAddress();
105 if (ServiceWorkerRequestHandler* handler =
106 ServiceWorkerRequestHandler::GetHandler(request)) {
107 handler->GetExtraResponseInfo(&response->head);
108 }
109 AppCacheInterceptor::GetExtraResponseInfo(
110 request, &response->head.appcache_id,
111 &response->head.appcache_manifest_url);
112 if (info->is_load_timing_enabled())
113 request->GetLoadTimingInfo(&response->head.load_timing);
114
115 if (request->ssl_info().cert.get()) {
116 SSLStatus ssl_status;
117 GetSSLStatusForRequest(request->url(), request->ssl_info(),
118 info->GetChildID(), &ssl_status);
119 response->head.security_info = SerializeSecurityInfo(ssl_status);
120 } else {
121 // We should not have any SSL state.
122 DCHECK(!request->ssl_info().cert_status &&
123 request->ssl_info().security_bits == -1 &&
124 !request->ssl_info().connection_status);
125 }
126 }
127
117 } // namespace 128 } // namespace
118 129
119 ResourceLoader::ResourceLoader(scoped_ptr<net::URLRequest> request, 130 ResourceLoader::ResourceLoader(scoped_ptr<net::URLRequest> request,
120 scoped_ptr<ResourceHandler> handler, 131 scoped_ptr<ResourceHandler> handler,
121 ResourceLoaderDelegate* delegate) 132 ResourceLoaderDelegate* delegate)
122 : deferred_stage_(DEFERRED_NONE), 133 : deferred_stage_(DEFERRED_NONE),
123 request_(request.Pass()), 134 request_(request.Pass()),
124 handler_(handler.Pass()), 135 handler_(handler.Pass()),
125 delegate_(delegate), 136 delegate_(delegate),
126 last_upload_position_(0), 137 last_upload_position_(0),
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 FROM_HERE, base::Bind(&ResourceLoader::ResponseCompleted, 591 FROM_HERE, base::Bind(&ResourceLoader::ResponseCompleted,
581 weak_ptr_factory_.GetWeakPtr())); 592 weak_ptr_factory_.GetWeakPtr()));
582 } 593 }
583 } 594 }
584 595
585 void ResourceLoader::CompleteResponseStarted() { 596 void ResourceLoader::CompleteResponseStarted() {
586 ResourceRequestInfoImpl* info = GetRequestInfo(); 597 ResourceRequestInfoImpl* info = GetRequestInfo();
587 scoped_refptr<ResourceResponse> response(new ResourceResponse()); 598 scoped_refptr<ResourceResponse> response(new ResourceResponse());
588 PopulateResourceResponse(info, request_.get(), response.get()); 599 PopulateResourceResponse(info, request_.get(), response.get());
589 600
590 if (request_->ssl_info().cert.get()) {
591 SSLStatus ssl_status;
592 GetSSLStatusForRequest(request_->url(), request_->ssl_info(),
593 info->GetChildID(), &ssl_status);
594
595 response->head.security_info = SerializeSecurityInfo(ssl_status);
596 } else {
597 // We should not have any SSL state.
598 DCHECK(!request_->ssl_info().cert_status &&
599 request_->ssl_info().security_bits == -1 &&
600 !request_->ssl_info().connection_status);
601 }
602
603 delegate_->DidReceiveResponse(this); 601 delegate_->DidReceiveResponse(this);
604 602
605 // TODO(darin): Remove ScopedTracker below once crbug.com/475761 is fixed. 603 // TODO(darin): Remove ScopedTracker below once crbug.com/475761 is fixed.
606 tracked_objects::ScopedTracker tracking_profile( 604 tracked_objects::ScopedTracker tracking_profile(
607 FROM_HERE_WITH_EXPLICIT_FUNCTION("475761 OnResponseStarted()")); 605 FROM_HERE_WITH_EXPLICIT_FUNCTION("475761 OnResponseStarted()"));
608 606
609 bool defer = false; 607 bool defer = false;
610 if (!handler_->OnResponseStarted(response.get(), &defer)) { 608 if (!handler_->OnResponseStarted(response.get(), &defer)) {
611 Cancel(); 609 Cancel();
612 } else if (defer) { 610 } else if (defer) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 case net::URLRequestStatus::FAILED: 762 case net::URLRequestStatus::FAILED:
765 status = STATUS_UNDEFINED; 763 status = STATUS_UNDEFINED;
766 break; 764 break;
767 } 765 }
768 766
769 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); 767 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX);
770 } 768 }
771 } 769 }
772 770
773 } // namespace content 771 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/loader/resource_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698