| 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 "content/browser/speech/chunked_byte_buffer.h" | 5 #include "content/browser/speech/chunked_byte_buffer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 static const size_t kHeaderLength = sizeof(uint32); | 15 static const size_t kHeaderLength = sizeof(uint32); |
| 16 | 16 |
| 17 COMPILE_ASSERT(sizeof(size_t) >= kHeaderLength, | 17 static_assert(sizeof(size_t) >= kHeaderLength, |
| 18 ChunkedByteBufferNotSupportedOnThisArchitecture); | 18 "chunked byte buffer not supported on this architecture"); |
| 19 | 19 |
| 20 uint32 ReadBigEndian32(const uint8* buffer) { | 20 uint32 ReadBigEndian32(const uint8* buffer) { |
| 21 return (static_cast<uint32>(buffer[3])) | | 21 return (static_cast<uint32>(buffer[3])) | |
| 22 (static_cast<uint32>(buffer[2]) << 8) | | 22 (static_cast<uint32>(buffer[2]) << 8) | |
| 23 (static_cast<uint32>(buffer[1]) << 16) | | 23 (static_cast<uint32>(buffer[1]) << 16) | |
| 24 (static_cast<uint32>(buffer[0]) << 24); | 24 (static_cast<uint32>(buffer[0]) << 24); |
| 25 } | 25 } |
| 26 | 26 |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 ChunkedByteBuffer::Chunk::~Chunk() { | 128 ChunkedByteBuffer::Chunk::~Chunk() { |
| 129 } | 129 } |
| 130 | 130 |
| 131 size_t ChunkedByteBuffer::Chunk::ExpectedContentLength() const { | 131 size_t ChunkedByteBuffer::Chunk::ExpectedContentLength() const { |
| 132 DCHECK_EQ(header.size(), kHeaderLength); | 132 DCHECK_EQ(header.size(), kHeaderLength); |
| 133 return static_cast<size_t>(ReadBigEndian32(&header[0])); | 133 return static_cast<size_t>(ReadBigEndian32(&header[0])); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace content | 136 } // namespace content |
| OLD | NEW |