summaryrefslogtreecommitdiffstats
path: root/net/spdy
diff options
context:
space:
mode:
authorrtenneti@google.com <rtenneti@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-10 04:52:10 +0000
committerrtenneti@google.com <rtenneti@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-10 04:52:10 +0000
commit42baef7a5c2658d767cc15db5834e1f4b7bd4746 (patch)
treeacc5161c111cbf1db516538acfc660dd1caa32e2 /net/spdy
parent83260e00ec89e0a98492a1d3f5aad64684c3316d (diff)
downloadchromium_src-42baef7a5c2658d767cc15db5834e1f4b7bd4746.zip
chromium_src-42baef7a5c2658d767cc15db5834e1f4b7bd4746.tar.gz
chromium_src-42baef7a5c2658d767cc15db5834e1f4b7bd4746.tar.bz2
SPDY - add support for spdy/2.1 to support flow control.
1) Add spdy/2.1 as a supported NPN protocol. 2) Advertise that chrome supports spdy/2.1 when --flow-control (spdy flag) is enabled. 3) When SPDY protocol is negotiated, enable flow_control in spdy_session if spdy/2.1 is negotiated as NPN protocol. BUG=106911 R=willchan TEST=network unit tests and if possible test with SPDY 2.1 server with command line flag --flow-control. This CL is same as the following CL. Implemented changes suggested by willchan in the following review. http://codereview.chromium.org/8890044/ Review URL: http://codereview.chromium.org/8892026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy')
-rw-r--r--net/spdy/spdy_http_stream.cc2
-rw-r--r--net/spdy/spdy_network_transaction_unittest.cc17
-rw-r--r--net/spdy/spdy_session.cc13
-rw-r--r--net/spdy/spdy_session.h14
-rw-r--r--net/spdy/spdy_stream.cc2
5 files changed, 33 insertions, 15 deletions
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc
index 175f827..8445898 100644
--- a/net/spdy/spdy_http_stream.cc
+++ b/net/spdy/spdy_http_stream.cc
@@ -128,7 +128,7 @@ int SpdyHttpStream::ReadResponseBody(
}
bytes_read += bytes_to_copy;
}
- if (SpdySession::flow_control())
+ if (spdy_session_ && spdy_session_->is_flow_control_enabled())
stream_->IncreaseRecvWindowSize(bytes_read);
return bytes_read;
} else if (stream_->closed()) {
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index d0f0d2b..901c1eb 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -122,6 +122,7 @@ class SpdyNetworkTransactionTest
std::vector<std::string> next_protos;
next_protos.push_back("http/1.1");
next_protos.push_back("spdy/2");
+ next_protos.push_back("spdy/2.1");
switch (test_type_) {
case SPDYNPN:
@@ -1851,7 +1852,7 @@ TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) {
// limitations as described above and it's not deterministic, tests may
// fail under specific circumstances.
TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) {
- SpdySession::set_flow_control(true);
+ SpdySession::set_use_flow_control(true);
static int kFrameCount = 2;
scoped_ptr<std::string> content(
@@ -1922,13 +1923,13 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) {
kMaxSpdyFrameChunkSize * kFrameCount,
stream->stream()->send_window_size());
helper.VerifyDataConsumed();
- SpdySession::set_flow_control(false);
+ SpdySession::set_use_flow_control(false);
}
// Test that received data frames and sent WINDOW_UPDATE frames change
// the recv_window_size_ correctly.
TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) {
- SpdySession::set_flow_control(true);
+ SpdySession::set_use_flow_control(true);
scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
scoped_ptr<spdy::SpdyFrame> window_update(
@@ -2005,13 +2006,13 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) {
data->CompleteRead();
helper.VerifyDataConsumed();
- SpdySession::set_flow_control(false);
+ SpdySession::set_use_flow_control(false);
}
// Test that WINDOW_UPDATE frame causing overflow is handled correctly. We
// use the same trick as in the above test to enforce our scenario.
TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) {
- SpdySession::set_flow_control(true);
+ SpdySession::set_use_flow_control(true);
// number of full frames we hope to write (but will not, used to
// set content-length header correctly)
@@ -2084,7 +2085,7 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) {
helper.session()->spdy_session_pool()->CloseAllSessions();
helper.VerifyDataConsumed();
- SpdySession::set_flow_control(false);
+ SpdySession::set_use_flow_control(false);
}
// Test that after hitting a send window size of 0, the write process
@@ -2103,7 +2104,7 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) {
// After that, next read is artifically enforced, which causes a
// WINDOW_UPDATE to be read and I/O process resumes.
TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) {
- SpdySession::set_flow_control(true);
+ SpdySession::set_use_flow_control(true);
// Number of frames we need to send to zero out the window size: data
// frames plus SYN_STREAM plus the last data frame; also we need another
@@ -2194,7 +2195,7 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) {
rv = callback.WaitForResult();
helper.VerifyDataConsumed();
- SpdySession::set_flow_control(false);
+ SpdySession::set_use_flow_control(false);
}
TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) {
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 17c18eb..1b0d591 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -282,6 +282,7 @@ SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair,
trailing_ping_pending_(false),
check_ping_status_pending_(false),
need_to_send_ping_(false),
+ flow_control_(use_flow_control_),
initial_send_window_size_(spdy::kSpdyStreamInitialWindowSize),
initial_recv_window_size_(spdy::kSpdyStreamInitialWindowSize),
net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)),
@@ -336,6 +337,14 @@ net::Error SpdySession::InitializeWithSocket(
is_secure_ = is_secure;
certificate_error_code_ = certificate_error_code;
+ if (is_secure_) {
+ SSLClientSocket* ssl_socket =
+ reinterpret_cast<SSLClientSocket*>(connection_->socket());
+ DCHECK(ssl_socket);
+ if (ssl_socket->next_protocol_negotiated() == SSLClientSocket::kProtoSPDY21)
+ flow_control_ = true;
+ }
+
// Write out any data that we might have to send, such as the settings frame.
WriteSocketLater();
net::Error error = ReadSocket();
@@ -557,7 +566,7 @@ int SpdySession::WriteStreamData(spdy::SpdyStreamId stream_id,
}
// Obey send window size of the stream if flow control is enabled.
- if (use_flow_control_) {
+ if (flow_control_) {
if (stream->send_window_size() <= 0) {
// Because we queue frames onto the session, it is possible that
// a stream was not flow controlled at the time it attempted the
@@ -1463,7 +1472,7 @@ void SpdySession::OnWindowUpdate(
CHECK_EQ(stream->stream_id(), stream_id);
CHECK(!stream->cancelled());
- if (use_flow_control_)
+ if (flow_control_)
stream->IncreaseSendWindowSize(delta_window_size);
net_log_.AddEvent(
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index a05bd3c..3da2f1e 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -149,9 +149,9 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
static void SetSSLMode(bool enable) { use_ssl_ = enable; }
static bool SSLMode() { return use_ssl_; }
- // Enable or disable flow control.
- static void set_flow_control(bool enable) { use_flow_control_ = enable; }
- static bool flow_control() { return use_flow_control_; }
+ // Enable or disable flow control used by unit tests. This only applies for
+ // new SpdySessions.
+ static void set_use_flow_control(bool enable) { use_flow_control_ = enable; }
// Sets the max concurrent streams per session, as a ceiling on any server
// specific SETTINGS value.
@@ -224,6 +224,11 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
return unclaimed_pushed_streams_.size();
}
+ // Returns true if flow control is enabled for the session.
+ bool is_flow_control_enabled() const {
+ return flow_control_;
+ }
+
const BoundNetLog& net_log() const { return net_log_; }
int GetPeerAddress(AddressList* address) const;
@@ -540,6 +545,9 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
// waste of effort (and MUST not be done).
bool need_to_send_ping_;
+ // Indicate if flow control is enabled or not.
+ bool flow_control_;
+
// Initial send window size for the session; can be changed by an
// arriving SETTINGS frame; newly created streams use this value for the
// initial send window size.
diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc
index 00e66e4..088d89fa 100644
--- a/net/spdy/spdy_stream.cc
+++ b/net/spdy/spdy_stream.cc
@@ -325,7 +325,7 @@ void SpdyStream::OnDataReceived(const char* data, int length) {
return;
}
- if (session_->flow_control())
+ if (session_->is_flow_control_enabled())
DecreaseRecvWindowSize(length);
// Track our bandwidth.