| 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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 974          frame_type == DATA || | 974          frame_type == DATA || | 
| 975          frame_type == CREDENTIAL || | 975          frame_type == CREDENTIAL || | 
| 976          frame_type == SYN_STREAM); | 976          frame_type == SYN_STREAM); | 
| 977   EnqueueWrite(stream->priority(), frame_type, producer.Pass(), stream); | 977   EnqueueWrite(stream->priority(), frame_type, producer.Pass(), stream); | 
| 978 } | 978 } | 
| 979 | 979 | 
| 980 scoped_ptr<SpdyFrame> SpdySession::CreateSynStream( | 980 scoped_ptr<SpdyFrame> SpdySession::CreateSynStream( | 
| 981     SpdyStreamId stream_id, | 981     SpdyStreamId stream_id, | 
| 982     RequestPriority priority, | 982     RequestPriority priority, | 
| 983     SpdyControlFlags flags, | 983     SpdyControlFlags flags, | 
| 984     const SpdyHeaderBlock& headers) { | 984     const SpdyHeaderBlock& block) { | 
| 985   ActiveStreamMap::const_iterator it = active_streams_.find(stream_id); | 985   ActiveStreamMap::const_iterator it = active_streams_.find(stream_id); | 
| 986   CHECK(it != active_streams_.end()); | 986   CHECK(it != active_streams_.end()); | 
| 987   CHECK_EQ(it->second.stream->stream_id(), stream_id); | 987   CHECK_EQ(it->second.stream->stream_id(), stream_id); | 
| 988 | 988 | 
| 989   SendPrefacePingIfNoneInFlight(); | 989   SendPrefacePingIfNoneInFlight(); | 
| 990 | 990 | 
| 991   DCHECK(buffered_spdy_framer_.get()); | 991   DCHECK(buffered_spdy_framer_.get()); | 
| 992   SpdyPriority spdy_priority = | 992   SpdyPriority spdy_priority = | 
| 993       ConvertRequestPriorityToSpdyPriority(priority, GetProtocolVersion()); | 993       ConvertRequestPriorityToSpdyPriority(priority, GetProtocolVersion()); | 
| 994   scoped_ptr<SpdyFrame> syn_frame( | 994 | 
| 995       buffered_spdy_framer_->CreateSynStream(stream_id, 0, spdy_priority, flags, | 995   scoped_ptr<SpdyFrame> syn_frame; | 
| 996                                              &headers)); | 996   // TODO(hkhalil): Avoid copy of |block|. | 
|  | 997   if (GetProtocolVersion() <= SPDY3) { | 
|  | 998     SpdySynStreamIR syn_stream(stream_id); | 
|  | 999     syn_stream.set_associated_to_stream_id(0); | 
|  | 1000     syn_stream.set_priority(spdy_priority); | 
|  | 1001     syn_stream.set_fin((flags & CONTROL_FLAG_FIN) != 0); | 
|  | 1002     syn_stream.set_unidirectional((flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0); | 
|  | 1003     syn_stream.set_name_value_block(block); | 
|  | 1004     syn_frame.reset(buffered_spdy_framer_->SerializeFrame(syn_stream)); | 
|  | 1005   } else { | 
|  | 1006     SpdyHeadersIR headers(stream_id); | 
|  | 1007     headers.set_priority(spdy_priority); | 
|  | 1008     headers.set_has_priority(true); | 
|  | 1009     headers.set_fin((flags & CONTROL_FLAG_FIN) != 0); | 
|  | 1010     headers.set_name_value_block(block); | 
|  | 1011     syn_frame.reset(buffered_spdy_framer_->SerializeFrame(headers)); | 
|  | 1012   } | 
| 997 | 1013 | 
| 998   base::StatsCounter spdy_requests("spdy.requests"); | 1014   base::StatsCounter spdy_requests("spdy.requests"); | 
| 999   spdy_requests.Increment(); | 1015   spdy_requests.Increment(); | 
| 1000   streams_initiated_count_++; | 1016   streams_initiated_count_++; | 
| 1001 | 1017 | 
| 1002   if (net_log().IsLogging()) { | 1018   if (net_log().IsLogging()) { | 
| 1003     net_log().AddEvent( | 1019     net_log().AddEvent(NetLog::TYPE_SPDY_SESSION_SYN_STREAM, | 
| 1004         NetLog::TYPE_SPDY_SESSION_SYN_STREAM, | 1020                        base::Bind(&NetLogSpdySynStreamSentCallback, | 
| 1005         base::Bind(&NetLogSpdySynStreamSentCallback, &headers, | 1021                                   &block, | 
| 1006                    (flags & CONTROL_FLAG_FIN) != 0, | 1022                                   (flags & CONTROL_FLAG_FIN) != 0, | 
| 1007                    (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0, | 1023                                   (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0, | 
| 1008                    spdy_priority, | 1024                                   spdy_priority, | 
| 1009                    stream_id)); | 1025                                   stream_id)); | 
| 1010   } | 1026   } | 
| 1011 | 1027 | 
| 1012   return syn_frame.Pass(); | 1028   return syn_frame.Pass(); | 
| 1013 } | 1029 } | 
| 1014 | 1030 | 
| 1015 scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id, | 1031 scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id, | 
| 1016                                                      IOBuffer* data, | 1032                                                      IOBuffer* data, | 
| 1017                                                      int len, | 1033                                                      int len, | 
| 1018                                                      SpdyDataFlags flags) { | 1034                                                      SpdyDataFlags flags) { | 
| 1019   if (availability_state_ == STATE_DRAINING) { | 1035   if (availability_state_ == STATE_DRAINING) { | 
| (...skipping 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3117     if (!queue->empty()) { | 3133     if (!queue->empty()) { | 
| 3118       SpdyStreamId stream_id = queue->front(); | 3134       SpdyStreamId stream_id = queue->front(); | 
| 3119       queue->pop_front(); | 3135       queue->pop_front(); | 
| 3120       return stream_id; | 3136       return stream_id; | 
| 3121     } | 3137     } | 
| 3122   } | 3138   } | 
| 3123   return 0; | 3139   return 0; | 
| 3124 } | 3140 } | 
| 3125 | 3141 | 
| 3126 }  // namespace net | 3142 }  // namespace net | 
| OLD | NEW | 
|---|