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); |
| 537 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, |
| 538 CancelReservedStreamOnHeadersReceived); |
529 | 539 |
530 typedef std::deque<base::WeakPtr<SpdyStreamRequest> > | 540 typedef std::deque<base::WeakPtr<SpdyStreamRequest> > |
531 PendingStreamRequestQueue; | 541 PendingStreamRequestQueue; |
532 | 542 |
533 struct ActiveStreamInfo { | 543 struct ActiveStreamInfo { |
534 ActiveStreamInfo(); | 544 ActiveStreamInfo(); |
535 explicit ActiveStreamInfo(SpdyStream* stream); | 545 explicit ActiveStreamInfo(SpdyStream* stream); |
536 ~ActiveStreamInfo(); | 546 ~ActiveStreamInfo(); |
537 | 547 |
538 SpdyStream* stream; | 548 SpdyStream* stream; |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 // -------------------------- | 922 // -------------------------- |
913 | 923 |
914 void set_connection_at_risk_of_loss_time(base::TimeDelta duration) { | 924 void set_connection_at_risk_of_loss_time(base::TimeDelta duration) { |
915 connection_at_risk_of_loss_time_ = duration; | 925 connection_at_risk_of_loss_time_ = duration; |
916 } | 926 } |
917 | 927 |
918 void set_hung_interval(base::TimeDelta duration) { | 928 void set_hung_interval(base::TimeDelta duration) { |
919 hung_interval_ = duration; | 929 hung_interval_ = duration; |
920 } | 930 } |
921 | 931 |
| 932 void set_max_concurrent_pushed_streams(size_t value) { |
| 933 max_concurrent_pushed_streams_ = value; |
| 934 } |
| 935 |
922 int64 pings_in_flight() const { return pings_in_flight_; } | 936 int64 pings_in_flight() const { return pings_in_flight_; } |
923 | 937 |
924 uint32 next_ping_id() const { return next_ping_id_; } | 938 uint32 next_ping_id() const { return next_ping_id_; } |
925 | 939 |
926 base::TimeTicks last_activity_time() const { return last_activity_time_; } | 940 base::TimeTicks last_activity_time() const { return last_activity_time_; } |
927 | 941 |
928 bool check_ping_status_pending() const { return check_ping_status_pending_; } | 942 bool check_ping_status_pending() const { return check_ping_status_pending_; } |
929 | 943 |
930 size_t max_concurrent_streams() const { return max_concurrent_streams_; } | 944 size_t max_concurrent_streams() const { return max_concurrent_streams_; } |
931 | 945 |
(...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 | 991 // (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 | 992 // already started to be pushed by the server, but do not have |
979 // consumers yet. Contains a subset of |active_streams_|. | 993 // consumers yet. Contains a subset of |active_streams_|. |
980 PushedStreamMap unclaimed_pushed_streams_; | 994 PushedStreamMap unclaimed_pushed_streams_; |
981 | 995 |
982 // Set of all created streams but that have not yet sent any frames. | 996 // Set of all created streams but that have not yet sent any frames. |
983 // | 997 // |
984 // |created_streams_| owns all its SpdyStream objects. | 998 // |created_streams_| owns all its SpdyStream objects. |
985 CreatedStreamSet created_streams_; | 999 CreatedStreamSet created_streams_; |
986 | 1000 |
| 1001 // Number of pushed streams. All active streams are stored in |
| 1002 // |active_streams_|, but it's better to know the number of push streams |
| 1003 // without traversing the whole collection. |
| 1004 size_t num_pushed_streams_; |
| 1005 |
| 1006 // Number of active pushed streams in |active_streams_|, i.e. not in reserved |
| 1007 // remote state. Streams in reserved state are not counted towards any |
| 1008 // concurrency limits. |
| 1009 size_t num_active_pushed_streams_; |
| 1010 |
987 // The write queue. | 1011 // The write queue. |
988 SpdyWriteQueue write_queue_; | 1012 SpdyWriteQueue write_queue_; |
989 | 1013 |
990 // Data for the frame we are currently sending. | 1014 // Data for the frame we are currently sending. |
991 | 1015 |
992 // The buffer we're currently writing. | 1016 // The buffer we're currently writing. |
993 scoped_ptr<SpdyBuffer> in_flight_write_; | 1017 scoped_ptr<SpdyBuffer> in_flight_write_; |
994 // The type of the frame in |in_flight_write_|. | 1018 // The type of the frame in |in_flight_write_|. |
995 SpdyFrameType in_flight_write_frame_type_; | 1019 SpdyFrameType in_flight_write_frame_type_; |
996 // The size of the frame in |in_flight_write_|. | 1020 // The size of the frame in |in_flight_write_|. |
(...skipping 18 matching lines...) Expand all Loading... |
1015 | 1039 |
1016 // If the session is closing (i.e., |availability_state_| is STATE_DRAINING), | 1040 // 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 | 1041 // 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. | 1042 // may be OK (upon a polite GOAWAY) or an error < ERR_IO_PENDING otherwise. |
1019 // Initialized to OK. | 1043 // Initialized to OK. |
1020 Error error_on_close_; | 1044 Error error_on_close_; |
1021 | 1045 |
1022 // Limits | 1046 // Limits |
1023 size_t max_concurrent_streams_; // 0 if no limit | 1047 size_t max_concurrent_streams_; // 0 if no limit |
1024 size_t max_concurrent_streams_limit_; | 1048 size_t max_concurrent_streams_limit_; |
| 1049 size_t max_concurrent_pushed_streams_; |
1025 | 1050 |
1026 // Some statistics counters for the session. | 1051 // Some statistics counters for the session. |
1027 int streams_initiated_count_; | 1052 int streams_initiated_count_; |
1028 int streams_pushed_count_; | 1053 int streams_pushed_count_; |
1029 int streams_pushed_and_claimed_count_; | 1054 int streams_pushed_and_claimed_count_; |
1030 int streams_abandoned_count_; | 1055 int streams_abandoned_count_; |
1031 | 1056 |
1032 // |total_bytes_received_| keeps track of all the bytes read by the | 1057 // |total_bytes_received_| keeps track of all the bytes read by the |
1033 // SpdySession. It is used by the |Net.SpdySettingsCwnd...| histograms. | 1058 // SpdySession. It is used by the |Net.SpdySettingsCwnd...| histograms. |
1034 int total_bytes_received_; | 1059 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 | 1157 // Used for posting asynchronous IO tasks. We use this even though |
1133 // SpdySession is refcounted because we don't need to keep the SpdySession | 1158 // 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 | 1159 // alive if the last reference is within a RunnableMethod. Just revoke the |
1135 // method. | 1160 // method. |
1136 base::WeakPtrFactory<SpdySession> weak_factory_; | 1161 base::WeakPtrFactory<SpdySession> weak_factory_; |
1137 }; | 1162 }; |
1138 | 1163 |
1139 } // namespace net | 1164 } // namespace net |
1140 | 1165 |
1141 #endif // NET_SPDY_SPDY_SESSION_H_ | 1166 #endif // NET_SPDY_SPDY_SESSION_H_ |
OLD | NEW |