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

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

Issue 13834009: SPDY - Re-land greedy read support for SpdySession (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: histograms to track bytes_read during init Created 7 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 <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 size_t max_concurrent_streams_limit, 322 size_t max_concurrent_streams_limit,
323 TimeFunc time_func, 323 TimeFunc time_func,
324 const HostPortPair& trusted_spdy_proxy, 324 const HostPortPair& trusted_spdy_proxy,
325 NetLog* net_log) 325 NetLog* net_log)
326 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 326 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
327 host_port_proxy_pair_(host_port_proxy_pair), 327 host_port_proxy_pair_(host_port_proxy_pair),
328 spdy_session_pool_(spdy_session_pool), 328 spdy_session_pool_(spdy_session_pool),
329 http_server_properties_(http_server_properties), 329 http_server_properties_(http_server_properties),
330 connection_(new ClientSocketHandle), 330 connection_(new ClientSocketHandle),
331 read_buffer_(new IOBuffer(kReadBufferSize)), 331 read_buffer_(new IOBuffer(kReadBufferSize)),
332 read_pending_(false),
333 stream_hi_water_mark_(kFirstStreamId), 332 stream_hi_water_mark_(kFirstStreamId),
334 write_pending_(false), 333 write_pending_(false),
335 delayed_write_pending_(false), 334 delayed_write_pending_(false),
336 is_secure_(false), 335 is_secure_(false),
337 certificate_error_code_(OK), 336 certificate_error_code_(OK),
338 error_(OK), 337 error_(OK),
339 state_(IDLE), 338 state_(STATE_IDLE),
340 max_concurrent_streams_(initial_max_concurrent_streams == 0 ? 339 max_concurrent_streams_(initial_max_concurrent_streams == 0 ?
341 kInitialMaxConcurrentStreams : 340 kInitialMaxConcurrentStreams :
342 initial_max_concurrent_streams), 341 initial_max_concurrent_streams),
343 max_concurrent_streams_limit_(max_concurrent_streams_limit == 0 ? 342 max_concurrent_streams_limit_(max_concurrent_streams_limit == 0 ?
344 kMaxConcurrentStreamLimit : 343 kMaxConcurrentStreamLimit :
345 max_concurrent_streams_limit), 344 max_concurrent_streams_limit),
346 streams_initiated_count_(0), 345 streams_initiated_count_(0),
347 streams_pushed_count_(0), 346 streams_pushed_count_(0),
348 streams_pushed_and_claimed_count_(0), 347 streams_pushed_and_claimed_count_(0),
349 streams_abandoned_count_(0), 348 streams_abandoned_count_(0),
350 bytes_received_(0), 349 total_bytes_received_(0),
350 bytes_read_(0),
351 sent_settings_(false), 351 sent_settings_(false),
352 received_settings_(false), 352 received_settings_(false),
353 stalled_streams_(0), 353 stalled_streams_(0),
354 pings_in_flight_(0), 354 pings_in_flight_(0),
355 next_ping_id_(1), 355 next_ping_id_(1),
356 last_activity_time_(base::TimeTicks::Now()), 356 last_activity_time_(base::TimeTicks::Now()),
357 check_ping_status_pending_(false), 357 check_ping_status_pending_(false),
358 flow_control_state_(FLOW_CONTROL_NONE), 358 flow_control_state_(FLOW_CONTROL_NONE),
359 stream_initial_send_window_size_(kSpdyStreamInitialWindowSize), 359 stream_initial_send_window_size_(kSpdyStreamInitialWindowSize),
360 stream_initial_recv_window_size_(stream_initial_recv_window_size == 0 ? 360 stream_initial_recv_window_size_(stream_initial_recv_window_size == 0 ?
(...skipping 20 matching lines...) Expand all
381 DCHECK(HttpStreamFactory::spdy_enabled()); 381 DCHECK(HttpStreamFactory::spdy_enabled());
382 net_log_.BeginEvent( 382 net_log_.BeginEvent(
383 NetLog::TYPE_SPDY_SESSION, 383 NetLog::TYPE_SPDY_SESSION,
384 base::Bind(&NetLogSpdySessionCallback, &host_port_proxy_pair_)); 384 base::Bind(&NetLogSpdySessionCallback, &host_port_proxy_pair_));
385 next_unclaimed_push_stream_sweep_time_ = time_func_() + 385 next_unclaimed_push_stream_sweep_time_ = time_func_() +
386 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); 386 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds);
387 // TODO(mbelshe): consider randomization of the stream_hi_water_mark. 387 // TODO(mbelshe): consider randomization of the stream_hi_water_mark.
388 } 388 }
389 389
390 SpdySession::~SpdySession() { 390 SpdySession::~SpdySession() {
391 if (state_ != CLOSED) { 391 if (state_ != STATE_CLOSED) {
392 state_ = CLOSED; 392 state_ = STATE_CLOSED;
393 393
394 // Cleanup all the streams. 394 // Cleanup all the streams.
395 CloseAllStreams(net::ERR_ABORTED); 395 CloseAllStreams(net::ERR_ABORTED);
396 } 396 }
397 397
398 if (connection_->is_initialized()) { 398 if (connection_->is_initialized()) {
399 // With SPDY we can't recycle sockets. 399 // With SPDY we can't recycle sockets.
400 connection_->socket()->Disconnect(); 400 connection_->socket()->Disconnect();
401 } 401 }
402 402
(...skipping 11 matching lines...) Expand all
414 net_log_.EndEvent(NetLog::TYPE_SPDY_SESSION); 414 net_log_.EndEvent(NetLog::TYPE_SPDY_SESSION);
415 } 415 }
416 416
417 net::Error SpdySession::InitializeWithSocket( 417 net::Error SpdySession::InitializeWithSocket(
418 ClientSocketHandle* connection, 418 ClientSocketHandle* connection,
419 bool is_secure, 419 bool is_secure,
420 int certificate_error_code) { 420 int certificate_error_code) {
421 base::StatsCounter spdy_sessions("spdy.sessions"); 421 base::StatsCounter spdy_sessions("spdy.sessions");
422 spdy_sessions.Increment(); 422 spdy_sessions.Increment();
423 423
424 state_ = CONNECTED; 424 state_ = STATE_DO_READ;
425 connection_.reset(connection); 425 connection_.reset(connection);
426 is_secure_ = is_secure; 426 is_secure_ = is_secure;
427 certificate_error_code_ = certificate_error_code; 427 certificate_error_code_ = certificate_error_code;
428 428
429 NextProto protocol = default_protocol_; 429 NextProto protocol = default_protocol_;
430 NextProto protocol_negotiated = connection->socket()->GetNegotiatedProtocol(); 430 NextProto protocol_negotiated = connection->socket()->GetNegotiatedProtocol();
431 if (protocol_negotiated != kProtoUnknown) { 431 if (protocol_negotiated != kProtoUnknown) {
432 protocol = protocol_negotiated; 432 protocol = protocol_negotiated;
433 } 433 }
434 434
(...skipping 30 matching lines...) Expand all
465 DCHECK_GT(kDefaultInitialRecvWindowSize, session_recv_window_size_); 465 DCHECK_GT(kDefaultInitialRecvWindowSize, session_recv_window_size_);
466 // This condition implies that |kDefaultInitialRecvWindowSize| - 466 // This condition implies that |kDefaultInitialRecvWindowSize| -
467 // |session_recv_window_size_| doesn't overflow. 467 // |session_recv_window_size_| doesn't overflow.
468 DCHECK_GT(session_recv_window_size_, 0); 468 DCHECK_GT(session_recv_window_size_, 0);
469 IncreaseRecvWindowSize( 469 IncreaseRecvWindowSize(
470 kDefaultInitialRecvWindowSize - session_recv_window_size_); 470 kDefaultInitialRecvWindowSize - session_recv_window_size_);
471 } 471 }
472 472
473 // Write out any data that we might have to send, such as the settings frame. 473 // Write out any data that we might have to send, such as the settings frame.
474 WriteSocketLater(); 474 WriteSocketLater();
475 net::Error error = ReadSocket(); 475 int error = DoLoop(OK);
476 UMA_HISTOGRAM_COUNTS("Net.SpdySession.Init.BytesRead", bytes_read_);
476 if (error == ERR_IO_PENDING) 477 if (error == ERR_IO_PENDING)
477 return OK; 478 return OK;
478 return error; 479 if (error != OK)
480 UMA_HISTOGRAM_COUNTS("Net.SpdySession.InitAndError.BytesRead", bytes_read_);
Ryan Hamilton 2013/04/14 02:21:46 We had also talked about adding a histogram of the
ramant (doing other things) 2013/04/16 19:12:23 Added new histograms per our discussion. Done.
481 return static_cast<net::Error>(error);
479 } 482 }
480 483
481 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { 484 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) {
482 if (!verify_domain_authentication_) 485 if (!verify_domain_authentication_)
483 return true; 486 return true;
484 487
485 if (state_ != CONNECTED) 488 if (!IsConnected())
486 return false; 489 return false;
487 490
488 SSLInfo ssl_info; 491 SSLInfo ssl_info;
489 bool was_npn_negotiated; 492 bool was_npn_negotiated;
490 NextProto protocol_negotiated = kProtoUnknown; 493 NextProto protocol_negotiated = kProtoUnknown;
491 if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated)) 494 if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated))
492 return true; // This is not a secure session, so all domains are okay. 495 return true; // This is not a secure session, so all domains are okay.
493 496
494 return !ssl_info.client_cert_sent && 497 return !ssl_info.client_cert_sent &&
495 (enable_credential_frames_ || !ssl_info.channel_id_sent || 498 (enable_credential_frames_ || !ssl_info.channel_id_sent ||
496 ServerBoundCertService::GetDomainForHost(domain) == 499 ServerBoundCertService::GetDomainForHost(domain) ==
497 ServerBoundCertService::GetDomainForHost( 500 ServerBoundCertService::GetDomainForHost(
498 host_port_proxy_pair_.first.host())) && 501 host_port_proxy_pair_.first.host())) &&
499 ssl_info.cert->VerifyNameMatch(domain); 502 ssl_info.cert->VerifyNameMatch(domain);
500 } 503 }
501 504
502 void SpdySession::SetStreamHasWriteAvailable(SpdyStream* stream, 505 void SpdySession::SetStreamHasWriteAvailable(SpdyStream* stream,
503 SpdyIOBufferProducer* producer) { 506 SpdyIOBufferProducer* producer) {
504 write_queue_.push(producer); 507 write_queue_.push(producer);
505 stream_producers_[producer] = stream; 508 stream_producers_[producer] = stream;
506 WriteSocketLater(); 509 WriteSocketLater();
507 } 510 }
508 511
509 int SpdySession::GetPushStream( 512 int SpdySession::GetPushStream(
510 const GURL& url, 513 const GURL& url,
511 scoped_refptr<SpdyStream>* stream, 514 scoped_refptr<SpdyStream>* stream,
512 const BoundNetLog& stream_net_log) { 515 const BoundNetLog& stream_net_log) {
513 CHECK_NE(state_, CLOSED); 516 CHECK_NE(state_, STATE_CLOSED);
514 517
515 *stream = NULL; 518 *stream = NULL;
516 519
517 // Don't allow access to secure push streams over an unauthenticated, but 520 // Don't allow access to secure push streams over an unauthenticated, but
518 // encrypted SSL socket. 521 // encrypted SSL socket.
519 if (is_secure_ && certificate_error_code_ != OK && 522 if (is_secure_ && certificate_error_code_ != OK &&
520 (url.SchemeIs("https") || url.SchemeIs("wss"))) { 523 (url.SchemeIs("https") || url.SchemeIs("wss"))) {
521 RecordProtocolErrorHistogram( 524 RecordProtocolErrorHistogram(
522 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION); 525 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION);
523 CloseSessionOnError( 526 CloseSessionOnError(
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 return ContainsKey(active_streams_, stream_id); 876 return ContainsKey(active_streams_, stream_id);
874 } 877 }
875 878
876 LoadState SpdySession::GetLoadState() const { 879 LoadState SpdySession::GetLoadState() const {
877 // NOTE: The application only queries the LoadState via the 880 // NOTE: The application only queries the LoadState via the
878 // SpdyNetworkTransaction, and details are only needed when 881 // SpdyNetworkTransaction, and details are only needed when
879 // we're in the process of connecting. 882 // we're in the process of connecting.
880 883
881 // If we're connecting, defer to the connection to give us the actual 884 // If we're connecting, defer to the connection to give us the actual
882 // LoadState. 885 // LoadState.
883 if (state_ == CONNECTING) 886 if (state_ == STATE_CONNECTING)
884 return connection_->GetLoadState(); 887 return connection_->GetLoadState();
885 888
886 // Just report that we're idle since the session could be doing 889 // Just report that we're idle since the session could be doing
887 // many things concurrently. 890 // many things concurrently.
888 return LOAD_STATE_IDLE; 891 return LOAD_STATE_IDLE;
889 } 892 }
890 893
891 void SpdySession::OnReadComplete(int bytes_read) { 894 void SpdySession::OnReadComplete(int bytes_read) {
892 // Parse a frame. For now this code requires that the frame fit into our 895 DCHECK_NE(state_, STATE_DO_READ);
893 // buffer (32KB). 896 DoLoop(bytes_read);
894 // TODO(mbelshe): support arbitrarily large frames! 897 }
895 898
896 read_pending_ = false; 899 void SpdySession::StartRead() {
900 DCHECK_NE(state_, STATE_DO_READ_COMPLETE);
901 DoLoop(OK);
902 }
897 903
898 if (bytes_read <= 0) { 904 int SpdySession::DoLoop(int result) {
899 // Session is tearing down. 905 bytes_read_ = 0;
900 net::Error error = static_cast<net::Error>(bytes_read);
901 if (bytes_read == 0)
902 error = ERR_CONNECTION_CLOSED;
903 CloseSessionOnError(error, true, "bytes_read is <= 0.");
904 return;
905 }
906
907 bytes_received_ += bytes_read;
908
909 last_activity_time_ = base::TimeTicks::Now();
910 906
911 // The SpdyFramer will use callbacks onto |this| as it parses frames. 907 // The SpdyFramer will use callbacks onto |this| as it parses frames.
912 // When errors occur, those callbacks can lead to teardown of all references 908 // When errors occur, those callbacks can lead to teardown of all references
913 // to |this|, so maintain a reference to self during this call for safe 909 // to |this|, so maintain a reference to self during this call for safe
914 // cleanup. 910 // cleanup.
915 scoped_refptr<SpdySession> self(this); 911 scoped_refptr<SpdySession> self(this);
916 912
913 do {
914 switch (state_) {
915 case STATE_DO_READ:
916 DCHECK_EQ(result, OK);
917 result = DoRead();
918 break;
919 case STATE_DO_READ_COMPLETE:
920 result = DoReadComplete(result);
921 break;
922 case STATE_CLOSED:
923 result = ERR_CONNECTION_CLOSED;
924 break;
925 default:
926 NOTREACHED() << "state_: " << state_;
927 break;
928 }
929 } while (result != ERR_IO_PENDING && state_ != STATE_CLOSED);
930
931 return result;
932 }
933
934 int SpdySession::DoRead() {
935 if (bytes_read_ > kMaxReadBytes) {
936 state_ = STATE_DO_READ;
937 MessageLoop::current()->PostTask(
938 FROM_HERE,
939 base::Bind(&SpdySession::StartRead,
940 weak_factory_.GetWeakPtr()));
941 return ERR_IO_PENDING;
942 }
943
944 CHECK(connection_.get());
945 CHECK(connection_->socket());
946 state_ = STATE_DO_READ_COMPLETE;
947 return connection_->socket()->Read(
948 read_buffer_.get(),
949 kReadBufferSize,
950 base::Bind(&SpdySession::OnReadComplete, weak_factory_.GetWeakPtr()));
951 }
952
953 int SpdySession::DoReadComplete(int result) {
954 // Parse a frame. For now this code requires that the frame fit into our
955 // buffer (32KB).
956 // TODO(mbelshe): support arbitrarily large frames!
957
958 if (result <= 0) {
959 // Session is tearing down.
960 net::Error error = static_cast<net::Error>(result);
961 if (result == 0)
962 error = ERR_CONNECTION_CLOSED;
963 CloseSessionOnError(error, true, "result is <= 0.");
964 return ERR_CONNECTION_CLOSED;
965 }
966
967 total_bytes_received_ += result;
968 bytes_read_ += result;
969
970 last_activity_time_ = base::TimeTicks::Now();
971
917 DCHECK(buffered_spdy_framer_.get()); 972 DCHECK(buffered_spdy_framer_.get());
918 char* data = read_buffer_->data(); 973 char* data = read_buffer_->data();
919 while (bytes_read && 974 while (result &&
920 buffered_spdy_framer_->error_code() == 975 buffered_spdy_framer_->error_code() ==
921 SpdyFramer::SPDY_NO_ERROR) { 976 SpdyFramer::SPDY_NO_ERROR) {
922 uint32 bytes_processed = 977 uint32 bytes_processed =
923 buffered_spdy_framer_->ProcessInput(data, bytes_read); 978 buffered_spdy_framer_->ProcessInput(data, result);
924 bytes_read -= bytes_processed; 979 result -= bytes_processed;
925 data += bytes_processed; 980 data += bytes_processed;
926 } 981 }
927 982
928 if (state_ != CLOSED) 983 if (IsConnected())
929 ReadSocket(); 984 state_ = STATE_DO_READ;
985 return OK;
930 } 986 }
931 987
932 void SpdySession::OnWriteComplete(int result) { 988 void SpdySession::OnWriteComplete(int result) {
933 DCHECK(write_pending_); 989 DCHECK(write_pending_);
934 DCHECK(in_flight_write_.size()); 990 DCHECK(in_flight_write_.size());
935 991
936 last_activity_time_ = base::TimeTicks::Now(); 992 last_activity_time_ = base::TimeTicks::Now();
937 write_pending_ = false; 993 write_pending_ = false;
938 994
939 scoped_refptr<SpdyStream> stream = in_flight_write_.stream(); 995 scoped_refptr<SpdyStream> stream = in_flight_write_.stream();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 WriteSocketLater(); 1032 WriteSocketLater();
977 } else { 1033 } else {
978 in_flight_write_.release(); 1034 in_flight_write_.release();
979 1035
980 // The stream is now errored. Close it down. 1036 // The stream is now errored. Close it down.
981 CloseSessionOnError( 1037 CloseSessionOnError(
982 static_cast<net::Error>(result), true, "The stream has errored."); 1038 static_cast<net::Error>(result), true, "The stream has errored.");
983 } 1039 }
984 } 1040 }
985 1041
986 net::Error SpdySession::ReadSocket() {
987 if (read_pending_)
988 return OK;
989
990 if (state_ == CLOSED) {
991 NOTREACHED();
992 return ERR_UNEXPECTED;
993 }
994
995 CHECK(connection_.get());
996 CHECK(connection_->socket());
997 int bytes_read = connection_->socket()->Read(
998 read_buffer_.get(),
999 kReadBufferSize,
1000 base::Bind(&SpdySession::OnReadComplete, base::Unretained(this)));
1001 switch (bytes_read) {
1002 case 0:
1003 // Socket is closed!
1004 CloseSessionOnError(ERR_CONNECTION_CLOSED, true, "bytes_read is 0.");
1005 return ERR_CONNECTION_CLOSED;
1006 case net::ERR_IO_PENDING:
1007 // Waiting for data. Nothing to do now.
1008 read_pending_ = true;
1009 return ERR_IO_PENDING;
1010 default:
1011 // Data was read, process it.
1012 // Schedule the work through the message loop to avoid recursive
1013 // callbacks.
1014 read_pending_ = true;
1015 MessageLoop::current()->PostTask(
1016 FROM_HERE,
1017 base::Bind(&SpdySession::OnReadComplete,
1018 weak_factory_.GetWeakPtr(), bytes_read));
1019 break;
1020 }
1021 return OK;
1022 }
1023
1024 void SpdySession::WriteSocketLater() { 1042 void SpdySession::WriteSocketLater() {
1025 if (delayed_write_pending_) 1043 if (delayed_write_pending_)
1026 return; 1044 return;
1027 1045
1028 if (state_ < CONNECTED) 1046 if (!IsConnected())
1029 return; 1047 return;
1030 1048
1031 delayed_write_pending_ = true; 1049 delayed_write_pending_ = true;
1032 MessageLoop::current()->PostTask( 1050 MessageLoop::current()->PostTask(
1033 FROM_HERE, 1051 FROM_HERE,
1034 base::Bind(&SpdySession::WriteSocket, weak_factory_.GetWeakPtr())); 1052 base::Bind(&SpdySession::WriteSocket, weak_factory_.GetWeakPtr()));
1035 } 1053 }
1036 1054
1037 void SpdySession::WriteSocket() { 1055 void SpdySession::WriteSocket() {
1038 // This function should only be called via WriteSocketLater. 1056 // This function should only be called via WriteSocketLater.
1039 DCHECK(delayed_write_pending_); 1057 DCHECK(delayed_write_pending_);
1040 delayed_write_pending_ = false; 1058 delayed_write_pending_ = false;
1041 1059
1042 // If the socket isn't connected yet, just wait; we'll get called 1060 // If the socket isn't connected yet, just wait; we'll get called
1043 // again when the socket connection completes. If the socket is 1061 // again when the socket connection completes. If the socket is
1044 // closed, just return. 1062 // closed, just return.
1045 if (state_ < CONNECTED || state_ == CLOSED) 1063 if (!IsConnected())
1046 return; 1064 return;
1047 1065
1048 if (write_pending_) // Another write is in progress still. 1066 if (write_pending_) // Another write is in progress still.
1049 return; 1067 return;
1050 1068
1051 // Loop sending frames until we've sent everything or until the write 1069 // Loop sending frames until we've sent everything or until the write
1052 // returns error (or ERR_IO_PENDING). 1070 // returns error (or ERR_IO_PENDING).
1053 DCHECK(buffered_spdy_framer_.get()); 1071 DCHECK(buffered_spdy_framer_.get());
1054 while (in_flight_write_.buffer() || !write_queue_.empty()) { 1072 while (in_flight_write_.buffer() || !write_queue_.empty()) {
1055 if (!in_flight_write_.buffer()) { 1073 if (!in_flight_write_.buffer()) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 scoped_refptr<SpdySession> self(this); 1176 scoped_refptr<SpdySession> self(this);
1159 1177
1160 DCHECK_LT(err, OK); 1178 DCHECK_LT(err, OK);
1161 net_log_.AddEvent( 1179 net_log_.AddEvent(
1162 NetLog::TYPE_SPDY_SESSION_CLOSE, 1180 NetLog::TYPE_SPDY_SESSION_CLOSE,
1163 base::Bind(&NetLogSpdySessionCloseCallback, err, &description)); 1181 base::Bind(&NetLogSpdySessionCloseCallback, err, &description));
1164 1182
1165 // Don't close twice. This can occur because we can have both 1183 // Don't close twice. This can occur because we can have both
1166 // a read and a write outstanding, and each can complete with 1184 // a read and a write outstanding, and each can complete with
1167 // an error. 1185 // an error.
1168 if (state_ != CLOSED) { 1186 if (!IsClosed()) {
1169 state_ = CLOSED; 1187 state_ = STATE_CLOSED;
1170 error_ = err; 1188 error_ = err;
1171 if (remove_from_pool) 1189 if (remove_from_pool)
1172 RemoveFromPool(); 1190 RemoveFromPool();
1173 CloseAllStreams(err); 1191 CloseAllStreams(err);
1174 } 1192 }
1175 } 1193 }
1176 1194
1177 base::Value* SpdySession::GetInfoAsValue() const { 1195 base::Value* SpdySession::GetInfoAsValue() const {
1178 base::DictionaryValue* dict = new base::DictionaryValue(); 1196 base::DictionaryValue* dict = new base::DictionaryValue();
1179 1197
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 SettingsMap::const_iterator it; 2134 SettingsMap::const_iterator it;
2117 for (it = settings_map.begin(); it != settings_map.end(); ++it) { 2135 for (it = settings_map.begin(); it != settings_map.end(); ++it) {
2118 const SpdySettingsIds id = it->first; 2136 const SpdySettingsIds id = it->first;
2119 const uint32 val = it->second.second; 2137 const uint32 val = it->second.second;
2120 switch (id) { 2138 switch (id) {
2121 case SETTINGS_CURRENT_CWND: 2139 case SETTINGS_CURRENT_CWND:
2122 // Record several different histograms to see if cwnd converges 2140 // Record several different histograms to see if cwnd converges
2123 // for larger volumes of data being sent. 2141 // for larger volumes of data being sent.
2124 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd", 2142 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd",
2125 val, 1, 200, 100); 2143 val, 1, 200, 100);
2126 if (bytes_received_ > 10 * 1024) { 2144 if (total_bytes_received_ > 10 * 1024) {
2127 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd10K", 2145 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd10K",
2128 val, 1, 200, 100); 2146 val, 1, 200, 100);
2129 if (bytes_received_ > 25 * 1024) { 2147 if (total_bytes_received_ > 25 * 1024) {
2130 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd25K", 2148 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd25K",
2131 val, 1, 200, 100); 2149 val, 1, 200, 100);
2132 if (bytes_received_ > 50 * 1024) { 2150 if (total_bytes_received_ > 50 * 1024) {
2133 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd50K", 2151 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd50K",
2134 val, 1, 200, 100); 2152 val, 1, 200, 100);
2135 if (bytes_received_ > 100 * 1024) { 2153 if (total_bytes_received_ > 100 * 1024) {
2136 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd100K", 2154 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd100K",
2137 val, 1, 200, 100); 2155 val, 1, 200, 100);
2138 } 2156 }
2139 } 2157 }
2140 } 2158 }
2141 } 2159 }
2142 break; 2160 break;
2143 case SETTINGS_ROUND_TRIP_TIME: 2161 case SETTINGS_ROUND_TRIP_TIME:
2144 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsRTT", 2162 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsRTT",
2145 val, 1, 1200, 100); 2163 val, 1, 1200, 100);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 } 2322 }
2305 2323
2306 session_recv_window_size_ -= delta_window_size; 2324 session_recv_window_size_ -= delta_window_size;
2307 net_log_.AddEvent( 2325 net_log_.AddEvent(
2308 NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW, 2326 NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW,
2309 base::Bind(&NetLogSpdySessionWindowUpdateCallback, 2327 base::Bind(&NetLogSpdySessionWindowUpdateCallback,
2310 -delta_window_size, session_recv_window_size_)); 2328 -delta_window_size, session_recv_window_size_));
2311 } 2329 }
2312 2330
2313 } // namespace net 2331 } // 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