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

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: Unwrap short lines. 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
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 =
472 SSLClientSocket::kProtoUnknown; 469 kProtoUnknown;
wtc 2012/03/30 20:53:51 Nit: move this to the previous line.
Ryan Hamilton 2012/03/30 21:12:13 Done.
473 if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated)) 470 if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated))
474 return true; // This is not a secure session, so all domains are okay. 471 return true; // This is not a secure session, so all domains are okay.
475 472
476 return !ssl_info.client_cert_sent && ssl_info.cert->VerifyNameMatch(domain); 473 return !ssl_info.client_cert_sent && ssl_info.cert->VerifyNameMatch(domain);
477 } 474 }
478 475
479 int SpdySession::GetPushStream( 476 int SpdySession::GetPushStream(
480 const GURL& url, 477 const GURL& url,
481 scoped_refptr<SpdyStream>* stream, 478 scoped_refptr<SpdyStream>* stream,
482 const BoundNetLog& stream_net_log) { 479 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); 615 DCHECK(priority >= net::HIGHEST && priority < net::NUM_PRIORITIES);
619 616
620 DCHECK_EQ(active_streams_[stream_id].get(), stream.get()); 617 DCHECK_EQ(active_streams_[stream_id].get(), stream.get());
621 return OK; 618 return OK;
622 } 619 }
623 620
624 bool SpdySession::NeedsCredentials() const { 621 bool SpdySession::NeedsCredentials() const {
625 if (!is_secure_) 622 if (!is_secure_)
626 return false; 623 return false;
627 SSLClientSocket* ssl_socket = GetSSLClientSocket(); 624 SSLClientSocket* ssl_socket = GetSSLClientSocket();
628 if (ssl_socket->protocol_negotiated() < SSLClientSocket::kProtoSPDY3) 625 if (ssl_socket->protocol_negotiated() < kProtoSPDY3)
629 return false; 626 return false;
630 return ssl_socket->WasDomainBoundCertSent(); 627 return ssl_socket->WasDomainBoundCertSent();
631 } 628 }
632 629
633 void SpdySession::AddPooledAlias(const HostPortProxyPair& alias) { 630 void SpdySession::AddPooledAlias(const HostPortProxyPair& alias) {
634 pooled_aliases_.insert(alias); 631 pooled_aliases_.insert(alias);
635 } 632 }
636 633
637 int SpdySession::GetProtocolVersion() const { 634 int SpdySession::GetProtocolVersion() const {
638 DCHECK(buffered_spdy_framer_.get()); 635 DCHECK(buffered_spdy_framer_.get());
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 } 1167 }
1171 dict->SetString("proxy", host_port_proxy_pair_.second.ToURI()); 1168 dict->SetString("proxy", host_port_proxy_pair_.second.ToURI());
1172 1169
1173 dict->SetInteger("active_streams", active_streams_.size()); 1170 dict->SetInteger("active_streams", active_streams_.size());
1174 1171
1175 dict->SetInteger("unclaimed_pushed_streams", 1172 dict->SetInteger("unclaimed_pushed_streams",
1176 unclaimed_pushed_streams_.size()); 1173 unclaimed_pushed_streams_.size());
1177 1174
1178 dict->SetBoolean("is_secure", is_secure_); 1175 dict->SetBoolean("is_secure", is_secure_);
1179 1176
1180 SSLClientSocket::NextProto proto = SSLClientSocket::kProtoUnknown; 1177 NextProto proto = kProtoUnknown;
1181 if (is_secure_) { 1178 if (is_secure_) {
1182 proto = GetSSLClientSocket()->protocol_negotiated(); 1179 proto = GetSSLClientSocket()->protocol_negotiated();
1183 } 1180 }
1184 dict->SetString("protocol_negotiated", 1181 dict->SetString("protocol_negotiated",
1185 SSLClientSocket::NextProtoToString(proto)); 1182 SSLClientSocket::NextProtoToString(proto));
1186 1183
1187 dict->SetInteger("error", error_); 1184 dict->SetInteger("error", error_);
1188 dict->SetInteger("max_concurrent_streams", max_concurrent_streams_); 1185 dict->SetInteger("max_concurrent_streams", max_concurrent_streams_);
1189 1186
1190 dict->SetInteger("streams_initiated_count", streams_initiated_count_); 1187 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; 1269 scoped_refptr<SpdyStream> stream = it->second;
1273 unclaimed_pushed_streams_.erase(it); 1270 unclaimed_pushed_streams_.erase(it);
1274 used_push_streams.Increment(); 1271 used_push_streams.Increment();
1275 return stream; 1272 return stream;
1276 } 1273 }
1277 return NULL; 1274 return NULL;
1278 } 1275 }
1279 1276
1280 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info, 1277 bool SpdySession::GetSSLInfo(SSLInfo* ssl_info,
1281 bool* was_npn_negotiated, 1278 bool* was_npn_negotiated,
1282 SSLClientSocket::NextProto* protocol_negotiated) { 1279 NextProto* protocol_negotiated) {
1283 if (!is_secure_) { 1280 if (!is_secure_) {
1284 *protocol_negotiated = SSLClientSocket::kProtoUnknown; 1281 *protocol_negotiated = kProtoUnknown;
1285 return false; 1282 return false;
1286 } 1283 }
1287 SSLClientSocket* ssl_socket = GetSSLClientSocket(); 1284 SSLClientSocket* ssl_socket = GetSSLClientSocket();
1288 ssl_socket->GetSSLInfo(ssl_info); 1285 ssl_socket->GetSSLInfo(ssl_info);
1289 *was_npn_negotiated = ssl_socket->was_npn_negotiated(); 1286 *was_npn_negotiated = ssl_socket->was_npn_negotiated();
1290 *protocol_negotiated = ssl_socket->protocol_negotiated(); 1287 *protocol_negotiated = ssl_socket->protocol_negotiated();
1291 return true; 1288 return true;
1292 } 1289 }
1293 1290
1294 bool SpdySession::GetSSLCertRequestInfo( 1291 bool SpdySession::GetSSLCertRequestInfo(
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 1947 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
1951 if (!is_secure_) 1948 if (!is_secure_)
1952 return NULL; 1949 return NULL;
1953 SSLClientSocket* ssl_socket = 1950 SSLClientSocket* ssl_socket =
1954 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 1951 reinterpret_cast<SSLClientSocket*>(connection_->socket());
1955 DCHECK(ssl_socket); 1952 DCHECK(ssl_socket);
1956 return ssl_socket; 1953 return ssl_socket;
1957 } 1954 }
1958 1955
1959 } // namespace net 1956 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698