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

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

Issue 1471073010: Removed unused include of winsock.h/inet.h from sys_byteorder.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include inet.h for things other than byte-swap Created 5 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_frame_reader_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 <iterator> 10 #include <iterator>
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 previous_state_ = state_; \ 132 previous_state_ = state_; \
133 state_ = newstate; \ 133 state_ = newstate; \
134 } while (false) 134 } while (false)
135 #endif 135 #endif
136 136
137 SettingsFlagsAndId SettingsFlagsAndId::FromWireFormat( 137 SettingsFlagsAndId SettingsFlagsAndId::FromWireFormat(
138 SpdyMajorVersion version, uint32 wire) { 138 SpdyMajorVersion version, uint32 wire) {
139 if (version < SPDY3) { 139 if (version < SPDY3) {
140 ConvertFlagsAndIdForSpdy2(&wire); 140 ConvertFlagsAndIdForSpdy2(&wire);
141 } 141 }
142 return SettingsFlagsAndId(ntohl(wire) >> 24, ntohl(wire) & 0x00ffffff); 142 return SettingsFlagsAndId(base::NetToHost32(wire) >> 24,
143 base::NetToHost32(wire) & 0x00ffffff);
143 } 144 }
144 145
145 SettingsFlagsAndId::SettingsFlagsAndId(uint8 flags, uint32 id) 146 SettingsFlagsAndId::SettingsFlagsAndId(uint8 flags, uint32 id)
146 : flags_(flags), id_(id & 0x00ffffff) { 147 : flags_(flags), id_(id & 0x00ffffff) {
147 LOG_IF(DFATAL, id > (1u << 24)) << "SPDY setting ID too large: " << id; 148 LOG_IF(DFATAL, id > (1u << 24)) << "SPDY setting ID too large: " << id;
148 } 149 }
149 150
150 uint32 SettingsFlagsAndId::GetWireFormat(SpdyMajorVersion version) 151 uint32 SettingsFlagsAndId::GetWireFormat(SpdyMajorVersion version)
151 const { 152 const {
152 uint32 wire = htonl(id_ & 0x00ffffff) | htonl(flags_ << 24); 153 uint32 wire =
154 base::HostToNet32(id_ & 0x00ffffff) | base::HostToNet32(flags_ << 24);
153 if (version < SPDY3) { 155 if (version < SPDY3) {
154 ConvertFlagsAndIdForSpdy2(&wire); 156 ConvertFlagsAndIdForSpdy2(&wire);
155 } 157 }
156 return wire; 158 return wire;
157 } 159 }
158 160
159 // SPDY 2 had a bug in it with respect to byte ordering of id/flags field. 161 // SPDY 2 had a bug in it with respect to byte ordering of id/flags field.
160 // This method is used to preserve buggy behavior and works on both 162 // This method is used to preserve buggy behavior and works on both
161 // little-endian and big-endian hosts. 163 // little-endian and big-endian hosts.
162 // This method is also bidirectional (can be used to translate SPDY 2 to SPDY 3 164 // This method is also bidirectional (can be used to translate SPDY 2 to SPDY 3
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 uint32 value; 1796 uint32 value;
1795 1797
1796 // Extract fields. 1798 // Extract fields.
1797 // Maintain behavior of old SPDY 2 bug with byte ordering of flags/id. 1799 // Maintain behavior of old SPDY 2 bug with byte ordering of flags/id.
1798 if (protocol_version() <= SPDY3) { 1800 if (protocol_version() <= SPDY3) {
1799 const uint32 id_and_flags_wire = *(reinterpret_cast<const uint32*>(data)); 1801 const uint32 id_and_flags_wire = *(reinterpret_cast<const uint32*>(data));
1800 SettingsFlagsAndId id_and_flags = 1802 SettingsFlagsAndId id_and_flags =
1801 SettingsFlagsAndId::FromWireFormat(protocol_version(), id_and_flags_wire); 1803 SettingsFlagsAndId::FromWireFormat(protocol_version(), id_and_flags_wire);
1802 id_field = id_and_flags.id(); 1804 id_field = id_and_flags.id();
1803 flags = id_and_flags.flags(); 1805 flags = id_and_flags.flags();
1804 value = ntohl(*(reinterpret_cast<const uint32*>(data + 4))); 1806 value = base::NetToHost32(*(reinterpret_cast<const uint32*>(data + 4)));
1805 } else { 1807 } else {
1806 id_field = ntohs(*(reinterpret_cast<const uint16*>(data))); 1808 id_field = base::NetToHost16(*(reinterpret_cast<const uint16*>(data)));
1807 value = ntohl(*(reinterpret_cast<const uint32*>(data + 2))); 1809 value = base::NetToHost32(*(reinterpret_cast<const uint32*>(data + 2)));
1808 } 1810 }
1809 1811
1810 // Validate id. 1812 // Validate id.
1811 if (!SpdyConstants::IsValidSettingId(protocol_version(), id_field)) { 1813 if (!SpdyConstants::IsValidSettingId(protocol_version(), id_field)) {
1812 DLOG(WARNING) << "Unknown SETTINGS ID: " << id_field; 1814 DLOG(WARNING) << "Unknown SETTINGS ID: " << id_field;
1813 if (protocol_version() <= SPDY3) { 1815 if (protocol_version() <= SPDY3) {
1814 return false; 1816 return false;
1815 } else { 1817 } else {
1816 // In HTTP2 we ignore unknown settings for extensibility. 1818 // In HTTP2 we ignore unknown settings for extensibility.
1817 return true; 1819 return true;
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
3223 #else 3225 #else
3224 WriteHeaderBlockToZ(&frame.header_block(), compressor); 3226 WriteHeaderBlockToZ(&frame.header_block(), compressor);
3225 #endif // defined(USE_SYSTEM_ZLIB) 3227 #endif // defined(USE_SYSTEM_ZLIB)
3226 3228
3227 int compressed_size = compressed_max_size - compressor->avail_out; 3229 int compressed_size = compressed_max_size - compressor->avail_out;
3228 builder->Seek(compressed_size); 3230 builder->Seek(compressed_size);
3229 builder->RewriteLength(*this); 3231 builder->RewriteLength(*this);
3230 } 3232 }
3231 3233
3232 } // namespace net 3234 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_frame_reader_test.cc ('k') | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698