| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 make_scoped_refptr( | 293 make_scoped_refptr( |
| 294 new NetLogSpdySessionParameter(host_port_proxy_pair_))); | 294 new NetLogSpdySessionParameter(host_port_proxy_pair_))); |
| 295 | 295 |
| 296 // TODO(mbelshe): consider randomization of the stream_hi_water_mark. | 296 // TODO(mbelshe): consider randomization of the stream_hi_water_mark. |
| 297 | 297 |
| 298 spdy_framer_.set_visitor(this); | 298 spdy_framer_.set_visitor(this); |
| 299 | 299 |
| 300 SendSettings(); | 300 SendSettings(); |
| 301 } | 301 } |
| 302 | 302 |
| 303 SpdySession::PendingCreateStream::~PendingCreateStream() {} |
| 304 |
| 305 SpdySession::CallbackResultPair::~CallbackResultPair() {} |
| 306 |
| 303 SpdySession::~SpdySession() { | 307 SpdySession::~SpdySession() { |
| 304 if (state_ != CLOSED) { | 308 if (state_ != CLOSED) { |
| 305 state_ = CLOSED; | 309 state_ = CLOSED; |
| 306 | 310 |
| 307 // Cleanup all the streams. | 311 // Cleanup all the streams. |
| 308 CloseAllStreams(net::ERR_ABORTED); | 312 CloseAllStreams(net::ERR_ABORTED); |
| 309 } | 313 } |
| 310 | 314 |
| 311 if (connection_->is_initialized()) { | 315 if (connection_->is_initialized()) { |
| 312 // With Spdy we can't recycle sockets. | 316 // With Spdy we can't recycle sockets. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 return OK; | 397 return OK; |
| 394 } | 398 } |
| 395 return 0; | 399 return 0; |
| 396 } | 400 } |
| 397 | 401 |
| 398 int SpdySession::CreateStream( | 402 int SpdySession::CreateStream( |
| 399 const GURL& url, | 403 const GURL& url, |
| 400 RequestPriority priority, | 404 RequestPriority priority, |
| 401 scoped_refptr<SpdyStream>* spdy_stream, | 405 scoped_refptr<SpdyStream>* spdy_stream, |
| 402 const BoundNetLog& stream_net_log, | 406 const BoundNetLog& stream_net_log, |
| 403 OldCompletionCallback* callback) { | 407 const CompletionCallback& callback) { |
| 404 if (!max_concurrent_streams_ || | 408 if (!max_concurrent_streams_ || |
| 405 active_streams_.size() < max_concurrent_streams_) { | 409 active_streams_.size() < max_concurrent_streams_) { |
| 406 return CreateStreamImpl(url, priority, spdy_stream, stream_net_log); | 410 return CreateStreamImpl(url, priority, spdy_stream, stream_net_log); |
| 407 } | 411 } |
| 408 | 412 |
| 409 stalled_streams_++; | 413 stalled_streams_++; |
| 410 net_log().AddEvent(NetLog::TYPE_SPDY_SESSION_STALLED_MAX_STREAMS, NULL); | 414 net_log().AddEvent(NetLog::TYPE_SPDY_SESSION_STALLED_MAX_STREAMS, NULL); |
| 411 create_stream_queues_[priority].push( | 415 create_stream_queues_[priority].push( |
| 412 PendingCreateStream(url, priority, spdy_stream, | 416 PendingCreateStream(url, priority, spdy_stream, |
| 413 stream_net_log, callback)); | 417 stream_net_log, callback)); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 if (!unclaimed_pushed_streams_.empty()) { | 887 if (!unclaimed_pushed_streams_.empty()) { |
| 884 streams_abandoned_count_ += unclaimed_pushed_streams_.size(); | 888 streams_abandoned_count_ += unclaimed_pushed_streams_.size(); |
| 885 abandoned_push_streams.Add(unclaimed_pushed_streams_.size()); | 889 abandoned_push_streams.Add(unclaimed_pushed_streams_.size()); |
| 886 unclaimed_pushed_streams_.clear(); | 890 unclaimed_pushed_streams_.clear(); |
| 887 } | 891 } |
| 888 | 892 |
| 889 for (int i = 0;i < NUM_PRIORITIES;++i) { | 893 for (int i = 0;i < NUM_PRIORITIES;++i) { |
| 890 while (!create_stream_queues_[i].empty()) { | 894 while (!create_stream_queues_[i].empty()) { |
| 891 PendingCreateStream pending_create = create_stream_queues_[i].front(); | 895 PendingCreateStream pending_create = create_stream_queues_[i].front(); |
| 892 create_stream_queues_[i].pop(); | 896 create_stream_queues_[i].pop(); |
| 893 pending_create.callback->Run(ERR_ABORTED); | 897 pending_create.callback.Run(ERR_ABORTED); |
| 894 } | 898 } |
| 895 } | 899 } |
| 896 | 900 |
| 897 while (!active_streams_.empty()) { | 901 while (!active_streams_.empty()) { |
| 898 ActiveStreamMap::iterator it = active_streams_.begin(); | 902 ActiveStreamMap::iterator it = active_streams_.begin(); |
| 899 const scoped_refptr<SpdyStream>& stream = it->second; | 903 const scoped_refptr<SpdyStream>& stream = it->second; |
| 900 DCHECK(stream); | 904 DCHECK(stream); |
| 901 VLOG(1) << "ABANDONED (stream_id=" << stream->stream_id() | 905 VLOG(1) << "ABANDONED (stream_id=" << stream->stream_id() |
| 902 << "): " << stream->path(); | 906 << "): " << stream->path(); |
| 903 DeleteStream(stream->stream_id(), status); | 907 DeleteStream(stream->stream_id(), status); |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 } | 1760 } |
| 1757 | 1761 |
| 1758 void SpdySession::InvokeUserStreamCreationCallback( | 1762 void SpdySession::InvokeUserStreamCreationCallback( |
| 1759 scoped_refptr<SpdyStream>* stream) { | 1763 scoped_refptr<SpdyStream>* stream) { |
| 1760 PendingCallbackMap::iterator it = pending_callback_map_.find(stream); | 1764 PendingCallbackMap::iterator it = pending_callback_map_.find(stream); |
| 1761 | 1765 |
| 1762 // Exit if the request has already been cancelled. | 1766 // Exit if the request has already been cancelled. |
| 1763 if (it == pending_callback_map_.end()) | 1767 if (it == pending_callback_map_.end()) |
| 1764 return; | 1768 return; |
| 1765 | 1769 |
| 1766 OldCompletionCallback* callback = it->second.callback; | 1770 CompletionCallback callback = it->second.callback; |
| 1767 int result = it->second.result; | 1771 int result = it->second.result; |
| 1768 pending_callback_map_.erase(it); | 1772 pending_callback_map_.erase(it); |
| 1769 callback->Run(result); | 1773 callback.Run(result); |
| 1770 } | 1774 } |
| 1771 | 1775 |
| 1772 } // namespace net | 1776 } // namespace net |
| OLD | NEW |