Chromium Code Reviews| Index: content/browser/speech/audio_buffer.cc |
| diff --git a/content/browser/speech/audio_buffer.cc b/content/browser/speech/audio_buffer.cc |
| index 5b887d74c333ddd7d7ace8f4e8c27f2c83e246ef..6a9f0e4d3d06fb46deea92be11fd63f8df64e316 100644 |
| --- a/content/browser/speech/audio_buffer.cc |
| +++ b/content/browser/speech/audio_buffer.cc |
| @@ -52,21 +52,22 @@ AudioBuffer::~AudioBuffer() { |
| } |
| void AudioBuffer::Enqueue(const uint8* data, size_t length) { |
| - AudioChunk* chunk = new AudioChunk(data, length, bytes_per_sample_); |
| + scoped_refptr<AudioChunk> chunk( |
| + new AudioChunk(data, length, bytes_per_sample_)); |
| chunks_.push_back(chunk); |
|
hans
2012/03/27 15:56:31
could we just do this on a single line?
chunks_.p
Primiano Tucci (use gerrit)
2012/03/27 16:51:24
Uh, right. It was a remainder of the old code :)
|
| } |
| -scoped_ptr<AudioChunk> AudioBuffer::DequeueSingleChunk() { |
| +scoped_refptr<AudioChunk> AudioBuffer::DequeueSingleChunk() { |
| DCHECK(!chunks_.empty()); |
| - AudioChunk* chunk = *chunks_.begin(); |
| - chunks_.weak_erase(chunks_.begin()); |
| - return scoped_ptr<AudioChunk>(chunk); |
| + scoped_refptr<AudioChunk> chunk(chunks_.front()); |
| + chunks_.pop_front(); |
| + return chunk; |
| } |
| -scoped_ptr<AudioChunk> AudioBuffer::DequeueAll() { |
| - AudioChunk* chunk = new AudioChunk(bytes_per_sample_); |
| +scoped_refptr<AudioChunk> AudioBuffer::DequeueAll() { |
| + scoped_refptr<AudioChunk> chunk(new AudioChunk(bytes_per_sample_)); |
| size_t resulting_length = 0; |
| - ChunksContainer::const_iterator it; |
| + ChunksContainer::iterator it; |
|
hans
2012/03/27 15:56:31
hmm, why isn't it a const_iterator anymore?
Primiano Tucci (use gerrit)
2012/03/27 16:51:24
Ah right. I tried to use a std::queue at beginning
|
| // In order to improve performance, calulate in advance the total length |
| // and then copy the chunks. |
| for (it = chunks_.begin(); it != chunks_.end(); ++it) { |
| @@ -77,11 +78,11 @@ scoped_ptr<AudioChunk> AudioBuffer::DequeueAll() { |
| chunk->data_string_.append((*it)->data_string_); |
| } |
| Clear(); |
| - return scoped_ptr<AudioChunk>(chunk); |
| + return chunk; |
| } |
| void AudioBuffer::Clear() { |
| - chunks_.erase(chunks_.begin(), chunks_.end()); |
| + chunks_.clear(); |
| } |
| bool AudioBuffer::IsEmpty() const { |