Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: content/browser/speech/audio_buffer.h

Issue 9861019: Speech refactoring: Turned AudioChunk into a refcounted class (CL1.4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed according to Hans review. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/speech/audio_buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fffba8c3fc90f846cfb8e6cf81b1681bd9964170 100644
--- a/content/browser/speech/audio_buffer.h
+++ b/content/browser/speech/audio_buffer.h
@@ -6,17 +6,18 @@
#define CONTENT_BROWSER_SPEECH_AUDIO_BUFFER_H_
#pragma once
+#include <deque>
#include <string>
#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> {
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_;
« no previous file with comments | « no previous file | content/browser/speech/audio_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698