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

Side by Side Diff: net/spdy/spdy_session.cc

Issue 9959033: Move NextProto enum to a new file net/socket/next_proto.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address wtc's comments Created 8 years, 8 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 | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_spdy2_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 "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 285
286 private: 286 private:
287 ~NetLogSpdyGoAwayParameter() {} 287 ~NetLogSpdyGoAwayParameter() {}
288 const SpdyStreamId last_stream_id_; 288 const SpdyStreamId last_stream_id_;
289 const int active_streams_; 289 const int active_streams_;
290 const int unclaimed_streams_; 290 const int unclaimed_streams_;
291 291
292 DISALLOW_COPY_AND_ASSIGN(NetLogSpdyGoAwayParameter); 292 DISALLOW_COPY_AND_ASSIGN(NetLogSpdyGoAwayParameter);
293 }; 293 };
294 294
295 SSLClientSocket::NextProto g_default_protocol = SSLClientSocket::kProtoUnknown; 295 NextProto g_default_protocol = kProtoUnknown;
296 size_t g_init_max_concurrent_streams = 10; 296 size_t g_init_max_concurrent_streams = 10;
297 size_t g_max_concurrent_stream_limit = 256; 297 size_t g_max_concurrent_stream_limit = 256;
298 bool g_enable_ping_based_connection_checking = true; 298 bool g_enable_ping_based_connection_checking = true;
299 299
300 } // namespace 300 } // namespace
301 301
302 // static 302 // static
303 void SpdySession::set_default_protocol( 303 void SpdySession::set_default_protocol(NextProto default_protocol) {
304 SSLClientSocket::NextProto default_protocol) {
305 g_default_protocol = default_protocol; 304 g_default_protocol = default_protocol;
306 } 305 }
307 306
308 // static 307 // static
309 void SpdySession::set_max_concurrent_streams(size_t value) { 308 void SpdySession::set_max_concurrent_streams(size_t value) {
310 g_max_concurrent_stream_limit = value; 309 g_max_concurrent_stream_limit = value;
311 } 310 }
312 311
313 // static 312 // static
314 void SpdySession::set_enable_ping_based_connection_checking(bool enable) { 313 void SpdySession::set_enable_ping_based_connection_checking(bool enable) {
315 g_enable_ping_based_connection_checking = enable; 314 g_enable_ping_based_connection_checking = enable;
316 } 315 }
317 316
318 // static 317 // static
319 void SpdySession::set_init_max_concurrent_streams(size_t value) { 318 void SpdySession::set_init_max_concurrent_streams(size_t value) {
320 g_init_max_concurrent_streams = 319 g_init_max_concurrent_streams =
321 std::min(value, g_max_concurrent_stream_limit); 320 std::min(value, g_max_concurrent_stream_limit);
322 } 321 }
323 322
324 // static 323 // static
325 void SpdySession::ResetStaticSettingsToInit() { 324 void SpdySession::ResetStaticSettingsToInit() {
326 // WARNING: These must match the initializers above. 325 // WARNING: These must match the initializers above.
327 g_default_protocol = SSLClientSocket::kProtoUnknown; 326 g_default_protocol = kProtoUnknown;
328 g_init_max_concurrent_streams = 10; 327 g_init_max_concurrent_streams = 10;
329 g_max_concurrent_stream_limit = 256; 328 g_max_concurrent_stream_limit = 256;
330 g_enable_ping_based_connection_checking = true; 329 g_enable_ping_based_connection_checking = true;
331 } 330 }
332 331
333 SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair, 332 SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair,
334 SpdySessionPool* spdy_session_pool, 333 SpdySessionPool* spdy_session_pool,
335 HttpServerProperties* http_server_properties, 334 HttpServerProperties* http_server_properties,
336 bool verify_domain_authentication, 335 bool verify_domain_authentication,
337 NetLog* net_log) 336 NetLog* net_log)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 bool is_secure, 416 bool is_secure,
418 int certificate_error_code) { 417 int certificate_error_code) {
419 base::StatsCounter spdy_sessions("spdy.sessions"); 418 base::StatsCounter spdy_sessions("spdy.sessions");
420 spdy_sessions.Increment(); 419 spdy_sessions.Increment();
421 420
422 state_ = CONNECTED; 421 state_ = CONNECTED;
423 connection_.reset(connection); 422 connection_.reset(connection);
424 is_secure_ = is_secure; 423 is_secure_ = is_secure;
425 certificate_error_code_ = certificate_error_code; 424 certificate_error_code_ = certificate_error_code;
426 425
427 SSLClientSocket::NextProto protocol = g_default_protocol; 426 NextProto protocol = g_default_protocol;
428 if (is_secure_) { 427 if (is_secure_) {
429 SSLClientSocket* ssl_socket = GetSSLClientSocket(); 428 SSLClientSocket* ssl_socket = GetSSLClientSocket();
430 429 NextProto protocol_negotiated = ssl_socket->protocol_negotiated();
431 SSLClientSocket::NextProto protocol_negotiated = 430 if (protocol_negotiated != kProtoUnknown) {
432 ssl_socket->protocol_negotiated();
433 if (protocol_negotiated != SSLClientSocket::kProtoUnknown) {
434 protocol = protocol_negotiated; 431 protocol = protocol_negotiated;
435 } 432 }
436 433
437 if (ssl_socket->WasDomainBoundCertSent()) { 434 if (ssl_socket->WasDomainBoundCertSent()) {
438 // According to the SPDY spec, the credential associated with the TLS 435 // According to the SPDY spec, the credential associated with the TLS
439 // connection is stored in slot[1]. 436 // connection is stored in slot[1].
440 credential_state_.SetHasCredential(GURL("https://" + 437 credential_state_.SetHasCredential(GURL("https://" +
441 host_port_pair().ToString())); 438 host_port_pair().ToString()));
442 } 439 }
443 } 440 }
444 441
445 DCHECK(protocol >= SSLClientSocket::kProtoSPDY2); 442 DCHECK(protocol >= kProtoSPDY2);
446 DCHECK(protocol <= SSLClientSocket::kProtoSPDY3); 443 DCHECK(protocol <= kProtoSPDY3);
447 int version = (protocol == SSLClientSocket::kProtoSPDY3) ? 3 : 2; 444 int version = (protocol == kProtoSPDY3) ? 3 : 2;
448 flow_control_ = (protocol >= SSLClientSocket::kProtoSPDY21); 445 flow_control_ = (protocol >= kProtoSPDY21);
449 446
450 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version)); 447 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version));
451 buffered_spdy_framer_->set_visitor(this); 448 buffered_spdy_framer_->set_visitor(this);
452 SendSettings(); 449 SendSettings();
453 450
454 // Write out any data that we might have to send, such as the settings frame. 451 // Write out any data that we might have to send, such as the settings frame.
455 WriteSocketLater(); 452 WriteSocketLater();
456 net::Error error = ReadSocket(); 453 net::Error error = ReadSocket();
457 if (error == ERR_IO_PENDING) 454 if (error == ERR_IO_PENDING)
458 return OK; 455 return OK;
459 return error; 456 return error;
460 } 457 }
461 458
462 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { 459 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) {
463 if (!verify_domain_authentication_) 460 if (!verify_domain_authentication_)
464 return true; 461 return true;
465 462
466 if (state_ != CONNECTED) 463 if (state_ != CONNECTED)
467 return false; 464 return false;
468 465
469 SSLInfo ssl_info; 466 SSLInfo ssl_info;
470 bool was_npn_negotiated; 467 bool was_npn_negotiated;
471 SSLClientSocket::NextProto protocol_negotiated = 468 NextProto protocol_negotiated = kProtoUnknown;
472 SSLClientSocket::kProtoUnknown;
473 if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated)) 469 if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated))
474 return true; // This is not a secure session, so all domains are okay. 470 return true; // This is not a secure session, so all domains are okay.
475 471
476 return !ssl_info.client_cert_sent && ssl_info.cert->VerifyNameMatch(domain); 472 return !ssl_info.client_cert_sent && ssl_info.cert->VerifyNameMatch(domain);
477 } 473 }
478 474
479 int SpdySession::GetPushStream( 475 int SpdySession::GetPushStream(
480 const GURL& url, 476 const GURL& url,
481 scoped_refptr<SpdyStream>* stream, 477 scoped_refptr<SpdyStream>* stream,
482 const BoundNetLog& stream_net_log) { 478 const BoundNetLog& stream_net_log) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 DCHECK(priority >= net::HIGHEST && priority < net::NUM_PRIORITIES); 614 DCHECK(priority >= net::HIGHEST && priority < net::NUM_PRIORITIES);
619 615
620 DCHECK_EQ(active_streams_[stream_id].get(), stream.get()); 616 DCHECK_EQ(active_streams_[stream_id].get(), stream.get());
621 return OK; 617 return OK;
622 } 618 }
623 619
624 bool SpdySession::NeedsCredentials() const { 620 bool SpdySession::NeedsCredentials() const {
625 if (!is_secure_) 621 if (!is_secure_)
626 return false; 622 return false;
627 SSLClientSocket* ssl_socket = GetSSLClientSocket(); 623 SSLClientSocket* ssl_socket = GetSSLClientSocket();
628 if (ssl_socket->protocol_negotiated() < SSLClientSocket::kProtoSPDY3) 624 if (ssl_socket->protocol_negotiated() < kProtoSPDY3)
629 return false; 625 return false;
630 return ssl_socket->WasDomainBoundCertSent(); 626 return ssl_socket->WasDomainBoundCertSent();
631 } 627 }
632 628
633 void SpdySession::AddPooledAlias(const HostPortProxyPair& alias) { 629 void SpdySession::AddPooledAlias(const HostPortProxyPair& alias) {
634 pooled_aliases_.insert(alias); 630 pooled_aliases_.insert(alias);
635 } 631 }
636 632
637 int SpdySession::GetProtocolVersion() const { 633 int SpdySession::GetProtocolVersion() const {
638 DCHECK(buffered_spdy_framer_.get()); 634 DCHECK(buffered_spdy_framer_.get());
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 } 1166 }
1171 dict->SetString("proxy", host_port_proxy_pair_.second.ToURI()); 1167 dict->SetString("proxy", host_port_proxy_pair_.second.ToURI());
1172 1168
1173 dict->SetInteger("active_streams", active_streams_.size()); 1169 dict->SetInteger("active_streams", active_streams_.size());
1174 1170
1175 dict->SetInteger("unclaimed_pushed_streams", 1171 dict->SetInteger("unclaimed_pushed_streams",
1176 unclaimed_pushed_streams_.size()); 1172 unclaimed_pushed_streams_.size());
1177 1173
1178 dict->SetBoolean("is_secure", is_secure_); 1174 dict->SetBoolean("is_secure", is_secure_);
1179 1175
1180 SSLClientSocket::NextProto proto = SSLClientSocket::kProtoUnknown; 1176 NextProto proto = kProtoUnknown;
1181 if (is_secure_) { 1177 if (is_secure_) {
1182 proto = GetSSLClientSocket()->protocol_negotiated(); 1178 proto = GetSSLClientSocket()->protocol_negotiated();
1183 } 1179 }
1184 dict->SetString("protocol_negotiated", 1180 dict->SetString("protocol_negotiated",
1185 SSLClientSocket::NextProtoToString(proto)); 1181 SSLClientSocket::NextProtoToString(proto));
1186 1182
1187 dict->SetInteger("error", error_); 1183 dict->SetInteger("error", error_);
1188 dict->SetInteger("max_concurrent_streams", max_concurrent_streams_); 1184 dict->SetInteger("max_concurrent_streams", max_concurrent_streams_);
1189 1185
1190 dict->SetInteger("streams_initiated_count", streams_initiated_count_); 1186 dict->SetInteger("streams_initiated_count", streams_initiated_count_);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 scoped_refptr<SpdyStream> stream = it->second; 1268 scoped_refptr<SpdyStream> stream = it->second;
1273 unclaimed_pushed_streams_.erase(it); 1269 unclaimed_pushed_streams_.erase(it);
1274 used_push_streams.Increment(); 1270 used_push_streams.Increment();
1275 return stream; 1271 return stream;
1276 } 1272 }
1277 return NULL; 1273 return NULL;
1278 } 1274 }
1279 1275
1280 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info, 1276 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info,
1281 bool* was_npn_negotiated, 1277 bool* was_npn_negotiated,
1282 SSLClientSocket::NextProto* protocol_negotiated) { 1278 NextProto* protocol_negotiated) {
1283 if (!is_secure_) { 1279 if (!is_secure_) {
1284 *protocol_negotiated = SSLClientSocket::kProtoUnknown; 1280 *protocol_negotiated = kProtoUnknown;
1285 return false; 1281 return false;
1286 } 1282 }
1287 SSLClientSocket* ssl_socket = GetSSLClientSocket(); 1283 SSLClientSocket* ssl_socket = GetSSLClientSocket();
1288 ssl_socket->GetSSLInfo(ssl_info); 1284 ssl_socket->GetSSLInfo(ssl_info);
1289 *was_npn_negotiated = ssl_socket->was_npn_negotiated(); 1285 *was_npn_negotiated = ssl_socket->was_npn_negotiated();
1290 *protocol_negotiated = ssl_socket->protocol_negotiated(); 1286 *protocol_negotiated = ssl_socket->protocol_negotiated();
1291 return true; 1287 return true;
1292 } 1288 }
1293 1289
1294 bool SpdySession::GetSSLCertRequestInfo( 1290 bool SpdySession::GetSSLCertRequestInfo(
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 1946 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
1951 if (!is_secure_) 1947 if (!is_secure_)
1952 return NULL; 1948 return NULL;
1953 SSLClientSocket* ssl_socket = 1949 SSLClientSocket* ssl_socket =
1954 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 1950 reinterpret_cast<SSLClientSocket*>(connection_->socket());
1955 DCHECK(ssl_socket); 1951 DCHECK(ssl_socket);
1956 return ssl_socket; 1952 return ssl_socket;
1957 } 1953 }
1958 1954
1959 } // namespace net 1955 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_spdy2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698