| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 SpdyStreamRequest::SpdyStreamRequest() { | 232 SpdyStreamRequest::SpdyStreamRequest() { |
| 233 Reset(); | 233 Reset(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 SpdyStreamRequest::~SpdyStreamRequest() { | 236 SpdyStreamRequest::~SpdyStreamRequest() { |
| 237 CancelRequest(); | 237 CancelRequest(); |
| 238 } | 238 } |
| 239 | 239 |
| 240 int SpdyStreamRequest::StartRequest( | 240 int SpdyStreamRequest::StartRequest( |
| 241 SpdyStreamType type, |
| 241 const scoped_refptr<SpdySession>& session, | 242 const scoped_refptr<SpdySession>& session, |
| 242 const GURL& url, | 243 const GURL& url, |
| 243 RequestPriority priority, | 244 RequestPriority priority, |
| 244 const BoundNetLog& net_log, | 245 const BoundNetLog& net_log, |
| 245 const CompletionCallback& callback) { | 246 const CompletionCallback& callback) { |
| 246 DCHECK(session); | 247 DCHECK(session); |
| 247 DCHECK(!session_); | 248 DCHECK(!session_); |
| 248 DCHECK(!stream_); | 249 DCHECK(!stream_); |
| 249 DCHECK(callback_.is_null()); | 250 DCHECK(callback_.is_null()); |
| 250 | 251 |
| 252 type_ = type; |
| 251 session_ = session; | 253 session_ = session; |
| 252 url_ = url; | 254 url_ = url; |
| 253 priority_ = priority; | 255 priority_ = priority; |
| 254 net_log_ = net_log; | 256 net_log_ = net_log; |
| 255 callback_ = callback; | 257 callback_ = callback; |
| 256 | 258 |
| 257 base::WeakPtr<SpdyStream> stream; | 259 base::WeakPtr<SpdyStream> stream; |
| 258 int rv = session->TryCreateStream(this, &stream); | 260 int rv = session->TryCreateStream(this, &stream); |
| 259 if (rv == OK) { | 261 if (rv == OK) { |
| 260 Reset(); | 262 Reset(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 DCHECK(session_); | 295 DCHECK(session_); |
| 294 DCHECK(!stream_); | 296 DCHECK(!stream_); |
| 295 DCHECK(!callback_.is_null()); | 297 DCHECK(!callback_.is_null()); |
| 296 CompletionCallback callback = callback_; | 298 CompletionCallback callback = callback_; |
| 297 Reset(); | 299 Reset(); |
| 298 DCHECK_NE(rv, OK); | 300 DCHECK_NE(rv, OK); |
| 299 callback.Run(rv); | 301 callback.Run(rv); |
| 300 } | 302 } |
| 301 | 303 |
| 302 void SpdyStreamRequest::Reset() { | 304 void SpdyStreamRequest::Reset() { |
| 305 type_ = SPDY_BIDIRECTIONAL_STREAM; |
| 303 session_ = NULL; | 306 session_ = NULL; |
| 304 stream_.reset(); | 307 stream_.reset(); |
| 305 url_ = GURL(); | 308 url_ = GURL(); |
| 306 priority_ = MINIMUM_PRIORITY; | 309 priority_ = MINIMUM_PRIORITY; |
| 307 net_log_ = BoundNetLog(); | 310 net_log_ = BoundNetLog(); |
| 308 callback_.Reset(); | 311 callback_.Reset(); |
| 309 } | 312 } |
| 310 | 313 |
| 311 SpdySession::SpdySession(const SpdySessionKey& spdy_session_key, | 314 SpdySession::SpdySession(const SpdySessionKey& spdy_session_key, |
| 312 SpdySessionPool* spdy_session_pool, | 315 SpdySessionPool* spdy_session_pool, |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 CloseSessionOnError( | 580 CloseSessionOnError( |
| 578 ERR_CONNECTION_CLOSED, | 581 ERR_CONNECTION_CLOSED, |
| 579 true, | 582 true, |
| 580 "Tried to create SPDY stream for a closed socket connection."); | 583 "Tried to create SPDY stream for a closed socket connection."); |
| 581 return ERR_CONNECTION_CLOSED; | 584 return ERR_CONNECTION_CLOSED; |
| 582 } | 585 } |
| 583 } | 586 } |
| 584 | 587 |
| 585 const std::string& path = request.url().PathForRequest(); | 588 const std::string& path = request.url().PathForRequest(); |
| 586 scoped_ptr<SpdyStream> new_stream( | 589 scoped_ptr<SpdyStream> new_stream( |
| 587 new SpdyStream(this, path, request.priority(), | 590 new SpdyStream(request.type(), this, path, request.priority(), |
| 588 stream_initial_send_window_size_, | 591 stream_initial_send_window_size_, |
| 589 stream_initial_recv_window_size_, | 592 stream_initial_recv_window_size_, |
| 590 false, request.net_log())); | 593 request.net_log())); |
| 591 *stream = new_stream->GetWeakPtr(); | 594 *stream = new_stream->GetWeakPtr(); |
| 592 InsertCreatedStream(new_stream.Pass()); | 595 InsertCreatedStream(new_stream.Pass()); |
| 593 | 596 |
| 594 UMA_HISTOGRAM_CUSTOM_COUNTS( | 597 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 595 "Net.SpdyPriorityCount", | 598 "Net.SpdyPriorityCount", |
| 596 static_cast<int>(request.priority()), 0, 10, 11); | 599 static_cast<int>(request.priority()), 0, 10, 11); |
| 597 | 600 |
| 598 return OK; | 601 return OK; |
| 599 } | 602 } |
| 600 | 603 |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 } | 1693 } |
| 1691 | 1694 |
| 1692 // There should not be an existing pushed stream with the same path. | 1695 // There should not be an existing pushed stream with the same path. |
| 1693 if (unclaimed_pushed_streams_.find(url) != unclaimed_pushed_streams_.end()) { | 1696 if (unclaimed_pushed_streams_.find(url) != unclaimed_pushed_streams_.end()) { |
| 1694 ResetStream(stream_id, request_priority, RST_STREAM_PROTOCOL_ERROR, | 1697 ResetStream(stream_id, request_priority, RST_STREAM_PROTOCOL_ERROR, |
| 1695 "Received duplicate pushed stream with url: " + url); | 1698 "Received duplicate pushed stream with url: " + url); |
| 1696 return; | 1699 return; |
| 1697 } | 1700 } |
| 1698 | 1701 |
| 1699 scoped_ptr<SpdyStream> stream( | 1702 scoped_ptr<SpdyStream> stream( |
| 1700 new SpdyStream(this, gurl.PathForRequest(), request_priority, | 1703 new SpdyStream(SPDY_PUSH_STREAM, this, gurl.PathForRequest(), |
| 1704 request_priority, |
| 1701 stream_initial_send_window_size_, | 1705 stream_initial_send_window_size_, |
| 1702 stream_initial_recv_window_size_, | 1706 stream_initial_recv_window_size_, |
| 1703 true, net_log_)); | 1707 net_log_)); |
| 1704 stream->set_stream_id(stream_id); | 1708 stream->set_stream_id(stream_id); |
| 1705 | 1709 |
| 1706 DeleteExpiredPushedStreams(); | 1710 DeleteExpiredPushedStreams(); |
| 1707 unclaimed_pushed_streams_[url] = | 1711 unclaimed_pushed_streams_[url] = |
| 1708 std::pair<SpdyStream*, base::TimeTicks>(stream.get(), time_func_()); | 1712 std::pair<SpdyStream*, base::TimeTicks>(stream.get(), time_func_()); |
| 1709 | 1713 |
| 1710 stream->set_response_received(); | 1714 stream->set_response_received(); |
| 1711 InsertActivatedStream(stream.Pass()); | 1715 InsertActivatedStream(stream.Pass()); |
| 1712 | 1716 |
| 1713 ActiveStreamMap::iterator it = active_streams_.find(stream_id); | 1717 ActiveStreamMap::iterator it = active_streams_.find(stream_id); |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2450 if (!queue->empty()) { | 2454 if (!queue->empty()) { |
| 2451 SpdyStreamId stream_id = queue->front(); | 2455 SpdyStreamId stream_id = queue->front(); |
| 2452 queue->pop_front(); | 2456 queue->pop_front(); |
| 2453 return stream_id; | 2457 return stream_id; |
| 2454 } | 2458 } |
| 2455 } | 2459 } |
| 2456 return 0; | 2460 return 0; |
| 2457 } | 2461 } |
| 2458 | 2462 |
| 2459 } // namespace net | 2463 } // namespace net |
| OLD | NEW |