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

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

Issue 22610006: [SPDY] Count closed-stream DATA frames for session flow control (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweak comments Created 7 years, 4 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 | « no previous file | net/spdy/spdy_session_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 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 if (availability_state_ == STATE_CLOSED) 1799 if (availability_state_ == STATE_CLOSED)
1800 return; 1800 return;
1801 1801
1802 DCHECK_LT(len, 1u << 24); 1802 DCHECK_LT(len, 1u << 24);
1803 if (net_log().IsLoggingAllEvents()) { 1803 if (net_log().IsLoggingAllEvents()) {
1804 net_log().AddEvent( 1804 net_log().AddEvent(
1805 NetLog::TYPE_SPDY_SESSION_RECV_DATA, 1805 NetLog::TYPE_SPDY_SESSION_RECV_DATA,
1806 base::Bind(&NetLogSpdyDataCallback, stream_id, len, fin)); 1806 base::Bind(&NetLogSpdyDataCallback, stream_id, len, fin));
1807 } 1807 }
1808 1808
1809 // Build the buffer as early as possible so that we go through the
1810 // session flow control checks and update
1811 // |unacked_recv_window_bytes_| properly even when the stream is
1812 // inactive (since the other side has still reduced its session send
1813 // window).
1814 scoped_ptr<SpdyBuffer> buffer;
1815 if (data) {
1816 DCHECK_GT(len, 0u);
1817 buffer.reset(new SpdyBuffer(data, len));
1818
1819 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) {
1820 DecreaseRecvWindowSize(static_cast<int32>(len));
1821 buffer->AddConsumeCallback(
1822 base::Bind(&SpdySession::OnReadBufferConsumed,
1823 weak_factory_.GetWeakPtr()));
1824 }
1825 } else {
1826 DCHECK_EQ(len, 0u);
1827 }
1828
1809 ActiveStreamMap::iterator it = active_streams_.find(stream_id); 1829 ActiveStreamMap::iterator it = active_streams_.find(stream_id);
1810 1830
1811 // By the time data comes in, the stream may already be inactive. 1831 // By the time data comes in, the stream may already be inactive.
1812 if (it == active_streams_.end()) 1832 if (it == active_streams_.end())
1813 return; 1833 return;
1814 1834
1815 SpdyStream* stream = it->second.stream; 1835 SpdyStream* stream = it->second.stream;
1816 CHECK_EQ(stream->stream_id(), stream_id); 1836 CHECK_EQ(stream->stream_id(), stream_id);
1817 1837
1818 if (it->second.waiting_for_syn_reply) { 1838 if (it->second.waiting_for_syn_reply) {
1819 const std::string& error = "Data received before SYN_REPLY."; 1839 const std::string& error = "Data received before SYN_REPLY.";
1820 stream->LogStreamError(ERR_SPDY_PROTOCOL_ERROR, error); 1840 stream->LogStreamError(ERR_SPDY_PROTOCOL_ERROR, error);
1821 ResetStreamIterator(it, RST_STREAM_PROTOCOL_ERROR, error); 1841 ResetStreamIterator(it, RST_STREAM_PROTOCOL_ERROR, error);
1822 return; 1842 return;
1823 } 1843 }
1824 1844
1825 scoped_ptr<SpdyBuffer> buffer;
1826 if (data) {
1827 DCHECK_GT(len, 0u);
1828 buffer.reset(new SpdyBuffer(data, len));
1829
1830 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) {
1831 DecreaseRecvWindowSize(static_cast<int32>(len));
1832 buffer->AddConsumeCallback(
1833 base::Bind(&SpdySession::OnReadBufferConsumed,
1834 weak_factory_.GetWeakPtr()));
1835 }
1836 } else {
1837 DCHECK_EQ(len, 0u);
1838 }
1839 stream->OnDataReceived(buffer.Pass()); 1845 stream->OnDataReceived(buffer.Pass());
1840 } 1846 }
1841 1847
1842 void SpdySession::OnSettings(bool clear_persisted) { 1848 void SpdySession::OnSettings(bool clear_persisted) {
1843 CHECK(in_io_loop_); 1849 CHECK(in_io_loop_);
1844 1850
1845 if (availability_state_ == STATE_CLOSED) 1851 if (availability_state_ == STATE_CLOSED)
1846 return; 1852 return;
1847 1853
1848 if (clear_persisted) 1854 if (clear_persisted)
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
2902 if (!queue->empty()) { 2908 if (!queue->empty()) {
2903 SpdyStreamId stream_id = queue->front(); 2909 SpdyStreamId stream_id = queue->front();
2904 queue->pop_front(); 2910 queue->pop_front();
2905 return stream_id; 2911 return stream_id;
2906 } 2912 }
2907 } 2913 }
2908 return 0; 2914 return 0;
2909 } 2915 }
2910 2916
2911 } // namespace net 2917 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698