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

Side by Side Diff: net/websockets/websocket_frame.cc

Issue 826973002: replace COMPILE_ASSERT with static_assert in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply fixups Created 5 years, 11 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
« no previous file with comments | « net/websockets/websocket_channel.cc ('k') | net/websockets/websocket_frame_perftest.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/websockets/websocket_frame.h" 5 #include "net/websockets/websocket_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/big_endian.h" 10 #include "base/big_endian.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 DCHECK_GE(data_size, 0); 172 DCHECK_GE(data_size, 0);
173 173
174 // Most of the masking is done one word at a time, except for the beginning 174 // Most of the masking is done one word at a time, except for the beginning
175 // and the end of the buffer which may be unaligned. We use size_t to get the 175 // and the end of the buffer which may be unaligned. We use size_t to get the
176 // word size for this architecture. We require it be a multiple of 176 // word size for this architecture. We require it be a multiple of
177 // kMaskingKeyLength in size. 177 // kMaskingKeyLength in size.
178 typedef size_t PackedMaskType; 178 typedef size_t PackedMaskType;
179 PackedMaskType packed_mask_key = 0; 179 PackedMaskType packed_mask_key = 0;
180 static const size_t kPackedMaskKeySize = sizeof(packed_mask_key); 180 static const size_t kPackedMaskKeySize = sizeof(packed_mask_key);
181 COMPILE_ASSERT((kPackedMaskKeySize >= kMaskingKeyLength && 181 static_assert((kPackedMaskKeySize >= kMaskingKeyLength &&
182 kPackedMaskKeySize % kMaskingKeyLength == 0), 182 kPackedMaskKeySize % kMaskingKeyLength == 0),
183 word_size_is_not_multiple_of_mask_length); 183 "word size is not a multiple of mask length");
184 char* const end = data + data_size; 184 char* const end = data + data_size;
185 // If the buffer is too small for the vectorised version to be useful, revert 185 // If the buffer is too small for the vectorised version to be useful, revert
186 // to the byte-at-a-time implementation early. 186 // to the byte-at-a-time implementation early.
187 if (data_size <= static_cast<int>(kPackedMaskKeySize * 2)) { 187 if (data_size <= static_cast<int>(kPackedMaskKeySize * 2)) {
188 MaskWebSocketFramePayloadByBytes( 188 MaskWebSocketFramePayloadByBytes(
189 masking_key, frame_offset % kMaskingKeyLength, data, end); 189 masking_key, frame_offset % kMaskingKeyLength, data, end);
190 return; 190 return;
191 } 191 }
192 const size_t data_modulus = 192 const size_t data_modulus =
193 reinterpret_cast<size_t>(data) % kPackedMaskKeySize; 193 reinterpret_cast<size_t>(data) % kPackedMaskKeySize;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 230 }
231 231
232 MaskWebSocketFramePayloadByBytes( 232 MaskWebSocketFramePayloadByBytes(
233 masking_key, 233 masking_key,
234 (frame_offset + (aligned_end - data)) % kMaskingKeyLength, 234 (frame_offset + (aligned_end - data)) % kMaskingKeyLength,
235 aligned_end, 235 aligned_end,
236 end); 236 end);
237 } 237 }
238 238
239 } // namespace net 239 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_channel.cc ('k') | net/websockets/websocket_frame_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698