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

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

Issue 11644088: SPDY - implement greedy approach to read all the data and process it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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/bind.h" 10 #include "base/bind.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 http_server_properties_(http_server_properties), 233 http_server_properties_(http_server_properties),
234 connection_(new ClientSocketHandle), 234 connection_(new ClientSocketHandle),
235 read_buffer_(new IOBuffer(kReadBufferSize)), 235 read_buffer_(new IOBuffer(kReadBufferSize)),
236 read_pending_(false), 236 read_pending_(false),
237 stream_hi_water_mark_(kFirstStreamId), 237 stream_hi_water_mark_(kFirstStreamId),
238 write_pending_(false), 238 write_pending_(false),
239 delayed_write_pending_(false), 239 delayed_write_pending_(false),
240 is_secure_(false), 240 is_secure_(false),
241 certificate_error_code_(OK), 241 certificate_error_code_(OK),
242 error_(OK), 242 error_(OK),
243 state_(IDLE), 243 state_(STATE_IDLE),
244 max_concurrent_streams_(initial_max_concurrent_streams == 0 ? 244 max_concurrent_streams_(initial_max_concurrent_streams == 0 ?
245 kInitialMaxConcurrentStreams : 245 kInitialMaxConcurrentStreams :
246 initial_max_concurrent_streams), 246 initial_max_concurrent_streams),
247 max_concurrent_streams_limit_(max_concurrent_streams_limit == 0 ? 247 max_concurrent_streams_limit_(max_concurrent_streams_limit == 0 ?
248 kMaxConcurrentStreamLimit : 248 kMaxConcurrentStreamLimit :
249 max_concurrent_streams_limit), 249 max_concurrent_streams_limit),
250 streams_initiated_count_(0), 250 streams_initiated_count_(0),
251 streams_pushed_count_(0), 251 streams_pushed_count_(0),
252 streams_pushed_and_claimed_count_(0), 252 streams_pushed_and_claimed_count_(0),
253 streams_abandoned_count_(0), 253 streams_abandoned_count_(0),
254 bytes_received_(0), 254 total_bytes_received_(0),
255 bytes_read_(0),
Ryan Sleevi 2013/02/06 23:04:46 I'm still not sure I understand why we need this,
ramant (doing other things) 2013/02/07 02:11:07 As we had gone over the code, bytes_read_ is used
255 sent_settings_(false), 256 sent_settings_(false),
256 received_settings_(false), 257 received_settings_(false),
257 stalled_streams_(0), 258 stalled_streams_(0),
258 pings_in_flight_(0), 259 pings_in_flight_(0),
259 next_ping_id_(1), 260 next_ping_id_(1),
260 last_activity_time_(base::TimeTicks::Now()), 261 last_activity_time_(base::TimeTicks::Now()),
261 check_ping_status_pending_(false), 262 check_ping_status_pending_(false),
262 flow_control_(false), 263 flow_control_(false),
263 initial_send_window_size_(kSpdyStreamInitialWindowSize), 264 initial_send_window_size_(kSpdyStreamInitialWindowSize),
264 initial_recv_window_size_(initial_recv_window_size == 0 ? 265 initial_recv_window_size_(initial_recv_window_size == 0 ?
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 305
305 SpdySession::CallbackResultPair::CallbackResultPair( 306 SpdySession::CallbackResultPair::CallbackResultPair(
306 const CompletionCallback& callback_in, int result_in) 307 const CompletionCallback& callback_in, int result_in)
307 : callback(callback_in), 308 : callback(callback_in),
308 result(result_in) { 309 result(result_in) {
309 } 310 }
310 311
311 SpdySession::CallbackResultPair::~CallbackResultPair() {} 312 SpdySession::CallbackResultPair::~CallbackResultPair() {}
312 313
313 SpdySession::~SpdySession() { 314 SpdySession::~SpdySession() {
314 if (state_ != CLOSED) { 315 if (state_ != STATE_CLOSED) {
315 state_ = CLOSED; 316 state_ = STATE_CLOSED;
316 317
317 // Cleanup all the streams. 318 // Cleanup all the streams.
318 CloseAllStreams(net::ERR_ABORTED); 319 CloseAllStreams(net::ERR_ABORTED);
319 } 320 }
320 321
321 if (connection_->is_initialized()) { 322 if (connection_->is_initialized()) {
322 // With SPDY we can't recycle sockets. 323 // With SPDY we can't recycle sockets.
323 connection_->socket()->Disconnect(); 324 connection_->socket()->Disconnect();
324 } 325 }
325 326
326 // Streams should all be gone now. 327 // Streams should all be gone now.
327 DCHECK_EQ(0u, num_active_streams()); 328 DCHECK_EQ(0u, num_active_streams());
328 DCHECK_EQ(0u, num_unclaimed_pushed_streams()); 329 DCHECK_EQ(0u, num_unclaimed_pushed_streams());
329 330
330 DCHECK(pending_callback_map_.empty()); 331 DCHECK(pending_callback_map_.empty());
331 332
332 RecordHistograms(); 333 RecordHistograms();
333 334
334 net_log_.EndEvent(NetLog::TYPE_SPDY_SESSION); 335 net_log_.EndEvent(NetLog::TYPE_SPDY_SESSION);
335 } 336 }
336 337
337 net::Error SpdySession::InitializeWithSocket( 338 net::Error SpdySession::InitializeWithSocket(
338 ClientSocketHandle* connection, 339 ClientSocketHandle* connection,
339 bool is_secure, 340 bool is_secure,
340 int certificate_error_code) { 341 int certificate_error_code) {
341 base::StatsCounter spdy_sessions("spdy.sessions"); 342 base::StatsCounter spdy_sessions("spdy.sessions");
342 spdy_sessions.Increment(); 343 spdy_sessions.Increment();
343 344
344 state_ = CONNECTED; 345 state_ = STATE_DO_READ;
345 connection_.reset(connection); 346 connection_.reset(connection);
346 is_secure_ = is_secure; 347 is_secure_ = is_secure;
347 certificate_error_code_ = certificate_error_code; 348 certificate_error_code_ = certificate_error_code;
348 349
349 NextProto protocol = default_protocol_; 350 NextProto protocol = default_protocol_;
350 NextProto protocol_negotiated = connection->socket()->GetNegotiatedProtocol(); 351 NextProto protocol_negotiated = connection->socket()->GetNegotiatedProtocol();
351 if (protocol_negotiated != kProtoUnknown) { 352 if (protocol_negotiated != kProtoUnknown) {
352 protocol = protocol_negotiated; 353 protocol = protocol_negotiated;
353 } 354 }
354 355
(...skipping 11 matching lines...) Expand all
366 flow_control_ = (protocol >= kProtoSPDY3); 367 flow_control_ = (protocol >= kProtoSPDY3);
367 368
368 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version, 369 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version,
369 enable_compression_)); 370 enable_compression_));
370 buffered_spdy_framer_->set_visitor(this); 371 buffered_spdy_framer_->set_visitor(this);
371 SendInitialSettings(); 372 SendInitialSettings();
372 UMA_HISTOGRAM_ENUMERATION("Net.SpdyVersion", protocol, kProtoMaximumVersion); 373 UMA_HISTOGRAM_ENUMERATION("Net.SpdyVersion", protocol, kProtoMaximumVersion);
373 374
374 // Write out any data that we might have to send, such as the settings frame. 375 // Write out any data that we might have to send, such as the settings frame.
375 WriteSocketLater(); 376 WriteSocketLater();
376 net::Error error = ReadSocket(); 377 int error = DoLoop(OK);
377 if (error == ERR_IO_PENDING) 378 if (error == ERR_IO_PENDING)
378 return OK; 379 return OK;
379 return error; 380 return static_cast<net::Error>(error);
380 } 381 }
381 382
382 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { 383 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) {
383 if (!verify_domain_authentication_) 384 if (!verify_domain_authentication_)
384 return true; 385 return true;
385 386
386 if (state_ != CONNECTED) 387 if (!IsConnected())
387 return false; 388 return false;
388 389
389 SSLInfo ssl_info; 390 SSLInfo ssl_info;
390 bool was_npn_negotiated; 391 bool was_npn_negotiated;
391 NextProto protocol_negotiated = kProtoUnknown; 392 NextProto protocol_negotiated = kProtoUnknown;
392 if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated)) 393 if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated))
393 return true; // This is not a secure session, so all domains are okay. 394 return true; // This is not a secure session, so all domains are okay.
394 395
395 return !ssl_info.client_cert_sent && 396 return !ssl_info.client_cert_sent &&
396 (enable_credential_frames_ || !ssl_info.channel_id_sent || 397 (enable_credential_frames_ || !ssl_info.channel_id_sent ||
397 ServerBoundCertService::GetDomainForHost(domain) == 398 ServerBoundCertService::GetDomainForHost(domain) ==
398 ServerBoundCertService::GetDomainForHost( 399 ServerBoundCertService::GetDomainForHost(
399 host_port_proxy_pair_.first.host())) && 400 host_port_proxy_pair_.first.host())) &&
400 ssl_info.cert->VerifyNameMatch(domain); 401 ssl_info.cert->VerifyNameMatch(domain);
401 } 402 }
402 403
403 void SpdySession::SetStreamHasWriteAvailable(SpdyStream* stream, 404 void SpdySession::SetStreamHasWriteAvailable(SpdyStream* stream,
404 SpdyIOBufferProducer* producer) { 405 SpdyIOBufferProducer* producer) {
405 write_queue_.push(producer); 406 write_queue_.push(producer);
406 stream_producers_[producer] = stream; 407 stream_producers_[producer] = stream;
407 WriteSocketLater(); 408 WriteSocketLater();
408 } 409 }
409 410
410 int SpdySession::GetPushStream( 411 int SpdySession::GetPushStream(
411 const GURL& url, 412 const GURL& url,
412 scoped_refptr<SpdyStream>* stream, 413 scoped_refptr<SpdyStream>* stream,
413 const BoundNetLog& stream_net_log) { 414 const BoundNetLog& stream_net_log) {
414 CHECK_NE(state_, CLOSED); 415 CHECK_NE(state_, STATE_CLOSED);
415 416
416 *stream = NULL; 417 *stream = NULL;
417 418
418 // Don't allow access to secure push streams over an unauthenticated, but 419 // Don't allow access to secure push streams over an unauthenticated, but
419 // encrypted SSL socket. 420 // encrypted SSL socket.
420 if (is_secure_ && certificate_error_code_ != OK && 421 if (is_secure_ && certificate_error_code_ != OK &&
421 (url.SchemeIs("https") || url.SchemeIs("wss"))) { 422 (url.SchemeIs("https") || url.SchemeIs("wss"))) {
422 RecordProtocolErrorHistogram( 423 RecordProtocolErrorHistogram(
423 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION); 424 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION);
424 CloseSessionOnError( 425 CloseSessionOnError(
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 return ContainsKey(active_streams_, stream_id); 765 return ContainsKey(active_streams_, stream_id);
765 } 766 }
766 767
767 LoadState SpdySession::GetLoadState() const { 768 LoadState SpdySession::GetLoadState() const {
768 // NOTE: The application only queries the LoadState via the 769 // NOTE: The application only queries the LoadState via the
769 // SpdyNetworkTransaction, and details are only needed when 770 // SpdyNetworkTransaction, and details are only needed when
770 // we're in the process of connecting. 771 // we're in the process of connecting.
771 772
772 // If we're connecting, defer to the connection to give us the actual 773 // If we're connecting, defer to the connection to give us the actual
773 // LoadState. 774 // LoadState.
774 if (state_ == CONNECTING) 775 if (state_ == STATE_CONNECTING)
775 return connection_->GetLoadState(); 776 return connection_->GetLoadState();
776 777
777 // Just report that we're idle since the session could be doing 778 // Just report that we're idle since the session could be doing
778 // many things concurrently. 779 // many things concurrently.
779 return LOAD_STATE_IDLE; 780 return LOAD_STATE_IDLE;
780 } 781 }
781 782
782 void SpdySession::OnReadComplete(int bytes_read) { 783 void SpdySession::OnReadComplete(int bytes_read) {
784 DCHECK_NE(state_, STATE_DO_READ);
785 read_pending_ = false;
786 DoLoop(bytes_read);
787 }
788
789 void SpdySession::StartRead() {
790 DCHECK_NE(state_, STATE_DO_READ_COMPLETE);
791 read_pending_ = false;
792 DoLoop(OK);
793 }
794
795 int SpdySession::DoLoop(int result) {
796 bytes_read_ = 0;
797 do {
798 if (read_pending_)
799 return OK;
800
801 switch (state_) {
802 case STATE_DO_READ:
803 DCHECK_EQ(result, OK);
804 result = DoRead();
805 break;
806 case STATE_DO_READ_COMPLETE:
807 result = DoReadComplete(result);
808 break;
809 case STATE_CLOSED:
810 result = ERR_CONNECTION_CLOSED;
811 break;
812 default:
813 NOTREACHED() << "state_: " << state_;
814 break;
815 }
816 } while (result != ERR_IO_PENDING && result != ERR_CONNECTION_CLOSED);
817
818 return result;
819 }
820
821 int SpdySession::DoRead() {
822 DCHECK(!read_pending_);
823 if (bytes_read_ > kMaxReadBytes) {
824 state_ = STATE_DO_READ;
825 MessageLoop::current()->PostTask(
826 FROM_HERE,
827 base::Bind(&SpdySession::StartRead,
828 weak_factory_.GetWeakPtr()));
829 return ERR_IO_PENDING;
830 }
831
832 CHECK(connection_.get());
833 CHECK(connection_->socket());
834 state_ = STATE_DO_READ_COMPLETE;
835 int result = connection_->socket()->Read(
836 read_buffer_.get(),
837 kReadBufferSize,
838 base::Bind(&SpdySession::OnReadComplete, base::Unretained(this)));
839 if (result == net::ERR_IO_PENDING)
840 read_pending_ = true;
Ryan Sleevi 2013/02/06 23:04:46 Why is this necessary? Returning result here shoul
ramant (doing other things) 2013/02/07 02:11:07 Deleted read_pending_. This variable seems to indi
841 return result;
842 }
843
844 int SpdySession::DoReadComplete(int bytes_read) {
783 // Parse a frame. For now this code requires that the frame fit into our 845 // Parse a frame. For now this code requires that the frame fit into our
784 // buffer (32KB). 846 // buffer (32KB).
785 // TODO(mbelshe): support arbitrarily large frames! 847 // TODO(mbelshe): support arbitrarily large frames!
786 848
787 read_pending_ = false; 849 DCHECK(!read_pending_);
Ryan Sleevi 2013/02/06 23:04:46 This seems wrong - you set read_pending_ to true o
ramant (doing other things) 2013/02/07 02:11:07 SpdySession::OnReadComplete initializes read_pendi
788 850
789 if (bytes_read <= 0) { 851 if (bytes_read <= 0) {
790 // Session is tearing down. 852 // Session is tearing down.
791 net::Error error = static_cast<net::Error>(bytes_read); 853 net::Error error = static_cast<net::Error>(bytes_read);
792 if (bytes_read == 0) 854 if (bytes_read == 0)
793 error = ERR_CONNECTION_CLOSED; 855 error = ERR_CONNECTION_CLOSED;
794 CloseSessionOnError(error, true, "bytes_read is <= 0."); 856 CloseSessionOnError(error, true, "bytes_read is <= 0.");
795 return; 857 return ERR_CONNECTION_CLOSED;
796 } 858 }
797 859
798 bytes_received_ += bytes_read; 860 total_bytes_received_ += bytes_read;
861 bytes_read_ += bytes_read;
Ryan Sleevi 2013/02/06 23:04:46 naming: having bytes_read_ (instance var) and byte
ramant (doing other things) 2013/02/07 02:11:07 Changed "bytes_read" to "result" Done.
799 862
800 last_activity_time_ = base::TimeTicks::Now(); 863 last_activity_time_ = base::TimeTicks::Now();
801 864
802 // The SpdyFramer will use callbacks onto |this| as it parses frames. 865 // The SpdyFramer will use callbacks onto |this| as it parses frames.
803 // When errors occur, those callbacks can lead to teardown of all references 866 // When errors occur, those callbacks can lead to teardown of all references
804 // to |this|, so maintain a reference to self during this call for safe 867 // to |this|, so maintain a reference to self during this call for safe
805 // cleanup. 868 // cleanup.
806 scoped_refptr<SpdySession> self(this); 869 scoped_refptr<SpdySession> self(this);
807 870
808 DCHECK(buffered_spdy_framer_.get()); 871 DCHECK(buffered_spdy_framer_.get());
809 char *data = read_buffer_->data(); 872 char *data = read_buffer_->data();
810 while (bytes_read && 873 while (bytes_read &&
811 buffered_spdy_framer_->error_code() == 874 buffered_spdy_framer_->error_code() ==
812 SpdyFramer::SPDY_NO_ERROR) { 875 SpdyFramer::SPDY_NO_ERROR) {
813 uint32 bytes_processed = 876 uint32 bytes_processed =
814 buffered_spdy_framer_->ProcessInput(data, bytes_read); 877 buffered_spdy_framer_->ProcessInput(data, bytes_read);
815 bytes_read -= bytes_processed; 878 bytes_read -= bytes_processed;
816 data += bytes_processed; 879 data += bytes_processed;
817 if (buffered_spdy_framer_->state() == SpdyFramer::SPDY_DONE) 880 if (buffered_spdy_framer_->state() == SpdyFramer::SPDY_DONE)
818 buffered_spdy_framer_->Reset(); 881 buffered_spdy_framer_->Reset();
819 } 882 }
820 883
821 if (state_ != CLOSED) 884 if (IsConnected())
822 ReadSocket(); 885 state_ = STATE_DO_READ;
886 return OK;
823 } 887 }
824 888
825 void SpdySession::OnWriteComplete(int result) { 889 void SpdySession::OnWriteComplete(int result) {
826 DCHECK(write_pending_); 890 DCHECK(write_pending_);
827 DCHECK(in_flight_write_.size()); 891 DCHECK(in_flight_write_.size());
828 892
829 last_activity_time_ = base::TimeTicks::Now(); 893 last_activity_time_ = base::TimeTicks::Now();
830 write_pending_ = false; 894 write_pending_ = false;
831 895
832 scoped_refptr<SpdyStream> stream = in_flight_write_.stream(); 896 scoped_refptr<SpdyStream> stream = in_flight_write_.stream();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 WriteSocketLater(); 931 WriteSocketLater();
868 } else { 932 } else {
869 in_flight_write_.release(); 933 in_flight_write_.release();
870 934
871 // The stream is now errored. Close it down. 935 // The stream is now errored. Close it down.
872 CloseSessionOnError( 936 CloseSessionOnError(
873 static_cast<net::Error>(result), true, "The stream has errored."); 937 static_cast<net::Error>(result), true, "The stream has errored.");
874 } 938 }
875 } 939 }
876 940
877 net::Error SpdySession::ReadSocket() {
878 if (read_pending_)
879 return OK;
880
881 if (state_ == CLOSED) {
882 NOTREACHED();
883 return ERR_UNEXPECTED;
884 }
885
886 CHECK(connection_.get());
887 CHECK(connection_->socket());
888 int bytes_read = connection_->socket()->Read(
889 read_buffer_.get(),
890 kReadBufferSize,
891 base::Bind(&SpdySession::OnReadComplete, base::Unretained(this)));
892 switch (bytes_read) {
893 case 0:
894 // Socket is closed!
895 CloseSessionOnError(ERR_CONNECTION_CLOSED, true, "bytes_read is 0.");
896 return ERR_CONNECTION_CLOSED;
897 case net::ERR_IO_PENDING:
898 // Waiting for data. Nothing to do now.
899 read_pending_ = true;
900 return ERR_IO_PENDING;
901 default:
902 // Data was read, process it.
903 // Schedule the work through the message loop to avoid recursive
904 // callbacks.
905 read_pending_ = true;
906 MessageLoop::current()->PostTask(
907 FROM_HERE,
908 base::Bind(&SpdySession::OnReadComplete,
909 weak_factory_.GetWeakPtr(), bytes_read));
910 break;
911 }
912 return OK;
913 }
914
915 void SpdySession::WriteSocketLater() { 941 void SpdySession::WriteSocketLater() {
916 if (delayed_write_pending_) 942 if (delayed_write_pending_)
917 return; 943 return;
918 944
919 if (state_ < CONNECTED) 945 if (!IsConnected())
920 return; 946 return;
921 947
922 delayed_write_pending_ = true; 948 delayed_write_pending_ = true;
923 MessageLoop::current()->PostTask( 949 MessageLoop::current()->PostTask(
924 FROM_HERE, 950 FROM_HERE,
925 base::Bind(&SpdySession::WriteSocket, weak_factory_.GetWeakPtr())); 951 base::Bind(&SpdySession::WriteSocket, weak_factory_.GetWeakPtr()));
926 } 952 }
927 953
928 void SpdySession::WriteSocket() { 954 void SpdySession::WriteSocket() {
929 // This function should only be called via WriteSocketLater. 955 // This function should only be called via WriteSocketLater.
930 DCHECK(delayed_write_pending_); 956 DCHECK(delayed_write_pending_);
931 delayed_write_pending_ = false; 957 delayed_write_pending_ = false;
932 958
933 // If the socket isn't connected yet, just wait; we'll get called 959 // If the socket isn't connected yet, just wait; we'll get called
934 // again when the socket connection completes. If the socket is 960 // again when the socket connection completes. If the socket is
935 // closed, just return. 961 // closed, just return.
936 if (state_ < CONNECTED || state_ == CLOSED) 962 if (!IsConnected())
937 return; 963 return;
938 964
939 if (write_pending_) // Another write is in progress still. 965 if (write_pending_) // Another write is in progress still.
940 return; 966 return;
941 967
942 // Loop sending frames until we've sent everything or until the write 968 // Loop sending frames until we've sent everything or until the write
943 // returns error (or ERR_IO_PENDING). 969 // returns error (or ERR_IO_PENDING).
944 DCHECK(buffered_spdy_framer_.get()); 970 DCHECK(buffered_spdy_framer_.get());
945 while (in_flight_write_.buffer() || !write_queue_.empty()) { 971 while (in_flight_write_.buffer() || !write_queue_.empty()) {
946 if (!in_flight_write_.buffer()) { 972 if (!in_flight_write_.buffer()) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 scoped_refptr<SpdySession> self(this); 1075 scoped_refptr<SpdySession> self(this);
1050 1076
1051 DCHECK_LT(err, OK); 1077 DCHECK_LT(err, OK);
1052 net_log_.AddEvent( 1078 net_log_.AddEvent(
1053 NetLog::TYPE_SPDY_SESSION_CLOSE, 1079 NetLog::TYPE_SPDY_SESSION_CLOSE,
1054 base::Bind(&NetLogSpdySessionCloseCallback, err, &description)); 1080 base::Bind(&NetLogSpdySessionCloseCallback, err, &description));
1055 1081
1056 // Don't close twice. This can occur because we can have both 1082 // Don't close twice. This can occur because we can have both
1057 // a read and a write outstanding, and each can complete with 1083 // a read and a write outstanding, and each can complete with
1058 // an error. 1084 // an error.
1059 if (state_ != CLOSED) { 1085 if (!IsClosed()) {
1060 state_ = CLOSED; 1086 state_ = STATE_CLOSED;
1061 error_ = err; 1087 error_ = err;
1062 if (remove_from_pool) 1088 if (remove_from_pool)
1063 RemoveFromPool(); 1089 RemoveFromPool();
1064 CloseAllStreams(err); 1090 CloseAllStreams(err);
1065 } 1091 }
1066 } 1092 }
1067 1093
1068 Value* SpdySession::GetInfoAsValue() const { 1094 Value* SpdySession::GetInfoAsValue() const {
1069 DictionaryValue* dict = new DictionaryValue(); 1095 DictionaryValue* dict = new DictionaryValue();
1070 1096
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 SettingsMap::const_iterator it; 1940 SettingsMap::const_iterator it;
1915 for (it = settings_map.begin(); it != settings_map.end(); ++it) { 1941 for (it = settings_map.begin(); it != settings_map.end(); ++it) {
1916 const SpdySettingsIds id = it->first; 1942 const SpdySettingsIds id = it->first;
1917 const uint32 val = it->second.second; 1943 const uint32 val = it->second.second;
1918 switch (id) { 1944 switch (id) {
1919 case SETTINGS_CURRENT_CWND: 1945 case SETTINGS_CURRENT_CWND:
1920 // Record several different histograms to see if cwnd converges 1946 // Record several different histograms to see if cwnd converges
1921 // for larger volumes of data being sent. 1947 // for larger volumes of data being sent.
1922 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd", 1948 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd",
1923 val, 1, 200, 100); 1949 val, 1, 200, 100);
1924 if (bytes_received_ > 10 * 1024) { 1950 if (total_bytes_received_ > 10 * 1024) {
1925 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd10K", 1951 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd10K",
1926 val, 1, 200, 100); 1952 val, 1, 200, 100);
1927 if (bytes_received_ > 25 * 1024) { 1953 if (total_bytes_received_ > 25 * 1024) {
1928 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd25K", 1954 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd25K",
1929 val, 1, 200, 100); 1955 val, 1, 200, 100);
1930 if (bytes_received_ > 50 * 1024) { 1956 if (total_bytes_received_ > 50 * 1024) {
1931 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd50K", 1957 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd50K",
1932 val, 1, 200, 100); 1958 val, 1, 200, 100);
1933 if (bytes_received_ > 100 * 1024) { 1959 if (total_bytes_received_ > 100 * 1024) {
1934 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd100K", 1960 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd100K",
1935 val, 1, 200, 100); 1961 val, 1, 200, 100);
1936 } 1962 }
1937 } 1963 }
1938 } 1964 }
1939 } 1965 }
1940 break; 1966 break;
1941 case SETTINGS_ROUND_TRIP_TIME: 1967 case SETTINGS_ROUND_TRIP_TIME:
1942 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsRTT", 1968 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsRTT",
1943 val, 1, 1200, 100); 1969 val, 1, 1200, 100);
(...skipping 26 matching lines...) Expand all
1970 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 1996 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
1971 if (!is_secure_) 1997 if (!is_secure_)
1972 return NULL; 1998 return NULL;
1973 SSLClientSocket* ssl_socket = 1999 SSLClientSocket* ssl_socket =
1974 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 2000 reinterpret_cast<SSLClientSocket*>(connection_->socket());
1975 DCHECK(ssl_socket); 2001 DCHECK(ssl_socket);
1976 return ssl_socket; 2002 return ssl_socket;
1977 } 2003 }
1978 2004
1979 } // namespace net 2005 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698