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

Side by Side Diff: net/spdy/spdy_protocol.cc

Issue 2544343003: Use wire values in SpdySettingsIds. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « net/spdy/spdy_protocol.h ('k') | net/spdy/spdy_protocol_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "net/spdy/spdy_protocol.h" 5 #include "net/spdy/spdy_protocol.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "net/spdy/spdy_bug_tracker.h" 8 #include "net/spdy/spdy_bug_tracker.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 case SETTINGS: 151 case SETTINGS:
152 case PING: 152 case PING:
153 // These frame types must not specify a stream 153 // These frame types must not specify a stream
154 return false; 154 return false;
155 default: 155 default:
156 return true; 156 return true;
157 } 157 }
158 } 158 }
159 } 159 }
160 160
161 bool SpdyConstants::IsValidSettingId(int setting_id_field) { 161 bool SpdyConstants::ParseSettingsId(int wire_setting_id,
162 // HEADER_TABLE_SIZE is the first valid setting id. 162 SpdySettingsIds* setting_id) {
163 if (setting_id_field < SerializeSettingId(SETTINGS_HEADER_TABLE_SIZE)) { 163 // HEADER_TABLE_SIZE is the first defined setting id.
164 if (wire_setting_id < SETTINGS_MIN) {
164 return false; 165 return false;
165 } 166 }
166 167
167 // MAX_HEADER_LIST_SIZE is the last valid setting id. 168 // MAX_HEADER_LIST_SIZE is the last defined setting id.
168 if (setting_id_field > SerializeSettingId(SETTINGS_MAX_HEADER_LIST_SIZE)) { 169 if (wire_setting_id > SETTINGS_MAX) {
169 return false; 170 return false;
170 } 171 }
171 172
173 *setting_id = static_cast<SpdySettingsIds>(wire_setting_id);
172 return true; 174 return true;
173 } 175 }
174 176
175 SpdySettingsIds SpdyConstants::ParseSettingId(int setting_id_field) { 177 bool SpdyConstants::SettingsIdToString(SpdySettingsIds id,
176 switch (setting_id_field) { 178 const char** settings_id_string) {
177 case 1:
178 return SETTINGS_HEADER_TABLE_SIZE;
179 case 2:
180 return SETTINGS_ENABLE_PUSH;
181 case 3:
182 return SETTINGS_MAX_CONCURRENT_STREAMS;
183 case 4:
184 return SETTINGS_INITIAL_WINDOW_SIZE;
185 case 5:
186 return SETTINGS_MAX_FRAME_SIZE;
187 case 6:
188 return SETTINGS_MAX_HEADER_LIST_SIZE;
189 }
190 SPDY_BUG << "Unhandled setting ID " << setting_id_field;
191 return SETTINGS_UPLOAD_BANDWIDTH;
192 }
193
194 int SpdyConstants::SerializeSettingId(SpdySettingsIds id) {
195 switch (id) { 179 switch (id) {
196 case SETTINGS_HEADER_TABLE_SIZE: 180 case SETTINGS_HEADER_TABLE_SIZE:
197 return 1; 181 *settings_id_string = "SETTINGS_HEADER_TABLE_SIZE";
182 return true;
198 case SETTINGS_ENABLE_PUSH: 183 case SETTINGS_ENABLE_PUSH:
199 return 2; 184 *settings_id_string = "SETTINGS_ENABLE_PUSH";
185 return true;
200 case SETTINGS_MAX_CONCURRENT_STREAMS: 186 case SETTINGS_MAX_CONCURRENT_STREAMS:
201 return 3; 187 *settings_id_string = "SETTINGS_MAX_CONCURRENT_STREAMS";
188 return true;
202 case SETTINGS_INITIAL_WINDOW_SIZE: 189 case SETTINGS_INITIAL_WINDOW_SIZE:
203 return 4; 190 *settings_id_string = "SETTINGS_INITIAL_WINDOW_SIZE";
191 return true;
204 case SETTINGS_MAX_FRAME_SIZE: 192 case SETTINGS_MAX_FRAME_SIZE:
205 return 5; 193 *settings_id_string = "SETTINGS_MAX_FRAME_SIZE";
194 return true;
206 case SETTINGS_MAX_HEADER_LIST_SIZE: 195 case SETTINGS_MAX_HEADER_LIST_SIZE:
207 return 6; 196 *settings_id_string = "SETTINGS_MAX_HEADER_LIST_SIZE";
208 default: 197 return true;
209 SPDY_BUG << "Serializing unhandled setting id " << id;
210 return -1;
211 } 198 }
199
200 *settings_id_string = "SETTINGS_UNKNOWN";
201 return false;
212 } 202 }
213 203
214 bool SpdyConstants::IsValidRstStreamStatus(int rst_stream_status_field) { 204 bool SpdyConstants::IsValidRstStreamStatus(int rst_stream_status_field) {
215 // NO_ERROR is the first valid status code. 205 // NO_ERROR is the first valid status code.
216 if (rst_stream_status_field < SerializeRstStreamStatus(RST_STREAM_NO_ERROR)) { 206 if (rst_stream_status_field < SerializeRstStreamStatus(RST_STREAM_NO_ERROR)) {
217 return false; 207 return false;
218 } 208 }
219 209
220 // TODO(hkhalil): Omit COMPRESSION_ERROR and SETTINGS_TIMEOUT 210 // TODO(hkhalil): Omit COMPRESSION_ERROR and SETTINGS_TIMEOUT
221 /* 211 /*
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 530
541 void SpdyAltSvcIR::Visit(SpdyFrameVisitor* visitor) const { 531 void SpdyAltSvcIR::Visit(SpdyFrameVisitor* visitor) const {
542 return visitor->VisitAltSvc(*this); 532 return visitor->VisitAltSvc(*this);
543 } 533 }
544 534
545 void SpdyPriorityIR::Visit(SpdyFrameVisitor* visitor) const { 535 void SpdyPriorityIR::Visit(SpdyFrameVisitor* visitor) const {
546 return visitor->VisitPriority(*this); 536 return visitor->VisitPriority(*this);
547 } 537 }
548 538
549 } // namespace net 539 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_protocol.h ('k') | net/spdy/spdy_protocol_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698