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

Side by Side Diff: net/spdy/spdy_framer.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/quic/core/quic_headers_stream_test.cc ('k') | net/spdy/spdy_framer_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_framer.h" 5 #include "net/spdy/spdy_framer.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cctype> 10 #include <cctype>
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 remaining_data_length_ -= processed_bytes; 1344 remaining_data_length_ -= processed_bytes;
1345 if (remaining_data_length_ == 0) { 1345 if (remaining_data_length_ == 0) {
1346 visitor_->OnSettingsEnd(); 1346 visitor_->OnSettingsEnd();
1347 CHANGE_STATE(SPDY_FRAME_COMPLETE); 1347 CHANGE_STATE(SPDY_FRAME_COMPLETE);
1348 } 1348 }
1349 1349
1350 return processed_bytes; 1350 return processed_bytes;
1351 } 1351 }
1352 1352
1353 bool SpdyFramer::ProcessSetting(const char* data) { 1353 bool SpdyFramer::ProcessSetting(const char* data) {
1354 int id_field;
1355 SpdySettingsIds id;
1356 uint8_t flags = 0;
1357 uint32_t value;
1358
1359 // Extract fields. 1354 // Extract fields.
1360 // Maintain behavior of old SPDY 2 bug with byte ordering of flags/id. 1355 // Maintain behavior of old SPDY 2 bug with byte ordering of flags/id.
1361 id_field = base::NetToHost16(*(reinterpret_cast<const uint16_t*>(data))); 1356 int id_field = base::NetToHost16(*(reinterpret_cast<const uint16_t*>(data)));
1362 value = base::NetToHost32(*(reinterpret_cast<const uint32_t*>(data + 2))); 1357 int32_t value =
1358 base::NetToHost32(*(reinterpret_cast<const uint32_t*>(data + 2)));
1363 1359
1364 // Validate id. 1360 // Validate id.
1365 if (!SpdyConstants::IsValidSettingId(id_field)) { 1361 SpdySettingsIds setting_id;
1362 if (!SpdyConstants::ParseSettingsId(id_field, &setting_id)) {
1366 DLOG(WARNING) << "Unknown SETTINGS ID: " << id_field; 1363 DLOG(WARNING) << "Unknown SETTINGS ID: " << id_field;
1367 // Ignore unknown settings for extensibility. 1364 // Ignore unknown settings for extensibility.
1368 return true; 1365 return true;
1369 } 1366 }
1370 id = SpdyConstants::ParseSettingId(id_field);
1371 1367
1372 // Validation succeeded. Pass on to visitor. 1368 // Validation succeeded. Pass on to visitor.
1373 visitor_->OnSetting(id, flags, value); 1369 visitor_->OnSetting(setting_id, /*flags=*/0, value);
1374 return true; 1370 return true;
1375 } 1371 }
1376 1372
1377 size_t SpdyFramer::ProcessControlFramePayload(const char* data, size_t len) { 1373 size_t SpdyFramer::ProcessControlFramePayload(const char* data, size_t len) {
1378 size_t original_len = len; 1374 size_t original_len = len;
1379 size_t bytes_read = UpdateCurrentFrameBuffer(&data, &len, 1375 size_t bytes_read = UpdateCurrentFrameBuffer(&data, &len,
1380 remaining_data_length_); 1376 remaining_data_length_);
1381 remaining_data_length_ -= bytes_read; 1377 remaining_data_length_ -= bytes_read;
1382 if (remaining_data_length_ == 0) { 1378 if (remaining_data_length_ == 0) {
1383 SpdyFrameReader reader(current_frame_buffer_.data(), 1379 SpdyFrameReader reader(current_frame_buffer_.data(),
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 SpdyFrameBuilder builder(size); 1907 SpdyFrameBuilder builder(size);
1912 builder.BeginNewFrame(*this, SETTINGS, flags, 0); 1908 builder.BeginNewFrame(*this, SETTINGS, flags, 0);
1913 1909
1914 // If this is an ACK, payload should be empty. 1910 // If this is an ACK, payload should be empty.
1915 if (settings.is_ack()) { 1911 if (settings.is_ack()) {
1916 return builder.take(); 1912 return builder.take();
1917 } 1913 }
1918 1914
1919 DCHECK_EQ(GetSettingsMinimumSize(), builder.length()); 1915 DCHECK_EQ(GetSettingsMinimumSize(), builder.length());
1920 for (SpdySettingsIR::ValueMap::const_iterator it = values->begin(); 1916 for (SpdySettingsIR::ValueMap::const_iterator it = values->begin();
1921 it != values->end(); 1917 it != values->end(); ++it) {
1922 ++it) { 1918 int setting_id = it->first;
1923 int setting_id = SpdyConstants::SerializeSettingId(it->first);
1924 DCHECK_GE(setting_id, 0); 1919 DCHECK_GE(setting_id, 0);
1925 builder.WriteUInt16(static_cast<uint16_t>(setting_id)); 1920 builder.WriteUInt16(static_cast<uint16_t>(setting_id));
1926 builder.WriteUInt32(it->second.value); 1921 builder.WriteUInt32(it->second.value);
1927 } 1922 }
1928 DCHECK_EQ(size, builder.length()); 1923 DCHECK_EQ(size, builder.length());
1929 return builder.take(); 1924 return builder.take();
1930 } 1925 }
1931 1926
1932 SpdySerializedFrame SpdyFramer::SerializePing(const SpdyPingIR& ping) const { 1927 SpdySerializedFrame SpdyFramer::SerializePing(const SpdyPingIR& ping) const {
1933 SpdyFrameBuilder builder(GetPingSize()); 1928 SpdyFrameBuilder builder(GetPingSize());
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 builder->WriteUInt32(header_block.size()); 2422 builder->WriteUInt32(header_block.size());
2428 2423
2429 // Serialize each header. 2424 // Serialize each header.
2430 for (const auto& header : header_block) { 2425 for (const auto& header : header_block) {
2431 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); 2426 builder->WriteStringPiece32(base::ToLowerASCII(header.first));
2432 builder->WriteStringPiece32(header.second); 2427 builder->WriteStringPiece32(header.second);
2433 } 2428 }
2434 } 2429 }
2435 2430
2436 } // namespace net 2431 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_headers_stream_test.cc ('k') | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698