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

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

Issue 170243005: Making sure that SpeechRecognitionDispatcherHost is not used after free (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed comments Created 6 years, 10 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/input_tag_speech_dispatcher_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/speech/input_tag_speech_dispatcher_host.h
diff --git a/content/browser/speech/input_tag_speech_dispatcher_host.h b/content/browser/speech/input_tag_speech_dispatcher_host.h
index 0329ab6fcee4c0409460d88166cd0d5afb5c6168..4d5eb60bf170beb756a600a2fe2e00bcf8f9e2af 100644
--- a/content/browser/speech/input_tag_speech_dispatcher_host.h
+++ b/content/browser/speech/input_tag_speech_dispatcher_host.h
@@ -7,6 +7,7 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/speech_recognition_event_listener.h"
@@ -32,6 +33,8 @@ class CONTENT_EXPORT InputTagSpeechDispatcherHost
int render_process_id,
net::URLRequestContextGetter* url_request_context_getter);
+ base::WeakPtr<InputTagSpeechDispatcherHost> AsWeakPtr();
+
// SpeechRecognitionEventListener methods.
virtual void OnRecognitionStart(int session_id) OVERRIDE;
virtual void OnAudioStart(int session_id) OVERRIDE;
@@ -57,6 +60,8 @@ class CONTENT_EXPORT InputTagSpeechDispatcherHost
const IPC::Message& message,
BrowserThread::ID* thread) OVERRIDE;
+ virtual void OnChannelClosing() OVERRIDE;
+
private:
virtual ~InputTagSpeechDispatcherHost();
@@ -75,6 +80,11 @@ class CONTENT_EXPORT InputTagSpeechDispatcherHost
int render_process_id_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
+ // Used for posting asynchronous tasks (on the IO thread) without worrying
+ // about this class being destroyed in the meanwhile (due to browser shutdown)
+ // since tasks pending on a destroyed WeakPtr are automatically discarded.
+ base::WeakPtrFactory<InputTagSpeechDispatcherHost> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(InputTagSpeechDispatcherHost);
};
« no previous file with comments | « no previous file | content/browser/speech/input_tag_speech_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698