| 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 case RST_STREAM_CONNECT_ERROR: | 333 case RST_STREAM_CONNECT_ERROR: |
| 334 return STATUS_CODE_CONNECT_ERROR; | 334 return STATUS_CODE_CONNECT_ERROR; |
| 335 case RST_STREAM_ENHANCE_YOUR_CALM: | 335 case RST_STREAM_ENHANCE_YOUR_CALM: |
| 336 return STATUS_CODE_ENHANCE_YOUR_CALM; | 336 return STATUS_CODE_ENHANCE_YOUR_CALM; |
| 337 default: | 337 default: |
| 338 NOTREACHED(); | 338 NOTREACHED(); |
| 339 return static_cast<SpdyProtocolErrorDetails>(-1); | 339 return static_cast<SpdyProtocolErrorDetails>(-1); |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 | 342 |
| 343 void SplitPushedHeadersToRequestAndResponse(const SpdyHeaderBlock& headers, |
| 344 SpdyMajorVersion protocol_version, |
| 345 SpdyHeaderBlock* request_headers, |
| 346 SpdyHeaderBlock* response_headers) { |
| 347 DCHECK(response_headers); |
| 348 DCHECK(request_headers); |
| 349 for (SpdyHeaderBlock::const_iterator it = headers.begin(); |
| 350 it != headers.end(); |
| 351 ++it) { |
| 352 SpdyHeaderBlock* to_insert = response_headers; |
| 353 if (protocol_version == SPDY2) { |
| 354 if (it->first == "url") |
| 355 to_insert = request_headers; |
| 356 } else { |
| 357 const char* host = protocol_version >= SPDY4 ? ":authority" : ":host"; |
| 358 static const char* scheme = ":scheme"; |
| 359 static const char* path = ":path"; |
| 360 if (it->first == host || it->first == scheme || it->first == path) |
| 361 to_insert = request_headers; |
| 362 } |
| 363 to_insert->insert(*it); |
| 364 } |
| 365 } |
| 366 |
| 343 SpdyStreamRequest::SpdyStreamRequest() : weak_ptr_factory_(this) { | 367 SpdyStreamRequest::SpdyStreamRequest() : weak_ptr_factory_(this) { |
| 344 Reset(); | 368 Reset(); |
| 345 } | 369 } |
| 346 | 370 |
| 347 SpdyStreamRequest::~SpdyStreamRequest() { | 371 SpdyStreamRequest::~SpdyStreamRequest() { |
| 348 CancelRequest(); | 372 CancelRequest(); |
| 349 } | 373 } |
| 350 | 374 |
| 351 int SpdyStreamRequest::StartRequest( | 375 int SpdyStreamRequest::StartRequest( |
| 352 SpdyStreamType type, | 376 SpdyStreamType type, |
| (...skipping 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2119 | 2143 |
| 2120 InsertActivatedStream(stream.Pass()); | 2144 InsertActivatedStream(stream.Pass()); |
| 2121 | 2145 |
| 2122 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); | 2146 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); |
| 2123 if (active_it == active_streams_.end()) { | 2147 if (active_it == active_streams_.end()) { |
| 2124 NOTREACHED(); | 2148 NOTREACHED(); |
| 2125 return; | 2149 return; |
| 2126 } | 2150 } |
| 2127 | 2151 |
| 2128 // Parse the headers. | 2152 // Parse the headers. |
| 2129 if (OnInitialResponseHeadersReceived( | 2153 |
| 2130 headers, response_time, | 2154 // Split headers to simulate push promise and response. |
| 2131 recv_first_byte_time, active_it->second.stream) != OK) | 2155 SpdyHeaderBlock request_headers; |
| 2156 SpdyHeaderBlock response_headers; |
| 2157 SplitPushedHeadersToRequestAndResponse( |
| 2158 headers, GetProtocolVersion(), &request_headers, &response_headers); |
| 2159 |
| 2160 if (active_it->second.stream->OnPushPromiseHeadersReceived(request_headers) != |
| 2161 OK) |
| 2162 return; |
| 2163 |
| 2164 if (OnInitialResponseHeadersReceived(response_headers, |
| 2165 response_time, |
| 2166 recv_first_byte_time, |
| 2167 active_it->second.stream) != OK) |
| 2132 return; | 2168 return; |
| 2133 | 2169 |
| 2134 base::StatsCounter push_requests("spdy.pushed_streams"); | 2170 base::StatsCounter push_requests("spdy.pushed_streams"); |
| 2135 push_requests.Increment(); | 2171 push_requests.Increment(); |
| 2136 } | 2172 } |
| 2137 | 2173 |
| 2138 void SpdySession::DeleteExpiredPushedStreams() { | 2174 void SpdySession::DeleteExpiredPushedStreams() { |
| 2139 if (unclaimed_pushed_streams_.empty()) | 2175 if (unclaimed_pushed_streams_.empty()) |
| 2140 return; | 2176 return; |
| 2141 | 2177 |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2944 if (!queue->empty()) { | 2980 if (!queue->empty()) { |
| 2945 SpdyStreamId stream_id = queue->front(); | 2981 SpdyStreamId stream_id = queue->front(); |
| 2946 queue->pop_front(); | 2982 queue->pop_front(); |
| 2947 return stream_id; | 2983 return stream_id; |
| 2948 } | 2984 } |
| 2949 } | 2985 } |
| 2950 return 0; | 2986 return 0; |
| 2951 } | 2987 } |
| 2952 | 2988 |
| 2953 } // namespace net | 2989 } // namespace net |
| OLD | NEW |