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

Side by Side Diff: net/http/http_network_transaction.cc

Issue 2808010: Add field trial stats for alternate_protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | net/http/http_network_transaction_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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/field_trial.h" 8 #include "base/field_trial.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (request_info->extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, 148 if (request_info->extra_headers.GetHeader(HttpRequestHeaders::kUserAgent,
149 &user_agent)) 149 &user_agent))
150 request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent); 150 request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent);
151 151
152 request_headers->MergeFrom(authorization_headers); 152 request_headers->MergeFrom(authorization_headers);
153 } 153 }
154 154
155 void ProcessAlternateProtocol(const HttpResponseHeaders& headers, 155 void ProcessAlternateProtocol(const HttpResponseHeaders& headers,
156 const HostPortPair& http_host_port_pair, 156 const HostPortPair& http_host_port_pair,
157 HttpAlternateProtocols* alternate_protocols) { 157 HttpAlternateProtocols* alternate_protocols) {
158 if (!g_next_protos || g_next_protos->empty()) {
159 // This implies that NPN is not supported. We don't currently support any
160 // alternate protocols that don't use NPN.
161 return;
162 }
163 158
164 std::string alternate_protocol_str; 159 std::string alternate_protocol_str;
165 if (!headers.EnumerateHeader(NULL, HttpAlternateProtocols::kHeader, 160 if (!headers.EnumerateHeader(NULL, HttpAlternateProtocols::kHeader,
166 &alternate_protocol_str)) { 161 &alternate_protocol_str)) {
167 // Header is not present. 162 // Header is not present.
168 return; 163 return;
169 } 164 }
170 165
171 std::vector<std::string> port_protocol_vector; 166 std::vector<std::string> port_protocol_vector;
172 SplitString(alternate_protocol_str, ':', &port_protocol_vector); 167 SplitString(alternate_protocol_str, ':', &port_protocol_vector);
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 url_canon::Replacements<char> replacements; 751 url_canon::Replacements<char> replacements;
757 const std::string port_str = IntToString(endpoint_.port); 752 const std::string port_str = IntToString(endpoint_.port);
758 replacements.SetPort(port_str.c_str(), 753 replacements.SetPort(port_str.c_str(),
759 url_parse::Component(0, port_str.size())); 754 url_parse::Component(0, port_str.size()));
760 replacements.SetHost(endpoint_.host.c_str(), 755 replacements.SetHost(endpoint_.host.c_str(),
761 url_parse::Component(0, endpoint_.host.size())); 756 url_parse::Component(0, endpoint_.host.size()));
762 alternate_endpoint_url = curr_endpoint_url->ReplaceComponents(replacements); 757 alternate_endpoint_url = curr_endpoint_url->ReplaceComponents(replacements);
763 curr_endpoint_url = &alternate_endpoint_url; 758 curr_endpoint_url = &alternate_endpoint_url;
764 } 759 }
765 760
766 if (alternate_protocol_mode_ == kUnspecified) { 761 const HttpAlternateProtocols& alternate_protocols =
767 const HttpAlternateProtocols& alternate_protocols = 762 session_->alternate_protocols();
768 session_->alternate_protocols(); 763 if (alternate_protocols.HasAlternateProtocolFor(endpoint_)) {
769 if (alternate_protocols.HasAlternateProtocolFor(endpoint_)) { 764 response_.was_alternate_protocol_available = true;
765 if (alternate_protocol_mode_ == kUnspecified) {
770 HttpAlternateProtocols::PortProtocolPair alternate = 766 HttpAlternateProtocols::PortProtocolPair alternate =
771 alternate_protocols.GetAlternateProtocolFor(endpoint_); 767 alternate_protocols.GetAlternateProtocolFor(endpoint_);
772 if (alternate.protocol != HttpAlternateProtocols::BROKEN) { 768 if (alternate.protocol != HttpAlternateProtocols::BROKEN) {
773 DCHECK_EQ(HttpAlternateProtocols::NPN_SPDY_1, alternate.protocol); 769 DCHECK_EQ(HttpAlternateProtocols::NPN_SPDY_1, alternate.protocol);
774 endpoint_.port = alternate.port; 770 endpoint_.port = alternate.port;
775 alternate_protocol_ = HttpAlternateProtocols::NPN_SPDY_1; 771 alternate_protocol_ = HttpAlternateProtocols::NPN_SPDY_1;
776 alternate_protocol_mode_ = kUsingAlternateProtocol; 772 alternate_protocol_mode_ = kUsingAlternateProtocol;
777 773
778 url_canon::Replacements<char> replacements; 774 url_canon::Replacements<char> replacements;
779 replacements.SetScheme("https", 775 replacements.SetScheme("https",
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 endpoint_); 2028 endpoint_);
2033 2029
2034 alternate_protocol_mode_ = kDoNotUseAlternateProtocol; 2030 alternate_protocol_mode_ = kDoNotUseAlternateProtocol;
2035 if (connection_->socket()) 2031 if (connection_->socket())
2036 connection_->socket()->Disconnect(); 2032 connection_->socket()->Disconnect();
2037 connection_->Reset(); 2033 connection_->Reset();
2038 next_state_ = STATE_INIT_CONNECTION; 2034 next_state_ = STATE_INIT_CONNECTION;
2039 } 2035 }
2040 2036
2041 } // namespace net 2037 } // namespace net
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698