| 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" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 scoped_ptr<Chunk> chunk(*chunks_.begin()); | 103 scoped_ptr<Chunk> chunk(*chunks_.begin()); |
| 104 chunks_.weak_erase(chunks_.begin()); | 104 chunks_.weak_erase(chunks_.begin()); |
| 105 DCHECK_EQ(chunk->header.size(), kHeaderLength); | 105 DCHECK_EQ(chunk->header.size(), kHeaderLength); |
| 106 DCHECK_EQ(chunk->content->size(), chunk->ExpectedContentLength()); | 106 DCHECK_EQ(chunk->content->size(), chunk->ExpectedContentLength()); |
| 107 total_bytes_stored_ -= chunk->content->size(); | 107 total_bytes_stored_ -= chunk->content->size(); |
| 108 total_bytes_stored_ -= kHeaderLength; | 108 total_bytes_stored_ -= kHeaderLength; |
| 109 return chunk->content.Pass(); | 109 return chunk->content.Pass(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void ChunkedByteBuffer::Clear() { | 112 void ChunkedByteBuffer::Clear() { |
| 113 chunks_.reset(); | 113 chunks_.clear(); |
| 114 partial_chunk_.reset(new Chunk()); | 114 partial_chunk_.reset(new Chunk()); |
| 115 total_bytes_stored_ = 0; | 115 total_bytes_stored_ = 0; |
| 116 } | 116 } |
| 117 | 117 |
| 118 ChunkedByteBuffer::Chunk::Chunk() | 118 ChunkedByteBuffer::Chunk::Chunk() |
| 119 : content(new std::vector<uint8>()) { | 119 : content(new std::vector<uint8>()) { |
| 120 } | 120 } |
| 121 | 121 |
| 122 ChunkedByteBuffer::Chunk::~Chunk() { | 122 ChunkedByteBuffer::Chunk::~Chunk() { |
| 123 } | 123 } |
| 124 | 124 |
| 125 size_t ChunkedByteBuffer::Chunk::ExpectedContentLength() const { | 125 size_t ChunkedByteBuffer::Chunk::ExpectedContentLength() const { |
| 126 DCHECK_EQ(header.size(), kHeaderLength); | 126 DCHECK_EQ(header.size(), kHeaderLength); |
| 127 return static_cast<size_t>(ReadBigEndian32(&header[0])); | 127 return static_cast<size_t>(ReadBigEndian32(&header[0])); |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace speech | 130 } // namespace speech |
| OLD | NEW |