OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/big_endian.h" | 10 #include "base/big_endian.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // GCC (and Clang) can transparently use vector ops. Only try to do this on | 20 // GCC (and Clang) can transparently use vector ops. Only try to do this on |
21 // architectures where we know it works, otherwise gcc will attempt to emulate | 21 // architectures where we know it works, otherwise gcc will attempt to emulate |
22 // the vector ops, which is unlikely to be efficient. | 22 // the vector ops, which is unlikely to be efficient. |
23 // TODO(ricea): Add ARCH_CPU_ARM_FAMILY when arm_neon=1 becomes the default. | 23 // TODO(ricea): Add ARCH_CPU_ARM_FAMILY when arm_neon=1 becomes the default. |
24 #if defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY) && !defined(OS_NACL) | 24 #if defined(COMPILER_GCC) && \ |
| 25 (defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY)) && \ |
| 26 !defined(OS_NACL) |
25 | 27 |
26 using PackedMaskType = uint32_t __attribute__((vector_size(16))); | 28 using PackedMaskType = uint32_t __attribute__((vector_size(16))); |
27 | 29 |
28 #else | 30 #else |
29 | 31 |
30 using PackedMaskType = size_t; | 32 using PackedMaskType = size_t; |
31 | 33 |
32 #endif // defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY) && | 34 #endif // defined(COMPILER_GCC) && |
| 35 // (defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY)) && |
33 // !defined(OS_NACL) | 36 // !defined(OS_NACL) |
34 | 37 |
35 const uint8_t kFinalBit = 0x80; | 38 const uint8_t kFinalBit = 0x80; |
36 const uint8_t kReserved1Bit = 0x40; | 39 const uint8_t kReserved1Bit = 0x40; |
37 const uint8_t kReserved2Bit = 0x20; | 40 const uint8_t kReserved2Bit = 0x20; |
38 const uint8_t kReserved3Bit = 0x10; | 41 const uint8_t kReserved3Bit = 0x10; |
39 const uint8_t kOpCodeMask = 0xF; | 42 const uint8_t kOpCodeMask = 0xF; |
40 const uint8_t kMaskBit = 0x80; | 43 const uint8_t kMaskBit = 0x80; |
41 const uint64_t kMaxPayloadLengthWithoutExtendedLengthField = 125; | 44 const uint64_t kMaxPayloadLengthWithoutExtendedLengthField = 125; |
42 const uint64_t kPayloadLengthWithTwoByteExtendedLengthField = 126; | 45 const uint64_t kPayloadLengthWithTwoByteExtendedLengthField = 126; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 246 } |
244 | 247 |
245 MaskWebSocketFramePayloadByBytes( | 248 MaskWebSocketFramePayloadByBytes( |
246 masking_key, | 249 masking_key, |
247 (frame_offset + (aligned_end - data)) % kMaskingKeyLength, | 250 (frame_offset + (aligned_end - data)) % kMaskingKeyLength, |
248 aligned_end, | 251 aligned_end, |
249 end); | 252 end); |
250 } | 253 } |
251 | 254 |
252 } // namespace net | 255 } // namespace net |
OLD | NEW |