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

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

Issue 2174943002: Avoid SpdyHeaderBlock copy in SpdyStream::OnPushPromiseHeadersReceived(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_stream.h » ('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 <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 next_unclaimed_push_stream_sweep_time_ = time_func_() + 2229 next_unclaimed_push_stream_sweep_time_ = time_func_() +
2230 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); 2230 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds);
2231 } 2231 }
2232 2232
2233 void SpdySession::OnHeaders(SpdyStreamId stream_id, 2233 void SpdySession::OnHeaders(SpdyStreamId stream_id,
2234 bool has_priority, 2234 bool has_priority,
2235 int weight, 2235 int weight,
2236 SpdyStreamId parent_stream_id, 2236 SpdyStreamId parent_stream_id,
2237 bool exclusive, 2237 bool exclusive,
2238 bool fin, 2238 bool fin,
2239 const SpdyHeaderBlock& headers) { 2239 SpdyHeaderBlock headers) {
2240 CHECK(in_io_loop_); 2240 CHECK(in_io_loop_);
2241 2241
2242 if (net_log().IsCapturing()) { 2242 if (net_log().IsCapturing()) {
2243 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_HEADERS, 2243 net_log().AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_HEADERS,
2244 base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback, 2244 base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback,
2245 &headers, fin, stream_id)); 2245 &headers, fin, stream_id));
2246 } 2246 }
2247 2247
2248 ActiveStreamMap::iterator it = active_streams_.find(stream_id); 2248 ActiveStreamMap::iterator it = active_streams_.find(stream_id);
2249 if (it == active_streams_.end()) { 2249 if (it == active_streams_.end()) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 } 2483 }
2484 2484
2485 CHECK_EQ(it->second.stream->stream_id(), stream_id); 2485 CHECK_EQ(it->second.stream->stream_id(), stream_id);
2486 it->second.stream->IncreaseSendWindowSize(delta_window_size); 2486 it->second.stream->IncreaseSendWindowSize(delta_window_size);
2487 } 2487 }
2488 } 2488 }
2489 2489
2490 bool SpdySession::TryCreatePushStream(SpdyStreamId stream_id, 2490 bool SpdySession::TryCreatePushStream(SpdyStreamId stream_id,
2491 SpdyStreamId associated_stream_id, 2491 SpdyStreamId associated_stream_id,
2492 SpdyPriority priority, 2492 SpdyPriority priority,
2493 const SpdyHeaderBlock& headers) { 2493 SpdyHeaderBlock headers) {
2494 // Server-initiated streams should have even sequence numbers. 2494 // Server-initiated streams should have even sequence numbers.
2495 if ((stream_id & 0x1) != 0) { 2495 if ((stream_id & 0x1) != 0) {
2496 LOG(WARNING) << "Received invalid push stream id " << stream_id; 2496 LOG(WARNING) << "Received invalid push stream id " << stream_id;
2497 CloseSessionOnError(ERR_SPDY_PROTOCOL_ERROR, "Odd push stream id."); 2497 CloseSessionOnError(ERR_SPDY_PROTOCOL_ERROR, "Odd push stream id.");
2498 return false; 2498 return false;
2499 } 2499 }
2500 2500
2501 // Server-initiated streams must be associated with client-initiated streams. 2501 // Server-initiated streams must be associated with client-initiated streams.
2502 if ((associated_stream_id & 0x1) != 1) { 2502 if ((associated_stream_id & 0x1) != 1) {
2503 LOG(WARNING) << "Received invalid associated stream id " << stream_id; 2503 LOG(WARNING) << "Received invalid associated stream id " << stream_id;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 DeleteExpiredPushedStreams(); 2658 DeleteExpiredPushedStreams();
2659 2659
2660 InsertActivatedStream(std::move(stream)); 2660 InsertActivatedStream(std::move(stream));
2661 2661
2662 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); 2662 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id);
2663 if (active_it == active_streams_.end()) { 2663 if (active_it == active_streams_.end()) {
2664 NOTREACHED(); 2664 NOTREACHED();
2665 return false; 2665 return false;
2666 } 2666 }
2667 2667
2668 active_it->second.stream->OnPushPromiseHeadersReceived(headers); 2668 active_it->second.stream->OnPushPromiseHeadersReceived(std::move(headers));
2669 DCHECK(active_it->second.stream->IsReservedRemote()); 2669 DCHECK(active_it->second.stream->IsReservedRemote());
2670 num_pushed_streams_++; 2670 num_pushed_streams_++;
2671 return true; 2671 return true;
2672 } 2672 }
2673 2673
2674 void SpdySession::OnPushPromise(SpdyStreamId stream_id, 2674 void SpdySession::OnPushPromise(SpdyStreamId stream_id,
2675 SpdyStreamId promised_stream_id, 2675 SpdyStreamId promised_stream_id,
2676 const SpdyHeaderBlock& headers) { 2676 SpdyHeaderBlock headers) {
2677 CHECK(in_io_loop_); 2677 CHECK(in_io_loop_);
2678 2678
2679 if (net_log_.IsCapturing()) { 2679 if (net_log_.IsCapturing()) {
2680 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_PUSH_PROMISE, 2680 net_log_.AddEvent(NetLog::TYPE_HTTP2_SESSION_RECV_PUSH_PROMISE,
2681 base::Bind(&NetLogSpdyPushPromiseReceivedCallback, 2681 base::Bind(&NetLogSpdyPushPromiseReceivedCallback,
2682 &headers, stream_id, promised_stream_id)); 2682 &headers, stream_id, promised_stream_id));
2683 } 2683 }
2684 2684
2685 // Any priority will do. 2685 // Any priority will do.
2686 // TODO(baranovich): pass parent stream id priority? 2686 // TODO(baranovich): pass parent stream id priority?
2687 if (!TryCreatePushStream(promised_stream_id, stream_id, 0, headers)) 2687 if (!TryCreatePushStream(promised_stream_id, stream_id, 0,
2688 std::move(headers)))
2688 return; 2689 return;
2689 } 2690 }
2690 2691
2691 void SpdySession::SendStreamWindowUpdate(SpdyStreamId stream_id, 2692 void SpdySession::SendStreamWindowUpdate(SpdyStreamId stream_id,
2692 uint32_t delta_window_size) { 2693 uint32_t delta_window_size) {
2693 ActiveStreamMap::const_iterator it = active_streams_.find(stream_id); 2694 ActiveStreamMap::const_iterator it = active_streams_.find(stream_id);
2694 CHECK(it != active_streams_.end()); 2695 CHECK(it != active_streams_.end());
2695 CHECK_EQ(it->second.stream->stream_id(), stream_id); 2696 CHECK_EQ(it->second.stream->stream_id(), stream_id);
2696 SendWindowUpdateFrame( 2697 SendWindowUpdateFrame(
2697 stream_id, delta_window_size, it->second.stream->priority()); 2698 stream_id, delta_window_size, it->second.stream->priority());
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
3150 if (!queue->empty()) { 3151 if (!queue->empty()) {
3151 SpdyStreamId stream_id = queue->front(); 3152 SpdyStreamId stream_id = queue->front();
3152 queue->pop_front(); 3153 queue->pop_front();
3153 return stream_id; 3154 return stream_id;
3154 } 3155 }
3155 } 3156 }
3156 return 0; 3157 return 0;
3157 } 3158 }
3158 3159
3159 } // namespace net 3160 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698