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 <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 | 420 |
421 // Returns true if session is not currently active | 421 // Returns true if session is not currently active |
422 bool is_active() const { | 422 bool is_active() const { |
423 return !active_streams_.empty() || !created_streams_.empty(); | 423 return !active_streams_.empty() || !created_streams_.empty(); |
424 } | 424 } |
425 | 425 |
426 // Access to the number of active and pending streams. These are primarily | 426 // Access to the number of active and pending streams. These are primarily |
427 // available for testing and diagnostics. | 427 // available for testing and diagnostics. |
428 size_t num_active_streams() const { return active_streams_.size(); } | 428 size_t num_active_streams() const { return active_streams_.size(); } |
429 size_t num_unclaimed_pushed_streams() const { | 429 size_t num_unclaimed_pushed_streams() const { |
430 return unclaimed_pushed_streams_.size(); | 430 return unclaimed_pushed_streams_.size(); |
431 } | 431 } |
432 size_t num_created_streams() const { return created_streams_.size(); } | 432 size_t num_created_streams() const { return created_streams_.size(); } |
433 | 433 |
434 size_t num_pushed_streams() const { return num_pushed_streams_; } | |
435 size_t num_active_pushed_streams() const { | |
436 return num_active_pushed_streams_; | |
437 } | |
438 | |
434 size_t pending_create_stream_queue_size(RequestPriority priority) const { | 439 size_t pending_create_stream_queue_size(RequestPriority priority) const { |
435 DCHECK_GE(priority, MINIMUM_PRIORITY); | 440 DCHECK_GE(priority, MINIMUM_PRIORITY); |
436 DCHECK_LE(priority, MAXIMUM_PRIORITY); | 441 DCHECK_LE(priority, MAXIMUM_PRIORITY); |
437 return pending_create_stream_queues_[priority].size(); | 442 return pending_create_stream_queues_[priority].size(); |
438 } | 443 } |
439 | 444 |
440 // Returns the (version-dependent) flow control state. | 445 // Returns the (version-dependent) flow control state. |
441 FlowControlState flow_control_state() const { | 446 FlowControlState flow_control_state() const { |
442 return flow_control_state_; | 447 return flow_control_state_; |
443 } | 448 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClearSettings); | 524 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClearSettings); |
520 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustRecvWindowSize); | 525 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustRecvWindowSize); |
521 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustSendWindowSize); | 526 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustSendWindowSize); |
522 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlInactiveStream); | 527 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlInactiveStream); |
523 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlNoReceiveLeaks); | 528 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlNoReceiveLeaks); |
524 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlNoSendLeaks); | 529 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlNoSendLeaks); |
525 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlEndToEnd); | 530 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlEndToEnd); |
526 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, StreamIdSpaceExhausted); | 531 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, StreamIdSpaceExhausted); |
527 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, UnstallRacesWithStreamCreation); | 532 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, UnstallRacesWithStreamCreation); |
528 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, GoAwayOnSessionFlowControlError); | 533 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, GoAwayOnSessionFlowControlError); |
534 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, | |
535 RejectPushedStreamExceedingConcurrencyLimit); | |
536 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, IgnoreReservedRemoteStreamsCount); | |
529 | 537 |
530 typedef std::deque<base::WeakPtr<SpdyStreamRequest> > | 538 typedef std::deque<base::WeakPtr<SpdyStreamRequest> > |
531 PendingStreamRequestQueue; | 539 PendingStreamRequestQueue; |
532 | 540 |
533 struct ActiveStreamInfo { | 541 struct ActiveStreamInfo { |
534 ActiveStreamInfo(); | 542 ActiveStreamInfo(); |
535 explicit ActiveStreamInfo(SpdyStream* stream); | 543 explicit ActiveStreamInfo(SpdyStream* stream); |
536 ~ActiveStreamInfo(); | 544 ~ActiveStreamInfo(); |
537 | 545 |
538 SpdyStream* stream; | 546 SpdyStream* stream; |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 // -------------------------- | 920 // -------------------------- |
913 | 921 |
914 void set_connection_at_risk_of_loss_time(base::TimeDelta duration) { | 922 void set_connection_at_risk_of_loss_time(base::TimeDelta duration) { |
915 connection_at_risk_of_loss_time_ = duration; | 923 connection_at_risk_of_loss_time_ = duration; |
916 } | 924 } |
917 | 925 |
918 void set_hung_interval(base::TimeDelta duration) { | 926 void set_hung_interval(base::TimeDelta duration) { |
919 hung_interval_ = duration; | 927 hung_interval_ = duration; |
920 } | 928 } |
921 | 929 |
930 void set_max_concurrent_pushed_streams(size_t value) { | |
931 max_concurrent_pushed_streams_ = value; | |
932 } | |
933 | |
922 int64 pings_in_flight() const { return pings_in_flight_; } | 934 int64 pings_in_flight() const { return pings_in_flight_; } |
923 | 935 |
924 uint32 next_ping_id() const { return next_ping_id_; } | 936 uint32 next_ping_id() const { return next_ping_id_; } |
925 | 937 |
926 base::TimeTicks last_activity_time() const { return last_activity_time_; } | 938 base::TimeTicks last_activity_time() const { return last_activity_time_; } |
927 | 939 |
928 bool check_ping_status_pending() const { return check_ping_status_pending_; } | 940 bool check_ping_status_pending() const { return check_ping_status_pending_; } |
929 | 941 |
930 size_t max_concurrent_streams() const { return max_concurrent_streams_; } | 942 size_t max_concurrent_streams() const { return max_concurrent_streams_; } |
931 | 943 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
977 // (Bijective) map from the URL to the ID of the streams that have | 989 // (Bijective) map from the URL to the ID of the streams that have |
978 // already started to be pushed by the server, but do not have | 990 // already started to be pushed by the server, but do not have |
979 // consumers yet. Contains a subset of |active_streams_|. | 991 // consumers yet. Contains a subset of |active_streams_|. |
980 PushedStreamMap unclaimed_pushed_streams_; | 992 PushedStreamMap unclaimed_pushed_streams_; |
981 | 993 |
982 // Set of all created streams but that have not yet sent any frames. | 994 // Set of all created streams but that have not yet sent any frames. |
983 // | 995 // |
984 // |created_streams_| owns all its SpdyStream objects. | 996 // |created_streams_| owns all its SpdyStream objects. |
985 CreatedStreamSet created_streams_; | 997 CreatedStreamSet created_streams_; |
986 | 998 |
999 // Number of pushed streams. All active streams are stored in | |
1000 // |active_streams_|, but it's better to know the number of push streams | |
1001 // without traversing the whole collection. | |
1002 size_t num_pushed_streams_; | |
1003 | |
1004 // Number of active pushed streams in |active_streams_|, i.e. not in reserved | |
1005 // remote state. Streams in reserved state are not counted towards any | |
1006 // concurrency limits. | |
1007 size_t num_active_pushed_streams_; | |
1008 | |
987 // The write queue. | 1009 // The write queue. |
988 SpdyWriteQueue write_queue_; | 1010 SpdyWriteQueue write_queue_; |
989 | 1011 |
990 // Data for the frame we are currently sending. | 1012 // Data for the frame we are currently sending. |
991 | 1013 |
992 // The buffer we're currently writing. | 1014 // The buffer we're currently writing. |
993 scoped_ptr<SpdyBuffer> in_flight_write_; | 1015 scoped_ptr<SpdyBuffer> in_flight_write_; |
994 // The type of the frame in |in_flight_write_|. | 1016 // The type of the frame in |in_flight_write_|. |
995 SpdyFrameType in_flight_write_frame_type_; | 1017 SpdyFrameType in_flight_write_frame_type_; |
996 // The size of the frame in |in_flight_write_|. | 1018 // The size of the frame in |in_flight_write_|. |
(...skipping 16 matching lines...) Expand all Loading... | |
1013 ReadState read_state_; | 1035 ReadState read_state_; |
1014 WriteState write_state_; | 1036 WriteState write_state_; |
1015 | 1037 |
1016 // If the session is closing (i.e., |availability_state_| is STATE_DRAINING), | 1038 // If the session is closing (i.e., |availability_state_| is STATE_DRAINING), |
1017 // then |error_on_close_| holds the error with which it was closed, which | 1039 // then |error_on_close_| holds the error with which it was closed, which |
1018 // may be OK (upon a polite GOAWAY) or an error < ERR_IO_PENDING otherwise. | 1040 // may be OK (upon a polite GOAWAY) or an error < ERR_IO_PENDING otherwise. |
1019 // Initialized to OK. | 1041 // Initialized to OK. |
1020 Error error_on_close_; | 1042 Error error_on_close_; |
1021 | 1043 |
1022 // Limits | 1044 // Limits |
1023 size_t max_concurrent_streams_; // 0 if no limit | 1045 size_t max_concurrent_streams_; // 0 if no limit |
Johnny
2014/07/07 19:58:49
I'm just realizing, it looks like we're not enforc
| |
1024 size_t max_concurrent_streams_limit_; | 1046 size_t max_concurrent_streams_limit_; |
1047 size_t max_concurrent_pushed_streams_; | |
1025 | 1048 |
1026 // Some statistics counters for the session. | 1049 // Some statistics counters for the session. |
1027 int streams_initiated_count_; | 1050 int streams_initiated_count_; |
1028 int streams_pushed_count_; | 1051 int streams_pushed_count_; |
1029 int streams_pushed_and_claimed_count_; | 1052 int streams_pushed_and_claimed_count_; |
1030 int streams_abandoned_count_; | 1053 int streams_abandoned_count_; |
1031 | 1054 |
1032 // |total_bytes_received_| keeps track of all the bytes read by the | 1055 // |total_bytes_received_| keeps track of all the bytes read by the |
1033 // SpdySession. It is used by the |Net.SpdySettingsCwnd...| histograms. | 1056 // SpdySession. It is used by the |Net.SpdySettingsCwnd...| histograms. |
1034 int total_bytes_received_; | 1057 int total_bytes_received_; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1132 // Used for posting asynchronous IO tasks. We use this even though | 1155 // Used for posting asynchronous IO tasks. We use this even though |
1133 // SpdySession is refcounted because we don't need to keep the SpdySession | 1156 // SpdySession is refcounted because we don't need to keep the SpdySession |
1134 // alive if the last reference is within a RunnableMethod. Just revoke the | 1157 // alive if the last reference is within a RunnableMethod. Just revoke the |
1135 // method. | 1158 // method. |
1136 base::WeakPtrFactory<SpdySession> weak_factory_; | 1159 base::WeakPtrFactory<SpdySession> weak_factory_; |
1137 }; | 1160 }; |
1138 | 1161 |
1139 } // namespace net | 1162 } // namespace net |
1140 | 1163 |
1141 #endif // NET_SPDY_SPDY_SESSION_H_ | 1164 #endif // NET_SPDY_SPDY_SESSION_H_ |
OLD | NEW |