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

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

Issue 2539563002: Minor cleanup in SpdySession. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 1996 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 stream->OnDataReceived(std::move(buffer)); 2007 stream->OnDataReceived(std::move(buffer));
2008 } 2008 }
2009 2009
2010 void SpdySession::OnStreamEnd(SpdyStreamId stream_id) { 2010 void SpdySession::OnStreamEnd(SpdyStreamId stream_id) {
2011 CHECK(in_io_loop_); 2011 CHECK(in_io_loop_);
2012 if (net_log().IsCapturing()) { 2012 if (net_log().IsCapturing()) {
2013 net_log().AddEvent(NetLogEventType::HTTP2_SESSION_RECV_DATA, 2013 net_log().AddEvent(NetLogEventType::HTTP2_SESSION_RECV_DATA,
2014 base::Bind(&NetLogSpdyDataCallback, stream_id, 0, true)); 2014 base::Bind(&NetLogSpdyDataCallback, stream_id, 0, true));
2015 } 2015 }
2016 2016
2017 // Build the buffer as early as possible so that we go through the
2018 // session flow control checks and update
2019 // |unacked_recv_window_bytes_| properly even when the stream is
2020 // inactive (since the other side has still reduced its session send
2021 // window).
2022 std::unique_ptr<SpdyBuffer> buffer;
2023
2024 ActiveStreamMap::iterator it = active_streams_.find(stream_id); 2017 ActiveStreamMap::iterator it = active_streams_.find(stream_id);
2025
2026 // By the time data comes in, the stream may already be inactive. 2018 // By the time data comes in, the stream may already be inactive.
2027 if (it == active_streams_.end()) 2019 if (it == active_streams_.end())
2028 return; 2020 return;
2029 2021
2030 SpdyStream* stream = it->second; 2022 SpdyStream* stream = it->second;
2031 CHECK_EQ(stream->stream_id(), stream_id); 2023 CHECK_EQ(stream->stream_id(), stream_id);
2032 2024
2033 stream->OnDataReceived(std::move(buffer)); 2025 stream->OnDataReceived(std::unique_ptr<SpdyBuffer>());
2034 } 2026 }
2035 2027
2036 void SpdySession::OnStreamPadding(SpdyStreamId stream_id, size_t len) { 2028 void SpdySession::OnStreamPadding(SpdyStreamId stream_id, size_t len) {
2037 CHECK(in_io_loop_); 2029 CHECK(in_io_loop_);
2038 2030
2039 // Decrease window size because padding bytes are received. 2031 // Decrease window size because padding bytes are received.
2040 // Increase window size because padding bytes are consumed (by discarding). 2032 // Increase window size because padding bytes are consumed (by discarding).
2041 // Net result: |session_unacked_recv_window_bytes_| increases by |len|, 2033 // Net result: |session_unacked_recv_window_bytes_| increases by |len|,
2042 // |session_recv_window_size_| does not change. 2034 // |session_recv_window_size_| does not change.
2043 DecreaseRecvWindowSize(static_cast<int32_t>(len)); 2035 DecreaseRecvWindowSize(static_cast<int32_t>(len));
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2545 "Received duplicate pushed stream with url: " + gurl.spec()); 2537 "Received duplicate pushed stream with url: " + gurl.spec());
2546 return; 2538 return;
2547 } 2539 }
2548 2540
2549 std::unique_ptr<SpdyStream> stream( 2541 std::unique_ptr<SpdyStream> stream(
2550 new SpdyStream(SPDY_PUSH_STREAM, GetWeakPtr(), gurl, request_priority, 2542 new SpdyStream(SPDY_PUSH_STREAM, GetWeakPtr(), gurl, request_priority,
2551 stream_initial_send_window_size_, 2543 stream_initial_send_window_size_,
2552 stream_max_recv_window_size_, net_log_)); 2544 stream_max_recv_window_size_, net_log_));
2553 stream->set_stream_id(stream_id); 2545 stream->set_stream_id(stream_id);
2554 2546
2555 // In HTTP2 PUSH_PROMISE arrives on associated stream. 2547 // PUSH_PROMISE arrives on associated stream.
2556 if (associated_it != active_streams_.end()) { 2548 associated_it->second.stream->AddRawReceivedBytes(last_compressed_frame_len_);
2557 associated_it->second->AddRawReceivedBytes(last_compressed_frame_len_);
2558 } else {
2559 stream->AddRawReceivedBytes(last_compressed_frame_len_);
Bence 2016/11/29 00:28:44 Return around line 2479 makes this branch dead.
2560 }
2561
2562 last_compressed_frame_len_ = 0; 2549 last_compressed_frame_len_ = 0;
2563 2550
2564 UnclaimedPushedStreamContainer::const_iterator inserted_pushed_it = 2551 UnclaimedPushedStreamContainer::const_iterator inserted_pushed_it =
2565 unclaimed_pushed_streams_.insert(pushed_it, gurl, stream_id, 2552 unclaimed_pushed_streams_.insert(pushed_it, gurl, stream_id,
2566 time_func_()); 2553 time_func_());
2567 DCHECK(inserted_pushed_it != pushed_it); 2554 DCHECK(inserted_pushed_it != pushed_it);
2568 DeleteExpiredPushedStreams(); 2555 DeleteExpiredPushedStreams();
2569 2556
2570 InsertActivatedStream(std::move(stream)); 2557 InsertActivatedStream(std::move(stream));
2571 2558
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
3007 if (!queue->empty()) { 2994 if (!queue->empty()) {
3008 SpdyStreamId stream_id = queue->front(); 2995 SpdyStreamId stream_id = queue->front();
3009 queue->pop_front(); 2996 queue->pop_front();
3010 return stream_id; 2997 return stream_id;
3011 } 2998 }
3012 } 2999 }
3013 return 0; 3000 return 0;
3014 } 3001 }
3015 3002
3016 } // namespace net 3003 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698