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

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

Issue 12208103: Revert 181569 (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
« no previous file with comments | « net/spdy/spdy_session.h ('k') | no next file » | 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/bind.h" 10 #include "base/bind.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 size_t max_concurrent_streams_limit, 226 size_t max_concurrent_streams_limit,
227 TimeFunc time_func, 227 TimeFunc time_func,
228 const HostPortPair& trusted_spdy_proxy, 228 const HostPortPair& trusted_spdy_proxy,
229 NetLog* net_log) 229 NetLog* net_log)
230 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 230 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
231 host_port_proxy_pair_(host_port_proxy_pair), 231 host_port_proxy_pair_(host_port_proxy_pair),
232 spdy_session_pool_(spdy_session_pool), 232 spdy_session_pool_(spdy_session_pool),
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),
237 stream_hi_water_mark_(kFirstStreamId), 236 stream_hi_water_mark_(kFirstStreamId),
238 write_pending_(false), 237 write_pending_(false),
239 delayed_write_pending_(false), 238 delayed_write_pending_(false),
240 is_secure_(false), 239 is_secure_(false),
241 certificate_error_code_(OK), 240 certificate_error_code_(OK),
242 error_(OK), 241 error_(OK),
243 state_(STATE_IDLE), 242 state_(STATE_IDLE),
244 max_concurrent_streams_(initial_max_concurrent_streams == 0 ? 243 max_concurrent_streams_(initial_max_concurrent_streams == 0 ?
245 kInitialMaxConcurrentStreams : 244 kInitialMaxConcurrentStreams :
246 initial_max_concurrent_streams), 245 initial_max_concurrent_streams),
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 if (state_ == STATE_CONNECTING) 774 if (state_ == STATE_CONNECTING)
776 return connection_->GetLoadState(); 775 return connection_->GetLoadState();
777 776
778 // Just report that we're idle since the session could be doing 777 // Just report that we're idle since the session could be doing
779 // many things concurrently. 778 // many things concurrently.
780 return LOAD_STATE_IDLE; 779 return LOAD_STATE_IDLE;
781 } 780 }
782 781
783 void SpdySession::OnReadComplete(int bytes_read) { 782 void SpdySession::OnReadComplete(int bytes_read) {
784 DCHECK_NE(state_, STATE_DO_READ); 783 DCHECK_NE(state_, STATE_DO_READ);
785 read_pending_ = false;
786 DoLoop(bytes_read); 784 DoLoop(bytes_read);
787 } 785 }
788 786
789 void SpdySession::StartRead() { 787 void SpdySession::StartRead() {
790 DCHECK_NE(state_, STATE_DO_READ_COMPLETE); 788 DCHECK_NE(state_, STATE_DO_READ_COMPLETE);
791 read_pending_ = false;
792 DoLoop(OK); 789 DoLoop(OK);
793 } 790 }
794 791
795 int SpdySession::DoLoop(int result) { 792 int SpdySession::DoLoop(int result) {
796 bytes_read_ = 0; 793 bytes_read_ = 0;
797 do { 794 do {
798 if (read_pending_)
799 return OK;
800
801 switch (state_) { 795 switch (state_) {
802 case STATE_DO_READ: 796 case STATE_DO_READ:
803 DCHECK_EQ(result, OK); 797 DCHECK_EQ(result, OK);
804 result = DoRead(); 798 result = DoRead();
805 break; 799 break;
806 case STATE_DO_READ_COMPLETE: 800 case STATE_DO_READ_COMPLETE:
807 result = DoReadComplete(result); 801 result = DoReadComplete(result);
808 break; 802 break;
809 case STATE_CLOSED: 803 case STATE_CLOSED:
810 result = ERR_CONNECTION_CLOSED; 804 result = ERR_CONNECTION_CLOSED;
811 break; 805 break;
812 default: 806 default:
813 NOTREACHED() << "state_: " << state_; 807 NOTREACHED() << "state_: " << state_;
814 break; 808 break;
815 } 809 }
816 } while (result != ERR_IO_PENDING && result != ERR_CONNECTION_CLOSED); 810 } while (result != ERR_IO_PENDING && result != ERR_CONNECTION_CLOSED);
817 811
818 return result; 812 return result;
819 } 813 }
820 814
821 int SpdySession::DoRead() { 815 int SpdySession::DoRead() {
822 DCHECK(!read_pending_);
823 if (bytes_read_ > kMaxReadBytes) { 816 if (bytes_read_ > kMaxReadBytes) {
824 state_ = STATE_DO_READ; 817 state_ = STATE_DO_READ;
825 MessageLoop::current()->PostTask( 818 MessageLoop::current()->PostTask(
826 FROM_HERE, 819 FROM_HERE,
827 base::Bind(&SpdySession::StartRead, 820 base::Bind(&SpdySession::StartRead,
828 weak_factory_.GetWeakPtr())); 821 weak_factory_.GetWeakPtr()));
829 return ERR_IO_PENDING; 822 return ERR_IO_PENDING;
830 } 823 }
831 824
832 CHECK(connection_.get()); 825 CHECK(connection_.get());
833 CHECK(connection_->socket()); 826 CHECK(connection_->socket());
834 state_ = STATE_DO_READ_COMPLETE; 827 state_ = STATE_DO_READ_COMPLETE;
835 int result = connection_->socket()->Read( 828 return connection_->socket()->Read(
836 read_buffer_.get(), 829 read_buffer_.get(),
837 kReadBufferSize, 830 kReadBufferSize,
838 base::Bind(&SpdySession::OnReadComplete, base::Unretained(this))); 831 base::Bind(&SpdySession::OnReadComplete, base::Unretained(this)));
839 if (result == net::ERR_IO_PENDING)
840 read_pending_ = true;
841 return result;
842 } 832 }
843 833
844 int SpdySession::DoReadComplete(int result) { 834 int SpdySession::DoReadComplete(int result) {
845 // Parse a frame. For now this code requires that the frame fit into our 835 // Parse a frame. For now this code requires that the frame fit into our
846 // buffer (32KB). 836 // buffer (32KB).
847 // TODO(mbelshe): support arbitrarily large frames! 837 // TODO(mbelshe): support arbitrarily large frames!
848 838
849 DCHECK(!read_pending_);
850
851 if (result <= 0) { 839 if (result <= 0) {
852 // Session is tearing down. 840 // Session is tearing down.
853 net::Error error = static_cast<net::Error>(result); 841 net::Error error = static_cast<net::Error>(result);
854 if (result == 0) 842 if (result == 0)
855 error = ERR_CONNECTION_CLOSED; 843 error = ERR_CONNECTION_CLOSED;
856 CloseSessionOnError(error, true, "result is <= 0."); 844 CloseSessionOnError(error, true, "result is <= 0.");
857 return ERR_CONNECTION_CLOSED; 845 return ERR_CONNECTION_CLOSED;
858 } 846 }
859 847
860 total_bytes_received_ += result; 848 total_bytes_received_ += result;
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 1985 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
1998 if (!is_secure_) 1986 if (!is_secure_)
1999 return NULL; 1987 return NULL;
2000 SSLClientSocket* ssl_socket = 1988 SSLClientSocket* ssl_socket =
2001 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 1989 reinterpret_cast<SSLClientSocket*>(connection_->socket());
2002 DCHECK(ssl_socket); 1990 DCHECK(ssl_socket);
2003 return ssl_socket; 1991 return ssl_socket;
2004 } 1992 }
2005 1993
2006 } // namespace net 1994 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698