Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: net/spdy/spdy_session.h

Issue 14348012: [SPDY] Close SPDY sessions on session flow control errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 STATUS_CODE_STREAM_ALREADY_CLOSED, 86 STATUS_CODE_STREAM_ALREADY_CLOSED,
87 STATUS_CODE_INVALID_CREDENTIALS, 87 STATUS_CODE_INVALID_CREDENTIALS,
88 STATUS_CODE_FRAME_TOO_LARGE, 88 STATUS_CODE_FRAME_TOO_LARGE,
89 89
90 // SpdySession errors 90 // SpdySession errors
91 PROTOCOL_ERROR_UNEXPECTED_PING, 91 PROTOCOL_ERROR_UNEXPECTED_PING,
92 PROTOCOL_ERROR_RST_STREAM_FOR_NON_ACTIVE_STREAM, 92 PROTOCOL_ERROR_RST_STREAM_FOR_NON_ACTIVE_STREAM,
93 PROTOCOL_ERROR_SPDY_COMPRESSION_FAILURE, 93 PROTOCOL_ERROR_SPDY_COMPRESSION_FAILURE,
94 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION, 94 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION,
95 PROTOCOL_ERROR_SYN_REPLY_NOT_RECEIVED, 95 PROTOCOL_ERROR_SYN_REPLY_NOT_RECEIVED,
96 PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE,
97 PROTOCOL_ERROR_RECEIVE_WINDOW_VIOLATION,
96 NUM_SPDY_PROTOCOL_ERROR_DETAILS 98 NUM_SPDY_PROTOCOL_ERROR_DETAILS
97 }; 99 };
98 100
99 COMPILE_ASSERT(STATUS_CODE_INVALID == 101 COMPILE_ASSERT(STATUS_CODE_INVALID ==
100 static_cast<SpdyProtocolErrorDetails>(SpdyFramer::LAST_ERROR), 102 static_cast<SpdyProtocolErrorDetails>(SpdyFramer::LAST_ERROR),
101 SpdyProtocolErrorDetails_SpdyErrors_mismatch); 103 SpdyProtocolErrorDetails_SpdyErrors_mismatch);
102 104
103 COMPILE_ASSERT(PROTOCOL_ERROR_UNEXPECTED_PING == 105 COMPILE_ASSERT(PROTOCOL_ERROR_UNEXPECTED_PING ==
104 static_cast<SpdyProtocolErrorDetails>( 106 static_cast<SpdyProtocolErrorDetails>(
105 RST_STREAM_NUM_STATUS_CODES + STATUS_CODE_INVALID), 107 RST_STREAM_NUM_STATUS_CODES + STATUS_CODE_INVALID),
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // ERR_IO_PENDING) otherwise. 220 // ERR_IO_PENDING) otherwise.
219 int GetPushStream( 221 int GetPushStream(
220 const GURL& url, 222 const GURL& url,
221 scoped_refptr<SpdyStream>* spdy_stream, 223 scoped_refptr<SpdyStream>* spdy_stream,
222 const BoundNetLog& stream_net_log); 224 const BoundNetLog& stream_net_log);
223 225
224 // Used by SpdySessionPool to initialize with a pre-existing SSL socket. For 226 // Used by SpdySessionPool to initialize with a pre-existing SSL socket. For
225 // testing, setting is_secure to false allows initialization with a 227 // testing, setting is_secure to false allows initialization with a
226 // pre-existing TCP socket. 228 // pre-existing TCP socket.
227 // Returns OK on success, or an error on failure. 229 // Returns OK on success, or an error on failure.
228 net::Error InitializeWithSocket(ClientSocketHandle* connection, 230 Error InitializeWithSocket(ClientSocketHandle* connection,
229 bool is_secure, 231 bool is_secure,
230 int certificate_error_code); 232 int certificate_error_code);
231 233
232 // Check to see if this SPDY session can support an additional domain. 234 // 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. 235 // 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 236 // For SSL-based sessions, verifies that the server certificate in use by
235 // this session provides authentication for the domain and no client 237 // this session provides authentication for the domain and no client
236 // certificate or channel ID was sent to the original server during the SSL 238 // certificate or channel ID was sent to the original server during the SSL
237 // handshake. NOTE: This function can have false negatives on some 239 // handshake. NOTE: This function can have false negatives on some
238 // platforms. 240 // platforms.
239 // TODO(wtc): rename this function and the Net.SpdyIPPoolDomainMatch 241 // TODO(wtc): rename this function and the Net.SpdyIPPoolDomainMatch
240 // histogram because this function does more than verifying domain 242 // histogram because this function does more than verifying domain
(...skipping 26 matching lines...) Expand all
267 scoped_ptr<SpdyFrame>* credential_frame); 269 scoped_ptr<SpdyFrame>* credential_frame);
268 270
269 // Creates and returns a HEADERS frame. 271 // Creates and returns a HEADERS frame.
270 scoped_ptr<SpdyFrame> CreateHeadersFrame(SpdyStreamId stream_id, 272 scoped_ptr<SpdyFrame> CreateHeadersFrame(SpdyStreamId stream_id,
271 const SpdyHeaderBlock& headers, 273 const SpdyHeaderBlock& headers,
272 SpdyControlFlags flags); 274 SpdyControlFlags flags);
273 275
274 // Creates and returns a SpdyBuffer holding a data frame with the 276 // Creates and returns a SpdyBuffer holding a data frame with the
275 // given data. May return NULL if stalled by flow control. 277 // given data. May return NULL if stalled by flow control.
276 scoped_ptr<SpdyBuffer> CreateDataBuffer(SpdyStreamId stream_id, 278 scoped_ptr<SpdyBuffer> CreateDataBuffer(SpdyStreamId stream_id,
277 net::IOBuffer* data, 279 IOBuffer* data,
278 int len, 280 int len,
279 SpdyDataFlags flags); 281 SpdyDataFlags flags);
280 282
281 // Close a stream. 283 // Close a stream.
282 void CloseStream(SpdyStreamId stream_id, int status); 284 void CloseStream(SpdyStreamId stream_id, int status);
283 285
284 // Close a stream that has been created but is not yet active. 286 // Close a stream that has been created but is not yet active.
285 void CloseCreatedStream(SpdyStream* stream, int status); 287 void CloseCreatedStream(SpdyStream* stream, int status);
286 288
287 // Reset a stream by sending a RST_STREAM frame with given status code. 289 // 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
319 // If session is closed, no new streams/transactions should be created. 321 // If session is closed, no new streams/transactions should be created.
320 bool IsClosed() const { return state_ == STATE_CLOSED; } 322 bool IsClosed() const { return state_ == STATE_CLOSED; }
321 323
322 // Closes this session. This will close all active streams and mark 324 // Closes this session. This will close all active streams and mark
323 // the session as permanently closed. 325 // the session as permanently closed.
324 // |err| should not be OK; this function is intended to be called on 326 // |err| should not be OK; this function is intended to be called on
325 // error. 327 // error.
326 // |remove_from_pool| indicates whether to also remove the session from the 328 // |remove_from_pool| indicates whether to also remove the session from the
327 // session pool. 329 // session pool.
328 // |description| indicates the reason for the error. 330 // |description| indicates the reason for the error.
329 void CloseSessionOnError(net::Error err, 331 void CloseSessionOnError(Error err,
330 bool remove_from_pool, 332 bool remove_from_pool,
331 const std::string& description); 333 const std::string& description);
332 334
333 // Retrieves information on the current state of the SPDY session as a 335 // Retrieves information on the current state of the SPDY session as a
334 // Value. Caller takes possession of the returned value. 336 // Value. Caller takes possession of the returned value.
335 base::Value* GetInfoAsValue() const; 337 base::Value* GetInfoAsValue() const;
336 338
337 // Indicates whether the session is being reused after having successfully 339 // Indicates whether the session is being reused after having successfully
338 // used to send/receive data in the past. 340 // used to send/receive data in the past.
339 bool IsReused() const; 341 bool IsReused() const;
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 // Calls OnResponseReceived(). 600 // Calls OnResponseReceived().
599 // Returns true if successful. 601 // Returns true if successful.
600 bool Respond(const SpdyHeaderBlock& headers, 602 bool Respond(const SpdyHeaderBlock& headers,
601 const scoped_refptr<SpdyStream> stream); 603 const scoped_refptr<SpdyStream> stream);
602 604
603 void RecordPingRTTHistogram(base::TimeDelta duration); 605 void RecordPingRTTHistogram(base::TimeDelta duration);
604 void RecordHistograms(); 606 void RecordHistograms();
605 void RecordProtocolErrorHistogram(SpdyProtocolErrorDetails details); 607 void RecordProtocolErrorHistogram(SpdyProtocolErrorDetails details);
606 608
607 // Closes all streams. Used as part of shutdown. 609 // Closes all streams. Used as part of shutdown.
608 void CloseAllStreams(net::Error status); 610 void CloseAllStreams(Error status);
609 611
610 void LogAbandonedStream(const scoped_refptr<SpdyStream>& stream, 612 void LogAbandonedStream(const scoped_refptr<SpdyStream>& stream,
611 net::Error status); 613 Error status);
612 614
613 // Invokes a user callback for stream creation. We provide this method so it 615 // Invokes a user callback for stream creation. We provide this method so it
614 // can be deferred to the MessageLoop, so we avoid re-entrancy problems. 616 // can be deferred to the MessageLoop, so we avoid re-entrancy problems.
615 void CompleteStreamRequest(SpdyStreamRequest* pending_request); 617 void CompleteStreamRequest(SpdyStreamRequest* pending_request);
616 618
617 // Remove old unclaimed pushed streams. 619 // Remove old unclaimed pushed streams.
618 void DeleteExpiredPushedStreams(); 620 void DeleteExpiredPushedStreams();
619 621
620 // BufferedSpdyFramerVisitorInterface: 622 // BufferedSpdyFramerVisitorInterface:
621 virtual void OnError(SpdyFramer::SpdyError error_code) OVERRIDE; 623 virtual void OnError(SpdyFramer::SpdyError error_code) OVERRIDE;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 821
820 // Certificate error code when using a secure connection. 822 // Certificate error code when using a secure connection.
821 int certificate_error_code_; 823 int certificate_error_code_;
822 824
823 // Spdy Frame state. 825 // Spdy Frame state.
824 scoped_ptr<BufferedSpdyFramer> buffered_spdy_framer_; 826 scoped_ptr<BufferedSpdyFramer> buffered_spdy_framer_;
825 827
826 // If an error has occurred on the session, the session is effectively 828 // If an error has occurred on the session, the session is effectively
827 // dead. Record this error here. When no error has occurred, |error_| will 829 // dead. Record this error here. When no error has occurred, |error_| will
828 // be OK. 830 // be OK.
829 net::Error error_; 831 Error error_;
830 State state_; 832 State state_;
831 833
832 // Limits 834 // Limits
833 size_t max_concurrent_streams_; // 0 if no limit 835 size_t max_concurrent_streams_; // 0 if no limit
834 size_t max_concurrent_streams_limit_; 836 size_t max_concurrent_streams_limit_;
835 837
836 // Some statistics counters for the session. 838 // Some statistics counters for the session.
837 int streams_initiated_count_; 839 int streams_initiated_count_;
838 int streams_pushed_count_; 840 int streams_pushed_count_;
839 int streams_pushed_and_claimed_count_; 841 int streams_pushed_and_claimed_count_;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 // This SPDY proxy is allowed to push resources from origins that are 936 // This SPDY proxy is allowed to push resources from origins that are
935 // different from those of their associated streams. 937 // different from those of their associated streams.
936 HostPortPair trusted_spdy_proxy_; 938 HostPortPair trusted_spdy_proxy_;
937 939
938 TimeFunc time_func_; 940 TimeFunc time_func_;
939 }; 941 };
940 942
941 } // namespace net 943 } // namespace net
942 944
943 #endif // NET_SPDY_SPDY_SESSION_H_ 945 #endif // NET_SPDY_SPDY_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698