Chromium Code Reviews| Index: content/browser/speech/audio_buffer.h |
| diff --git a/content/browser/speech/audio_buffer.h b/content/browser/speech/audio_buffer.h |
| index c1d5103dfd537499ba6dcb1d3bc6696fce456ed5..fa3b940e569c9a1485425011c228a14e71b21d1b 100644 |
| --- a/content/browser/speech/audio_buffer.h |
| +++ b/content/browser/speech/audio_buffer.h |
| @@ -7,16 +7,17 @@ |
| #pragma once |
| #include <string> |
| +#include <deque> |
|
hans
2012/03/27 15:56:31
nit: header includes should be sorted alphabetical
Primiano Tucci (use gerrit)
2012/03/27 16:51:24
Oops.
|
| #include "base/basictypes.h" |
| -#include "base/memory/scoped_ptr.h" |
| -#include "base/memory/scoped_vector.h" |
| +#include "base/memory/ref_counted.h" |
| #include "content/common/content_export.h" |
| namespace speech { |
| // Models a chunk derived from an AudioBuffer. |
| -class CONTENT_EXPORT AudioChunk { |
| +class CONTENT_EXPORT AudioChunk : |
| + public base::RefCountedThreadSafe<AudioChunk> { |
|
hans
2012/03/27 15:56:31
just to double check: it needs to be thread safe b
Primiano Tucci (use gerrit)
2012/03/27 16:51:24
Right, it might happen that it is released and acq
|
| public: |
| explicit AudioChunk(int bytes_per_sample); |
| AudioChunk(const uint8* data, size_t length, int bytes_per_sample); |
| @@ -30,6 +31,9 @@ class CONTENT_EXPORT AudioChunk { |
| friend class AudioBuffer; |
| private: |
| + ~AudioChunk() {} |
| + friend class base::RefCountedThreadSafe<AudioChunk>; |
| + |
| std::string data_string_; |
| int bytes_per_sample_; |
| @@ -49,10 +53,10 @@ class AudioBuffer { |
| // Dequeues, in FIFO order, a single chunk respecting the length of the |
| // corresponding Enqueue call (in a nutshell: multiple Enqueue calls followed |
| // by Dequeue calls will return the individual chunks without merging them). |
| - scoped_ptr<AudioChunk> DequeueSingleChunk(); |
| + scoped_refptr<AudioChunk> DequeueSingleChunk(); |
| // Dequeues all previously enqueued chunks, merging them in a single chunk. |
| - scoped_ptr<AudioChunk> DequeueAll(); |
| + scoped_refptr<AudioChunk> DequeueAll(); |
| // Removes and frees all the enqueued chunks. |
| void Clear(); |
| @@ -61,7 +65,7 @@ class AudioBuffer { |
| bool IsEmpty() const; |
| private: |
| - typedef ScopedVector<AudioChunk> ChunksContainer; |
| + typedef std::deque<scoped_refptr<AudioChunk> > ChunksContainer; |
| ChunksContainer chunks_; |
| int bytes_per_sample_; |