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

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

Issue 10399025: Moved instantiation of SpeechRecognitionManager inside browser_main_loop, instead of Singleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed according to Hans review + nits. Created 8 years, 7 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
Index: content/browser/speech/speech_recognition_manager_impl.h
diff --git a/content/browser/speech/speech_recognition_manager_impl.h b/content/browser/speech/speech_recognition_manager_impl.h
index 6088a5a18228bcb95d0c76dc89c3ab8aff43f7fe..72feaf06868f759b79bef7b55d1bb525863151db 100644
--- a/content/browser/speech/speech_recognition_manager_impl.h
+++ b/content/browser/speech/speech_recognition_manager_impl.h
@@ -20,6 +20,7 @@
#include "content/public/common/speech_recognition_error.h"
namespace content {
+class BrowserMainLoop;
class SpeechRecognitionManagerDelegate;
}
@@ -51,6 +52,8 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl :
public NON_EXPORTED_BASE(content::SpeechRecognitionManager),
public content::SpeechRecognitionEventListener {
public:
+ // Returns the current SpeechRecognitionManagerImpl. Can be called only after
+ // the RecognitionMnager has been created (by BrowserMainLoop).
static SpeechRecognitionManagerImpl* GetInstance();
// SpeechRecognitionManager implementation.
@@ -90,8 +93,9 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl :
float noise_volume) OVERRIDE;
protected:
- // Private constructor to enforce singleton.
- friend struct DefaultSingletonTraits<SpeechRecognitionManagerImpl>;
+ // BrowserMainLoop is the only one allowed to istantiate and free us.
+ friend class content::BrowserMainLoop;
+ friend class scoped_ptr<SpeechRecognitionManagerImpl>; // Needed for dtor.
SpeechRecognitionManagerImpl();
virtual ~SpeechRecognitionManagerImpl();
@@ -158,7 +162,7 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl :
int session_id_capturing_audio_;
int last_session_id_;
bool is_dispatching_event_;
- content::SpeechRecognitionManagerDelegate* delegate_;
+ scoped_ptr<content::SpeechRecognitionManagerDelegate> delegate_;
};
} // namespace speech

Powered by Google App Engine
This is Rietveld 408576698