| OLD | NEW |
| 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 Loading... |
| 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 |
| 1810 // |unacked_recv_window_bytes_| is updated properly even when the |
| 1811 // stream is inactive (since the other side has still decreased its |
| 1812 // session send window). |
| 1813 scoped_ptr<SpdyBuffer> buffer; |
| 1814 if (data) { |
| 1815 DCHECK_GT(len, 0u); |
| 1816 buffer.reset(new SpdyBuffer(data, len)); |
| 1817 |
| 1818 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) { |
| 1819 DecreaseRecvWindowSize(static_cast<int32>(len)); |
| 1820 buffer->AddConsumeCallback( |
| 1821 base::Bind(&SpdySession::OnReadBufferConsumed, |
| 1822 weak_factory_.GetWeakPtr())); |
| 1823 } |
| 1824 } else { |
| 1825 DCHECK_EQ(len, 0u); |
| 1826 } |
| 1827 |
| 1809 ActiveStreamMap::iterator it = active_streams_.find(stream_id); | 1828 ActiveStreamMap::iterator it = active_streams_.find(stream_id); |
| 1810 | 1829 |
| 1811 // By the time data comes in, the stream may already be inactive. | 1830 // By the time data comes in, the stream may already be inactive. |
| 1812 if (it == active_streams_.end()) | 1831 if (it == active_streams_.end()) |
| 1813 return; | 1832 return; |
| 1814 | 1833 |
| 1815 SpdyStream* stream = it->second.stream; | 1834 SpdyStream* stream = it->second.stream; |
| 1816 CHECK_EQ(stream->stream_id(), stream_id); | 1835 CHECK_EQ(stream->stream_id(), stream_id); |
| 1817 | 1836 |
| 1818 if (it->second.waiting_for_syn_reply) { | 1837 if (it->second.waiting_for_syn_reply) { |
| 1819 const std::string& error = "Data received before SYN_REPLY."; | 1838 const std::string& error = "Data received before SYN_REPLY."; |
| 1820 stream->LogStreamError(ERR_SPDY_PROTOCOL_ERROR, error); | 1839 stream->LogStreamError(ERR_SPDY_PROTOCOL_ERROR, error); |
| 1821 ResetStreamIterator(it, RST_STREAM_PROTOCOL_ERROR, error); | 1840 ResetStreamIterator(it, RST_STREAM_PROTOCOL_ERROR, error); |
| 1822 return; | 1841 return; |
| 1823 } | 1842 } |
| 1824 | 1843 |
| 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()); | 1844 stream->OnDataReceived(buffer.Pass()); |
| 1840 } | 1845 } |
| 1841 | 1846 |
| 1842 void SpdySession::OnSettings(bool clear_persisted) { | 1847 void SpdySession::OnSettings(bool clear_persisted) { |
| 1843 CHECK(in_io_loop_); | 1848 CHECK(in_io_loop_); |
| 1844 | 1849 |
| 1845 if (availability_state_ == STATE_CLOSED) | 1850 if (availability_state_ == STATE_CLOSED) |
| 1846 return; | 1851 return; |
| 1847 | 1852 |
| 1848 if (clear_persisted) | 1853 if (clear_persisted) |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2902 if (!queue->empty()) { | 2907 if (!queue->empty()) { |
| 2903 SpdyStreamId stream_id = queue->front(); | 2908 SpdyStreamId stream_id = queue->front(); |
| 2904 queue->pop_front(); | 2909 queue->pop_front(); |
| 2905 return stream_id; | 2910 return stream_id; |
| 2906 } | 2911 } |
| 2907 } | 2912 } |
| 2908 return 0; | 2913 return 0; |
| 2909 } | 2914 } |
| 2910 | 2915 |
| 2911 } // namespace net | 2916 } // namespace net |
| OLD | NEW |