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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 const int kMaxReadBytes = 32 * 1024; | 53 const int kMaxReadBytes = 32 * 1024; |
54 | 54 |
55 // The initial receive window size for both streams and sessions. | 55 // The initial receive window size for both streams and sessions. |
56 const int32 kDefaultInitialRecvWindowSize = 10 * 1024 * 1024; // 10MB | 56 const int32 kDefaultInitialRecvWindowSize = 10 * 1024 * 1024; // 10MB |
57 | 57 |
58 class BoundNetLog; | 58 class BoundNetLog; |
59 struct LoadTimingInfo; | 59 struct LoadTimingInfo; |
60 class SpdyStream; | 60 class SpdyStream; |
61 class SSLInfo; | 61 class SSLInfo; |
62 | 62 |
63 // NOTE: There's an enum of the same name (also with numeric suffixes) | |
64 // in histograms.xml. | |
jar (doing other things)
2013/04/19 23:12:38
Please add warning: DO NOT INSERT ENUMS INTO THIS
| |
63 enum SpdyProtocolErrorDetails { | 65 enum SpdyProtocolErrorDetails { |
64 // SpdyFramer::SpdyErrors | 66 // SpdyFramer::SpdyErrors |
65 SPDY_ERROR_NO_ERROR, | 67 SPDY_ERROR_NO_ERROR, |
66 SPDY_ERROR_INVALID_CONTROL_FRAME, | 68 SPDY_ERROR_INVALID_CONTROL_FRAME, |
67 SPDY_ERROR_CONTROL_PAYLOAD_TOO_LARGE, | 69 SPDY_ERROR_CONTROL_PAYLOAD_TOO_LARGE, |
68 SPDY_ERROR_ZLIB_INIT_FAILURE, | 70 SPDY_ERROR_ZLIB_INIT_FAILURE, |
69 SPDY_ERROR_UNSUPPORTED_VERSION, | 71 SPDY_ERROR_UNSUPPORTED_VERSION, |
70 SPDY_ERROR_DECOMPRESS_FAILURE, | 72 SPDY_ERROR_DECOMPRESS_FAILURE, |
71 SPDY_ERROR_COMPRESS_FAILURE, | 73 SPDY_ERROR_COMPRESS_FAILURE, |
72 SPDY_ERROR_CREDENTIAL_FRAME_CORRUPT, | 74 SPDY_ERROR_CREDENTIAL_FRAME_CORRUPT, |
73 SPDY_ERROR_INVALID_DATA_FRAME_FLAGS, | 75 SPDY_ERROR_INVALID_DATA_FRAME_FLAGS, |
74 SPDY_ERROR_INVALID_CONTROL_FRAME_FLAGS, | 76 SPDY_ERROR_INVALID_CONTROL_FRAME_FLAGS, |
75 | 77 |
76 // SpdyRstStreamStatus | 78 // SpdyRstStreamStatus |
77 STATUS_CODE_INVALID, | 79 STATUS_CODE_INVALID, |
78 STATUS_CODE_PROTOCOL_ERROR, | 80 STATUS_CODE_PROTOCOL_ERROR, |
79 STATUS_CODE_INVALID_STREAM, | 81 STATUS_CODE_INVALID_STREAM, |
80 STATUS_CODE_REFUSED_STREAM, | 82 STATUS_CODE_REFUSED_STREAM, |
81 STATUS_CODE_UNSUPPORTED_VERSION, | 83 STATUS_CODE_UNSUPPORTED_VERSION, |
82 STATUS_CODE_CANCEL, | 84 STATUS_CODE_CANCEL, |
83 STATUS_CODE_INTERNAL_ERROR, | 85 STATUS_CODE_INTERNAL_ERROR, |
84 STATUS_CODE_FLOW_CONTROL_ERROR, | 86 STATUS_CODE_FLOW_CONTROL_ERROR, |
85 STATUS_CODE_STREAM_IN_USE, | 87 STATUS_CODE_STREAM_IN_USE, |
86 STATUS_CODE_STREAM_ALREADY_CLOSED, | 88 STATUS_CODE_STREAM_ALREADY_CLOSED, |
87 STATUS_CODE_INVALID_CREDENTIALS, | 89 STATUS_CODE_INVALID_CREDENTIALS, |
88 STATUS_CODE_FRAME_TOO_LARGE, | 90 STATUS_CODE_FRAME_TOO_LARGE, |
89 | 91 |
90 // SpdySession errors | 92 // SpdySession errors |
jar (doing other things)
2013/04/19 23:12:38
nit: I'd put this at the end of line 93, to discou
| |
91 PROTOCOL_ERROR_UNEXPECTED_PING, | 93 PROTOCOL_ERROR_UNEXPECTED_PING, |
92 PROTOCOL_ERROR_RST_STREAM_FOR_NON_ACTIVE_STREAM, | 94 PROTOCOL_ERROR_RST_STREAM_FOR_NON_ACTIVE_STREAM, |
93 PROTOCOL_ERROR_SPDY_COMPRESSION_FAILURE, | 95 PROTOCOL_ERROR_SPDY_COMPRESSION_FAILURE, |
94 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION, | 96 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION, |
95 PROTOCOL_ERROR_SYN_REPLY_NOT_RECEIVED, | 97 PROTOCOL_ERROR_SYN_REPLY_NOT_RECEIVED, |
98 PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE, | |
99 PROTOCOL_ERROR_RECEIVE_WINDOW_VIOLATION, | |
96 NUM_SPDY_PROTOCOL_ERROR_DETAILS | 100 NUM_SPDY_PROTOCOL_ERROR_DETAILS |
97 }; | 101 }; |
98 | 102 |
99 COMPILE_ASSERT(STATUS_CODE_INVALID == | 103 COMPILE_ASSERT(STATUS_CODE_INVALID == |
100 static_cast<SpdyProtocolErrorDetails>(SpdyFramer::LAST_ERROR), | 104 static_cast<SpdyProtocolErrorDetails>(SpdyFramer::LAST_ERROR), |
101 SpdyProtocolErrorDetails_SpdyErrors_mismatch); | 105 SpdyProtocolErrorDetails_SpdyErrors_mismatch); |
102 | 106 |
103 COMPILE_ASSERT(PROTOCOL_ERROR_UNEXPECTED_PING == | 107 COMPILE_ASSERT(PROTOCOL_ERROR_UNEXPECTED_PING == |
104 static_cast<SpdyProtocolErrorDetails>( | 108 static_cast<SpdyProtocolErrorDetails>( |
105 RST_STREAM_NUM_STATUS_CODES + STATUS_CODE_INVALID), | 109 RST_STREAM_NUM_STATUS_CODES + STATUS_CODE_INVALID), |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 // ERR_IO_PENDING) otherwise. | 222 // ERR_IO_PENDING) otherwise. |
219 int GetPushStream( | 223 int GetPushStream( |
220 const GURL& url, | 224 const GURL& url, |
221 scoped_refptr<SpdyStream>* spdy_stream, | 225 scoped_refptr<SpdyStream>* spdy_stream, |
222 const BoundNetLog& stream_net_log); | 226 const BoundNetLog& stream_net_log); |
223 | 227 |
224 // Used by SpdySessionPool to initialize with a pre-existing SSL socket. For | 228 // Used by SpdySessionPool to initialize with a pre-existing SSL socket. For |
225 // testing, setting is_secure to false allows initialization with a | 229 // testing, setting is_secure to false allows initialization with a |
226 // pre-existing TCP socket. | 230 // pre-existing TCP socket. |
227 // Returns OK on success, or an error on failure. | 231 // Returns OK on success, or an error on failure. |
228 net::Error InitializeWithSocket(ClientSocketHandle* connection, | 232 Error InitializeWithSocket(ClientSocketHandle* connection, |
229 bool is_secure, | 233 bool is_secure, |
230 int certificate_error_code); | 234 int certificate_error_code); |
231 | 235 |
232 // Check to see if this SPDY session can support an additional domain. | 236 // Check to see if this SPDY session can support an additional domain. |
233 // If the session is un-authenticated, then this call always returns true. | 237 // If the session is un-authenticated, then this call always returns true. |
234 // For SSL-based sessions, verifies that the server certificate in use by | 238 // For SSL-based sessions, verifies that the server certificate in use by |
235 // this session provides authentication for the domain and no client | 239 // this session provides authentication for the domain and no client |
236 // certificate or channel ID was sent to the original server during the SSL | 240 // certificate or channel ID was sent to the original server during the SSL |
237 // handshake. NOTE: This function can have false negatives on some | 241 // handshake. NOTE: This function can have false negatives on some |
238 // platforms. | 242 // platforms. |
239 // TODO(wtc): rename this function and the Net.SpdyIPPoolDomainMatch | 243 // TODO(wtc): rename this function and the Net.SpdyIPPoolDomainMatch |
240 // histogram because this function does more than verifying domain | 244 // histogram because this function does more than verifying domain |
(...skipping 26 matching lines...) Expand all Loading... | |
267 scoped_ptr<SpdyFrame>* credential_frame); | 271 scoped_ptr<SpdyFrame>* credential_frame); |
268 | 272 |
269 // Creates and returns a HEADERS frame. | 273 // Creates and returns a HEADERS frame. |
270 scoped_ptr<SpdyFrame> CreateHeadersFrame(SpdyStreamId stream_id, | 274 scoped_ptr<SpdyFrame> CreateHeadersFrame(SpdyStreamId stream_id, |
271 const SpdyHeaderBlock& headers, | 275 const SpdyHeaderBlock& headers, |
272 SpdyControlFlags flags); | 276 SpdyControlFlags flags); |
273 | 277 |
274 // Creates and returns a SpdyBuffer holding a data frame with the | 278 // Creates and returns a SpdyBuffer holding a data frame with the |
275 // given data. May return NULL if stalled by flow control. | 279 // given data. May return NULL if stalled by flow control. |
276 scoped_ptr<SpdyBuffer> CreateDataBuffer(SpdyStreamId stream_id, | 280 scoped_ptr<SpdyBuffer> CreateDataBuffer(SpdyStreamId stream_id, |
277 net::IOBuffer* data, | 281 IOBuffer* data, |
278 int len, | 282 int len, |
279 SpdyDataFlags flags); | 283 SpdyDataFlags flags); |
280 | 284 |
281 // Close a stream. | 285 // Close a stream. |
282 void CloseStream(SpdyStreamId stream_id, int status); | 286 void CloseStream(SpdyStreamId stream_id, int status); |
283 | 287 |
284 // Close a stream that has been created but is not yet active. | 288 // Close a stream that has been created but is not yet active. |
285 void CloseCreatedStream(SpdyStream* stream, int status); | 289 void CloseCreatedStream(SpdyStream* stream, int status); |
286 | 290 |
287 // Reset a stream by sending a RST_STREAM frame with given status code. | 291 // Reset a stream by sending a RST_STREAM frame with given status code. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 // If session is closed, no new streams/transactions should be created. | 323 // If session is closed, no new streams/transactions should be created. |
320 bool IsClosed() const { return state_ == STATE_CLOSED; } | 324 bool IsClosed() const { return state_ == STATE_CLOSED; } |
321 | 325 |
322 // Closes this session. This will close all active streams and mark | 326 // Closes this session. This will close all active streams and mark |
323 // the session as permanently closed. | 327 // the session as permanently closed. |
324 // |err| should not be OK; this function is intended to be called on | 328 // |err| should not be OK; this function is intended to be called on |
325 // error. | 329 // error. |
326 // |remove_from_pool| indicates whether to also remove the session from the | 330 // |remove_from_pool| indicates whether to also remove the session from the |
327 // session pool. | 331 // session pool. |
328 // |description| indicates the reason for the error. | 332 // |description| indicates the reason for the error. |
329 void CloseSessionOnError(net::Error err, | 333 void CloseSessionOnError(Error err, |
330 bool remove_from_pool, | 334 bool remove_from_pool, |
331 const std::string& description); | 335 const std::string& description); |
332 | 336 |
333 // Retrieves information on the current state of the SPDY session as a | 337 // Retrieves information on the current state of the SPDY session as a |
334 // Value. Caller takes possession of the returned value. | 338 // Value. Caller takes possession of the returned value. |
335 base::Value* GetInfoAsValue() const; | 339 base::Value* GetInfoAsValue() const; |
336 | 340 |
337 // Indicates whether the session is being reused after having successfully | 341 // Indicates whether the session is being reused after having successfully |
338 // used to send/receive data in the past. | 342 // used to send/receive data in the past. |
339 bool IsReused() const; | 343 bool IsReused() const; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 const scoped_refptr<SpdyStream> stream); | 605 const scoped_refptr<SpdyStream> stream); |
602 | 606 |
603 void RecordPingRTTHistogram(base::TimeDelta duration); | 607 void RecordPingRTTHistogram(base::TimeDelta duration); |
604 void RecordHistograms(); | 608 void RecordHistograms(); |
605 void RecordProtocolErrorHistogram(SpdyProtocolErrorDetails details); | 609 void RecordProtocolErrorHistogram(SpdyProtocolErrorDetails details); |
606 | 610 |
607 // Closes all active streams with stream id's greater than | 611 // Closes all active streams with stream id's greater than |
608 // |last_good_stream_id|, as well as any created or pending streams. | 612 // |last_good_stream_id|, as well as any created or pending streams. |
609 // Does not close unclaimed push streams. | 613 // Does not close unclaimed push streams. |
610 void CloseAllStreamsAfter(SpdyStreamId last_good_stream_id, | 614 void CloseAllStreamsAfter(SpdyStreamId last_good_stream_id, |
611 net::Error status); | 615 Error status); |
612 | 616 |
613 // Closes all streams, including unclaimed push streams. Used as part of | 617 // Closes all streams, including unclaimed push streams. Used as part of |
614 // shutdown. | 618 // shutdown. |
615 void CloseAllStreams(net::Error status); | 619 void CloseAllStreams(Error status); |
616 | 620 |
617 void LogAbandonedStream(const scoped_refptr<SpdyStream>& stream, | 621 void LogAbandonedStream(const scoped_refptr<SpdyStream>& stream, |
618 net::Error status); | 622 Error status); |
619 | 623 |
620 // Invokes a user callback for stream creation. We provide this method so it | 624 // Invokes a user callback for stream creation. We provide this method so it |
621 // can be deferred to the MessageLoop, so we avoid re-entrancy problems. | 625 // can be deferred to the MessageLoop, so we avoid re-entrancy problems. |
622 void CompleteStreamRequest(SpdyStreamRequest* pending_request); | 626 void CompleteStreamRequest(SpdyStreamRequest* pending_request); |
623 | 627 |
624 // Remove old unclaimed pushed streams. | 628 // Remove old unclaimed pushed streams. |
625 void DeleteExpiredPushedStreams(); | 629 void DeleteExpiredPushedStreams(); |
626 | 630 |
627 // BufferedSpdyFramerVisitorInterface: | 631 // BufferedSpdyFramerVisitorInterface: |
628 virtual void OnError(SpdyFramer::SpdyError error_code) OVERRIDE; | 632 virtual void OnError(SpdyFramer::SpdyError error_code) OVERRIDE; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 | 830 |
827 // Certificate error code when using a secure connection. | 831 // Certificate error code when using a secure connection. |
828 int certificate_error_code_; | 832 int certificate_error_code_; |
829 | 833 |
830 // Spdy Frame state. | 834 // Spdy Frame state. |
831 scoped_ptr<BufferedSpdyFramer> buffered_spdy_framer_; | 835 scoped_ptr<BufferedSpdyFramer> buffered_spdy_framer_; |
832 | 836 |
833 // If an error has occurred on the session, the session is effectively | 837 // If an error has occurred on the session, the session is effectively |
834 // dead. Record this error here. When no error has occurred, |error_| will | 838 // dead. Record this error here. When no error has occurred, |error_| will |
835 // be OK. | 839 // be OK. |
836 net::Error error_; | 840 Error error_; |
837 State state_; | 841 State state_; |
838 | 842 |
839 // Limits | 843 // Limits |
840 size_t max_concurrent_streams_; // 0 if no limit | 844 size_t max_concurrent_streams_; // 0 if no limit |
841 size_t max_concurrent_streams_limit_; | 845 size_t max_concurrent_streams_limit_; |
842 | 846 |
843 // Some statistics counters for the session. | 847 // Some statistics counters for the session. |
844 int streams_initiated_count_; | 848 int streams_initiated_count_; |
845 int streams_pushed_count_; | 849 int streams_pushed_count_; |
846 int streams_pushed_and_claimed_count_; | 850 int streams_pushed_and_claimed_count_; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
941 // This SPDY proxy is allowed to push resources from origins that are | 945 // This SPDY proxy is allowed to push resources from origins that are |
942 // different from those of their associated streams. | 946 // different from those of their associated streams. |
943 HostPortPair trusted_spdy_proxy_; | 947 HostPortPair trusted_spdy_proxy_; |
944 | 948 |
945 TimeFunc time_func_; | 949 TimeFunc time_func_; |
946 }; | 950 }; |
947 | 951 |
948 } // namespace net | 952 } // namespace net |
949 | 953 |
950 #endif // NET_SPDY_SPDY_SESSION_H_ | 954 #endif // NET_SPDY_SPDY_SESSION_H_ |
OLD | NEW |