| 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 #ifndef NET_SPDY_SPDY_SESSION_H_ | 5 #ifndef NET_SPDY_SPDY_SESSION_H_ |
| 6 #define NET_SPDY_SPDY_SESSION_H_ | 6 #define NET_SPDY_SPDY_SESSION_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, IgnoreReservedRemoteStreamsCount); | 607 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, IgnoreReservedRemoteStreamsCount); |
| 608 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, | 608 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, |
| 609 CancelReservedStreamOnHeadersReceived); | 609 CancelReservedStreamOnHeadersReceived); |
| 610 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, RejectInvalidUnknownFrames); | 610 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, RejectInvalidUnknownFrames); |
| 611 FRIEND_TEST_ALL_PREFIXES(SpdySessionPoolTest, IPAddressChanged); | 611 FRIEND_TEST_ALL_PREFIXES(SpdySessionPoolTest, IPAddressChanged); |
| 612 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, | 612 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, |
| 613 ServerPushValidCrossOrigin); | 613 ServerPushValidCrossOrigin); |
| 614 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, | 614 FRIEND_TEST_ALL_PREFIXES(SpdyNetworkTransactionTest, |
| 615 ServerPushValidCrossOriginWithOpenSession); | 615 ServerPushValidCrossOriginWithOpenSession); |
| 616 | 616 |
| 617 typedef std::deque<base::WeakPtr<SpdyStreamRequest> > | 617 typedef std::deque<base::WeakPtr<SpdyStreamRequest>> |
| 618 PendingStreamRequestQueue; | 618 PendingStreamRequestQueue; |
| 619 | 619 typedef std::map<SpdyStreamId, SpdyStream*> ActiveStreamMap; |
| 620 struct ActiveStreamInfo { | |
| 621 ActiveStreamInfo(); | |
| 622 explicit ActiveStreamInfo(SpdyStream* stream); | |
| 623 ~ActiveStreamInfo(); | |
| 624 | |
| 625 SpdyStream* stream; | |
| 626 bool waiting_for_reply_headers_frame; | |
| 627 }; | |
| 628 typedef std::map<SpdyStreamId, ActiveStreamInfo> ActiveStreamMap; | |
| 629 | |
| 630 typedef std::set<SpdyStream*> CreatedStreamSet; | 620 typedef std::set<SpdyStream*> CreatedStreamSet; |
| 631 | 621 |
| 632 enum AvailabilityState { | 622 enum AvailabilityState { |
| 633 // The session is available in its socket pool and can be used | 623 // The session is available in its socket pool and can be used |
| 634 // freely. | 624 // freely. |
| 635 STATE_AVAILABLE, | 625 STATE_AVAILABLE, |
| 636 // The session can process data on existing streams but will | 626 // The session can process data on existing streams but will |
| 637 // refuse to create new ones. | 627 // refuse to create new ones. |
| 638 STATE_GOING_AWAY, | 628 STATE_GOING_AWAY, |
| 639 // The session is draining its write queue in preparation of closing. | 629 // The session is draining its write queue in preparation of closing. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 665 |
| 676 // Returns the next pending stream request to process, or NULL if | 666 // Returns the next pending stream request to process, or NULL if |
| 677 // there is none. | 667 // there is none. |
| 678 base::WeakPtr<SpdyStreamRequest> GetNextPendingStreamRequest(); | 668 base::WeakPtr<SpdyStreamRequest> GetNextPendingStreamRequest(); |
| 679 | 669 |
| 680 // Called when there is room to create more streams (e.g., a stream | 670 // Called when there is room to create more streams (e.g., a stream |
| 681 // was closed). Processes as many pending stream requests as | 671 // was closed). Processes as many pending stream requests as |
| 682 // possible. | 672 // possible. |
| 683 void ProcessPendingStreamRequests(); | 673 void ProcessPendingStreamRequests(); |
| 684 | 674 |
| 685 bool TryCreatePushStream(SpdyStreamId stream_id, | 675 void TryCreatePushStream(SpdyStreamId stream_id, |
| 686 SpdyStreamId associated_stream_id, | 676 SpdyStreamId associated_stream_id, |
| 687 SpdyPriority priority, | 677 SpdyPriority priority, |
| 688 SpdyHeaderBlock headers); | 678 SpdyHeaderBlock headers); |
| 689 | 679 |
| 690 // Close the stream pointed to by the given iterator. Note that that | 680 // Close the stream pointed to by the given iterator. Note that that |
| 691 // stream may hold the last reference to the session. | 681 // stream may hold the last reference to the session. |
| 692 void CloseActiveStreamIterator(ActiveStreamMap::iterator it, int status); | 682 void CloseActiveStreamIterator(ActiveStreamMap::iterator it, int status); |
| 693 | 683 |
| 694 // Close the stream pointed to by the given iterator. Note that that | 684 // Close the stream pointed to by the given iterator. Note that that |
| 695 // stream may hold the last reference to the session. | 685 // stream may hold the last reference to the session. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 808 |
| 819 // Returns the stream id of the push stream if it is not claimed yet, or 0 | 809 // Returns the stream id of the push stream if it is not claimed yet, or 0 |
| 820 // otherwise. | 810 // otherwise. |
| 821 SpdyStreamId GetStreamIdForPush(const GURL& url); | 811 SpdyStreamId GetStreamIdForPush(const GURL& url); |
| 822 | 812 |
| 823 // Check if we have a pending pushed-stream for this url | 813 // Check if we have a pending pushed-stream for this url |
| 824 // Returns the stream if found (and returns it from the pending | 814 // Returns the stream if found (and returns it from the pending |
| 825 // list). Returns NULL otherwise. | 815 // list). Returns NULL otherwise. |
| 826 base::WeakPtr<SpdyStream> GetActivePushStream(const GURL& url); | 816 base::WeakPtr<SpdyStream> GetActivePushStream(const GURL& url); |
| 827 | 817 |
| 828 // Delegates to |stream->OnInitialResponseHeadersReceived()|. If an | |
| 829 // error is returned, the last reference to |this| may have been | |
| 830 // released. | |
| 831 int OnInitialResponseHeadersReceived(const SpdyHeaderBlock& response_headers, | |
| 832 base::Time response_time, | |
| 833 base::TimeTicks recv_first_byte_time, | |
| 834 SpdyStream* stream); | |
| 835 | |
| 836 void RecordPingRTTHistogram(base::TimeDelta duration); | 818 void RecordPingRTTHistogram(base::TimeDelta duration); |
| 837 void RecordHistograms(); | 819 void RecordHistograms(); |
| 838 void RecordProtocolErrorHistogram(SpdyProtocolErrorDetails details); | 820 void RecordProtocolErrorHistogram(SpdyProtocolErrorDetails details); |
| 839 | 821 |
| 840 // DCHECKs that |availability_state_| >= STATE_GOING_AWAY, that | 822 // DCHECKs that |availability_state_| >= STATE_GOING_AWAY, that |
| 841 // there are no pending stream creation requests, and that there are | 823 // there are no pending stream creation requests, and that there are |
| 842 // no created streams. | 824 // no created streams. |
| 843 void DcheckGoingAway() const; | 825 void DcheckGoingAway() const; |
| 844 | 826 |
| 845 // Calls DcheckGoingAway(), then DCHECKs that |availability_state_| | 827 // Calls DcheckGoingAway(), then DCHECKs that |availability_state_| |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 // Used for posting asynchronous IO tasks. We use this even though | 1196 // Used for posting asynchronous IO tasks. We use this even though |
| 1215 // SpdySession is refcounted because we don't need to keep the SpdySession | 1197 // SpdySession is refcounted because we don't need to keep the SpdySession |
| 1216 // alive if the last reference is within a RunnableMethod. Just revoke the | 1198 // alive if the last reference is within a RunnableMethod. Just revoke the |
| 1217 // method. | 1199 // method. |
| 1218 base::WeakPtrFactory<SpdySession> weak_factory_; | 1200 base::WeakPtrFactory<SpdySession> weak_factory_; |
| 1219 }; | 1201 }; |
| 1220 | 1202 |
| 1221 } // namespace net | 1203 } // namespace net |
| 1222 | 1204 |
| 1223 #endif // NET_SPDY_SPDY_SESSION_H_ | 1205 #endif // NET_SPDY_SPDY_SESSION_H_ |
| OLD | NEW |