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

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

Issue 2675593002: Spdy{RstStream,GoAway}Status -> SpdyErrorCode. (Closed)
Patch Set: Unsigned vs signed int Created 3 years, 10 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
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 SPDY_ERROR_COMPRESS_FAILURE = 6, 101 SPDY_ERROR_COMPRESS_FAILURE = 6,
102 SPDY_ERROR_GOAWAY_FRAME_CORRUPT = 29, 102 SPDY_ERROR_GOAWAY_FRAME_CORRUPT = 29,
103 SPDY_ERROR_RST_STREAM_FRAME_CORRUPT = 30, 103 SPDY_ERROR_RST_STREAM_FRAME_CORRUPT = 30,
104 SPDY_ERROR_INVALID_PADDING = 39, 104 SPDY_ERROR_INVALID_PADDING = 39,
105 SPDY_ERROR_INVALID_DATA_FRAME_FLAGS = 8, 105 SPDY_ERROR_INVALID_DATA_FRAME_FLAGS = 8,
106 SPDY_ERROR_INVALID_CONTROL_FRAME_FLAGS = 9, 106 SPDY_ERROR_INVALID_CONTROL_FRAME_FLAGS = 9,
107 SPDY_ERROR_UNEXPECTED_FRAME = 31, 107 SPDY_ERROR_UNEXPECTED_FRAME = 31,
108 SPDY_ERROR_INTERNAL_FRAMER_ERROR = 41, 108 SPDY_ERROR_INTERNAL_FRAMER_ERROR = 41,
109 SPDY_ERROR_INVALID_CONTROL_FRAME_SIZE = 37, 109 SPDY_ERROR_INVALID_CONTROL_FRAME_SIZE = 37,
110 SPDY_ERROR_OVERSIZED_PAYLOAD = 40, 110 SPDY_ERROR_OVERSIZED_PAYLOAD = 40,
111 // SpdyRstStreamStatus mappings. 111 // SpdyErrorCode mappings.
112 STATUS_CODE_NO_ERROR = 41, 112 STATUS_CODE_NO_ERROR = 41,
113 STATUS_CODE_PROTOCOL_ERROR = 11, 113 STATUS_CODE_PROTOCOL_ERROR = 11,
114 STATUS_CODE_INTERNAL_ERROR = 16, 114 STATUS_CODE_INTERNAL_ERROR = 16,
115 STATUS_CODE_FLOW_CONTROL_ERROR = 17, 115 STATUS_CODE_FLOW_CONTROL_ERROR = 17,
116 STATUS_CODE_SETTINGS_TIMEOUT = 32, 116 STATUS_CODE_SETTINGS_TIMEOUT = 32,
117 STATUS_CODE_STREAM_CLOSED = 12, 117 STATUS_CODE_STREAM_CLOSED = 12,
118 STATUS_CODE_FRAME_SIZE_ERROR = 21, 118 STATUS_CODE_FRAME_SIZE_ERROR = 21,
119 STATUS_CODE_REFUSED_STREAM = 13, 119 STATUS_CODE_REFUSED_STREAM = 13,
120 STATUS_CODE_CANCEL = 15, 120 STATUS_CODE_CANCEL = 15,
121 STATUS_CODE_COMPRESSION_ERROR = 42, 121 STATUS_CODE_COMPRESSION_ERROR = 42,
122 STATUS_CODE_CONNECT_ERROR = 33, 122 STATUS_CODE_CONNECT_ERROR = 33,
123 STATUS_CODE_ENHANCE_YOUR_CALM = 34, 123 STATUS_CODE_ENHANCE_YOUR_CALM = 34,
124 STATUS_CODE_INADEQUATE_SECURITY = 35, 124 STATUS_CODE_INADEQUATE_SECURITY = 35,
125 STATUS_CODE_HTTP_1_1_REQUIRED = 36, 125 STATUS_CODE_HTTP_1_1_REQUIRED = 36,
126 // Deprecated SpdyRstStrreamStatus mappings. 126 // Deprecated SpdyRstStrreamStatus mappings.
127 STATUS_CODE_UNSUPPORTED_VERSION = 14, 127 STATUS_CODE_UNSUPPORTED_VERSION = 14,
128 STATUS_CODE_STREAM_IN_USE = 18, 128 STATUS_CODE_STREAM_IN_USE = 18,
129 STATUS_CODE_STREAM_ALREADY_CLOSED = 19, 129 STATUS_CODE_STREAM_ALREADY_CLOSED = 19,
130 130
131 // SpdySession errors 131 // SpdySession errors
132 PROTOCOL_ERROR_UNEXPECTED_PING = 22, 132 PROTOCOL_ERROR_UNEXPECTED_PING = 22,
133 PROTOCOL_ERROR_RST_STREAM_FOR_NON_ACTIVE_STREAM = 23, 133 PROTOCOL_ERROR_ERROR_CODE_FOR_NON_ACTIVE_STREAM = 23,
Bence 2017/02/02 15:12:25 Please leave this as RST_STREAM (since GOAWAY does
diannahu 2017/02/02 15:58:09 Whoops, I must've missed this when doing the find/
134 PROTOCOL_ERROR_SPDY_COMPRESSION_FAILURE = 24, 134 PROTOCOL_ERROR_SPDY_COMPRESSION_FAILURE = 24,
135 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION = 25, 135 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION = 25,
136 PROTOCOL_ERROR_SYN_REPLY_NOT_RECEIVED = 26, 136 PROTOCOL_ERROR_SYN_REPLY_NOT_RECEIVED = 26,
137 PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE = 27, 137 PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE = 27,
138 PROTOCOL_ERROR_RECEIVE_WINDOW_VIOLATION = 28, 138 PROTOCOL_ERROR_RECEIVE_WINDOW_VIOLATION = 28,
139 139
140 // Next free value. 140 // Next free value.
141 NUM_SPDY_PROTOCOL_ERROR_DETAILS = 43, 141 NUM_SPDY_PROTOCOL_ERROR_DETAILS = 43,
142 }; 142 };
143 SpdyProtocolErrorDetails NET_EXPORT_PRIVATE 143 SpdyProtocolErrorDetails NET_EXPORT_PRIVATE
144 MapFramerErrorToProtocolError(SpdyFramer::SpdyFramerError error); 144 MapFramerErrorToProtocolError(SpdyFramer::SpdyFramerError error);
145 Error NET_EXPORT_PRIVATE 145 Error NET_EXPORT_PRIVATE
146 MapFramerErrorToNetError(SpdyFramer::SpdyFramerError error); 146 MapFramerErrorToNetError(SpdyFramer::SpdyFramerError error);
147 SpdyProtocolErrorDetails NET_EXPORT_PRIVATE 147 SpdyProtocolErrorDetails NET_EXPORT_PRIVATE
148 MapRstStreamStatusToProtocolError(SpdyRstStreamStatus status); 148 MapRstStreamStatusToProtocolError(SpdyErrorCode error_code);
149 SpdyGoAwayStatus NET_EXPORT_PRIVATE MapNetErrorToGoAwayStatus(Error err); 149 SpdyErrorCode NET_EXPORT_PRIVATE MapNetErrorToGoAwayStatus(Error err);
150 150
151 // If these compile asserts fail then SpdyProtocolErrorDetails needs 151 // If these compile asserts fail then SpdyProtocolErrorDetails needs
152 // to be updated with new values, as do the mapping functions above. 152 // to be updated with new values, as do the mapping functions above.
153 static_assert(17 == SpdyFramer::LAST_ERROR, 153 static_assert(17 == SpdyFramer::LAST_ERROR,
154 "SpdyProtocolErrorDetails / Spdy Errors mismatch"); 154 "SpdyProtocolErrorDetails / Spdy Errors mismatch");
155 static_assert(14 == RST_STREAM_NUM_STATUS_CODES, 155 static_assert(13 == SpdyErrorCode::ERROR_CODE_MAX,
156 "SpdyProtocolErrorDetails / RstStreamStatus mismatch"); 156 "SpdyProtocolErrorDetails / SpdyErrorCode mismatch");
157 157
158 // A helper class used to manage a request to create a stream. 158 // A helper class used to manage a request to create a stream.
159 class NET_EXPORT_PRIVATE SpdyStreamRequest { 159 class NET_EXPORT_PRIVATE SpdyStreamRequest {
160 public: 160 public:
161 SpdyStreamRequest(); 161 SpdyStreamRequest();
162 // Calls CancelRequest(). 162 // Calls CancelRequest().
163 ~SpdyStreamRequest(); 163 ~SpdyStreamRequest();
164 164
165 // Starts the request to create a stream. If OK is returned, then 165 // Starts the request to create a stream. If OK is returned, then
166 // ReleaseStream() may be called. If ERR_IO_PENDING is returned, 166 // ReleaseStream() may be called. If ERR_IO_PENDING is returned,
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 // Close the given created stream, which must exist but not yet be 390 // Close the given created stream, which must exist but not yet be
391 // active. Note that |stream| may hold the last reference to the 391 // active. Note that |stream| may hold the last reference to the
392 // session. 392 // session.
393 void CloseCreatedStream(const base::WeakPtr<SpdyStream>& stream, int status); 393 void CloseCreatedStream(const base::WeakPtr<SpdyStream>& stream, int status);
394 394
395 // Send a RST_STREAM frame with the given status code and close the 395 // Send a RST_STREAM frame with the given status code and close the
396 // stream with the given ID, which must exist and be active. Note 396 // stream with the given ID, which must exist and be active. Note
397 // that that stream may hold the last reference to the session. 397 // that that stream may hold the last reference to the session.
398 void ResetStream(SpdyStreamId stream_id, 398 void ResetStream(SpdyStreamId stream_id,
399 SpdyRstStreamStatus status, 399 SpdyErrorCode error_code,
400 const std::string& description); 400 const std::string& description);
401 401
402 // Check if a stream is active. 402 // Check if a stream is active.
403 bool IsStreamActive(SpdyStreamId stream_id) const; 403 bool IsStreamActive(SpdyStreamId stream_id) const;
404 404
405 // The LoadState is used for informing the user of the current network 405 // The LoadState is used for informing the user of the current network
406 // status, such as "resolving host", "connecting", etc. 406 // status, such as "resolving host", "connecting", etc.
407 LoadState GetLoadState() const; 407 LoadState GetLoadState() const;
408 408
409 // Returns server infomation in the form of (scheme/host/port). 409 // Returns server infomation in the form of (scheme/host/port).
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 // stream may hold the last reference to the session. 683 // stream may hold the last reference to the session.
684 void CloseActiveStreamIterator(ActiveStreamMap::iterator it, int status); 684 void CloseActiveStreamIterator(ActiveStreamMap::iterator it, int status);
685 685
686 // Close the stream pointed to by the given iterator. Note that that 686 // Close the stream pointed to by the given iterator. Note that that
687 // stream may hold the last reference to the session. 687 // stream may hold the last reference to the session.
688 void CloseCreatedStreamIterator(CreatedStreamSet::iterator it, int status); 688 void CloseCreatedStreamIterator(CreatedStreamSet::iterator it, int status);
689 689
690 // Calls EnqueueResetStreamFrame() and then 690 // Calls EnqueueResetStreamFrame() and then
691 // CloseActiveStreamIterator(). 691 // CloseActiveStreamIterator().
692 void ResetStreamIterator(ActiveStreamMap::iterator it, 692 void ResetStreamIterator(ActiveStreamMap::iterator it,
693 SpdyRstStreamStatus status, 693 SpdyErrorCode error_code,
694 const std::string& description); 694 const std::string& description);
695 695
696 // Send a RST_STREAM frame with the given parameters. There should 696 // Send a RST_STREAM frame with the given parameters. There should
697 // either be no active stream with the given ID, or that active 697 // either be no active stream with the given ID, or that active
698 // stream should be closed shortly after this function is called. 698 // stream should be closed shortly after this function is called.
699 void EnqueueResetStreamFrame(SpdyStreamId stream_id, 699 void EnqueueResetStreamFrame(SpdyStreamId stream_id,
700 RequestPriority priority, 700 RequestPriority priority,
701 SpdyRstStreamStatus status, 701 SpdyErrorCode error_code,
702 const std::string& description); 702 const std::string& description);
703 703
704 // Send a PRIORITY frame with the given parameters. 704 // Send a PRIORITY frame with the given parameters.
705 void EnqueuePriorityFrame(SpdyStreamId stream_id, 705 void EnqueuePriorityFrame(SpdyStreamId stream_id,
706 SpdyStreamId dependency_id, 706 SpdyStreamId dependency_id,
707 int weight, 707 int weight,
708 bool exclusive); 708 bool exclusive);
709 709
710 // Calls DoReadLoop. Use this function instead of DoReadLoop when 710 // Calls DoReadLoop. Use this function instead of DoReadLoop when
711 // posting a task to pump the read loop. 711 // posting a task to pump the read loop.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 const base::WeakPtr<SpdyStreamRequest>& pending_request); 854 const base::WeakPtr<SpdyStreamRequest>& pending_request);
855 855
856 // Remove old unclaimed pushed streams. 856 // Remove old unclaimed pushed streams.
857 void DeleteExpiredPushedStreams(); 857 void DeleteExpiredPushedStreams();
858 858
859 // BufferedSpdyFramerVisitorInterface: 859 // BufferedSpdyFramerVisitorInterface:
860 void OnError(SpdyFramer::SpdyFramerError spdy_framer_error) override; 860 void OnError(SpdyFramer::SpdyFramerError spdy_framer_error) override;
861 void OnStreamError(SpdyStreamId stream_id, 861 void OnStreamError(SpdyStreamId stream_id,
862 const std::string& description) override; 862 const std::string& description) override;
863 void OnPing(SpdyPingId unique_id, bool is_ack) override; 863 void OnPing(SpdyPingId unique_id, bool is_ack) override;
864 void OnRstStream(SpdyStreamId stream_id, SpdyRstStreamStatus status) override; 864 void OnRstStream(SpdyStreamId stream_id, SpdyErrorCode error_code) override;
865 void OnGoAway(SpdyStreamId last_accepted_stream_id, 865 void OnGoAway(SpdyStreamId last_accepted_stream_id,
866 SpdyGoAwayStatus status, 866 SpdyErrorCode error_code,
867 base::StringPiece debug_data) override; 867 base::StringPiece debug_data) override;
868 void OnDataFrameHeader(SpdyStreamId stream_id, 868 void OnDataFrameHeader(SpdyStreamId stream_id,
869 size_t length, 869 size_t length,
870 bool fin) override; 870 bool fin) override;
871 void OnStreamFrameData(SpdyStreamId stream_id, 871 void OnStreamFrameData(SpdyStreamId stream_id,
872 const char* data, 872 const char* data,
873 size_t len) override; 873 size_t len) override;
874 void OnStreamEnd(SpdyStreamId stream_id) override; 874 void OnStreamEnd(SpdyStreamId stream_id) override;
875 void OnStreamPadding(SpdyStreamId stream_id, size_t len) override; 875 void OnStreamPadding(SpdyStreamId stream_id, size_t len) override;
876 void OnSettings() override; 876 void OnSettings() override;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 // Used for posting asynchronous IO tasks. We use this even though 1211 // Used for posting asynchronous IO tasks. We use this even though
1212 // SpdySession is refcounted because we don't need to keep the SpdySession 1212 // SpdySession is refcounted because we don't need to keep the SpdySession
1213 // alive if the last reference is within a RunnableMethod. Just revoke the 1213 // alive if the last reference is within a RunnableMethod. Just revoke the
1214 // method. 1214 // method.
1215 base::WeakPtrFactory<SpdySession> weak_factory_; 1215 base::WeakPtrFactory<SpdySession> weak_factory_;
1216 }; 1216 };
1217 1217
1218 } // namespace net 1218 } // namespace net
1219 1219
1220 #endif // NET_SPDY_SPDY_SESSION_H_ 1220 #endif // NET_SPDY_SPDY_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698