| 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "net/base/big_endian.h" | 10 #include "net/base/big_endian.h" |
| 11 #include "net/base/io_buffer.h" |
| 11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 const uint8 kFinalBit = 0x80; | 16 const uint8 kFinalBit = 0x80; |
| 16 const uint8 kReserved1Bit = 0x40; | 17 const uint8 kReserved1Bit = 0x40; |
| 17 const uint8 kReserved2Bit = 0x20; | 18 const uint8 kReserved2Bit = 0x20; |
| 18 const uint8 kReserved3Bit = 0x10; | 19 const uint8 kReserved3Bit = 0x10; |
| 19 const uint8 kOpCodeMask = 0xF; | 20 const uint8 kOpCodeMask = 0xF; |
| 20 const uint8 kMaskBit = 0x80; | 21 const uint8 kMaskBit = 0x80; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // (4 or 8 bytes), instead of XOR'ing every byte. | 146 // (4 or 8 bytes), instead of XOR'ing every byte. |
| 146 size_t masking_key_offset = frame_offset % kMaskingKeyLength; | 147 size_t masking_key_offset = frame_offset % kMaskingKeyLength; |
| 147 for (int i = 0; i < data_size; ++i) { | 148 for (int i = 0; i < data_size; ++i) { |
| 148 data[i] ^= masking_key.key[masking_key_offset++]; | 149 data[i] ^= masking_key.key[masking_key_offset++]; |
| 149 if (masking_key_offset == kMaskingKeyLength) | 150 if (masking_key_offset == kMaskingKeyLength) |
| 150 masking_key_offset = 0; | 151 masking_key_offset = 0; |
| 151 } | 152 } |
| 152 } | 153 } |
| 153 | 154 |
| 154 } // namespace net | 155 } // namespace net |
| OLD | NEW |