Index: content/browser/speech/speech_recognition_dispatcher_host.h |
diff --git a/content/browser/speech/speech_recognition_dispatcher_host.h b/content/browser/speech/speech_recognition_dispatcher_host.h |
index 34b333207e8e51f6dae30d29c513003fb873c947..5e0aac28bc4fcd5e96fd50312cd9810f56f0b7a5 100644 |
--- a/content/browser/speech/speech_recognition_dispatcher_host.h |
+++ b/content/browser/speech/speech_recognition_dispatcher_host.h |
@@ -5,31 +5,38 @@ |
#ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ |
#define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ |
+#include <map> |
+ |
#include "base/memory/scoped_ptr.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/web_contents_observer.h" |
#include "content/public/browser/speech_recognition_event_listener.h" |
-#include "net/url_request/url_request_context_getter.h" |
struct SpeechRecognitionHostMsg_StartRequest_Params; |
+namespace net { |
+class URLRequestContextGetter; |
+} // namespace net |
+ |
namespace content { |
class SpeechRecognitionManager; |
+class WebContents; |
struct SpeechRecognitionResult; |
+struct SpeechRecognitionSessionContext; |
+struct SpeechRecognitionSessionConfig; |
// SpeechRecognitionDispatcherHost is a delegate for Speech API messages used by |
-// RenderMessageFilter. Basically it acts as a proxy, relaying the events coming |
-// from the SpeechRecognitionManager to IPC messages (and vice versa). |
-// It's the complement of SpeechRecognitionDispatcher (owned by RenderView). |
+// BrowserMessageFilter. Basically it acts as a proxy, relaying the events |
+// coming from the SpeechRecognitionManager to IPC messages (and vice versa). |
+// It's the complement of SpeechRecognitionDispatcher (owned by RenderFrame). |
class CONTENT_EXPORT SpeechRecognitionDispatcherHost |
: public BrowserMessageFilter, |
public SpeechRecognitionEventListener { |
public: |
- SpeechRecognitionDispatcherHost( |
- int render_process_id, |
- net::URLRequestContextGetter* context_getter); |
+ explicit SpeechRecognitionDispatcherHost(int render_process_id); |
base::WeakPtr<SpeechRecognitionDispatcherHost> AsWeakPtr(); |
@@ -51,32 +58,39 @@ class CONTENT_EXPORT SpeechRecognitionDispatcherHost |
// BrowserMessageFilter implementation. |
void OnDestruct() const override; |
- bool OnMessageReceived(const IPC::Message& message) override; |
+ void OnChannelClosing() override; |
void OverrideThreadForMessage(const IPC::Message& message, |
BrowserThread::ID* thread) override; |
- |
- void OnChannelClosing() override; |
+ bool OnMessageReceived(const IPC::Message& message) override; |
private: |
friend class base::DeleteHelper<SpeechRecognitionDispatcherHost>; |
friend class BrowserThread; |
+ class FrameDeletedObserver; |
+ |
~SpeechRecognitionDispatcherHost() override; |
void OnStartRequest( |
const SpeechRecognitionHostMsg_StartRequest_Params& params); |
- void OnStartRequestOnIO( |
- int embedder_render_process_id, |
- int embedder_render_view_id, |
+ void StartSession( |
const SpeechRecognitionHostMsg_StartRequest_Params& params, |
- int params_render_frame_id, |
+ const SpeechRecognitionSessionContext& context, |
+ net::URLRequestContextGetter* url_request_context_getter, |
bool filter_profanities); |
- void OnAbortRequest(int render_view_id, int request_id); |
- void OnStopCaptureRequest(int render_view_id, int request_id); |
- void OnAbortAllRequests(int render_view_id); |
+ void OnAbortRequest(int render_frame_id, int request_id); |
+ void OnStopCaptureRequest(int render_frame_id, int request_id); |
+ void OnAbortAllRequests(int render_frame_id); |
+ |
+ // These methods must be called on the UI thread. |
+ void CreateObserverFor(WebContents* web_contents); |
+ void RemoveObserverFor(WebContents* web_contents); |
+ void AbortAllRequestsFromUI(int render_frame_id); |
int render_process_id_; |
- scoped_refptr<net::URLRequestContextGetter> context_getter_; |
+ |
+ using FrameDeletedObservers = std::map<WebContents*, FrameDeletedObserver*>; |
+ FrameDeletedObservers frame_deleted_observers_; |
// Used for posting asynchronous tasks (on the IO thread) without worrying |
// about this class being destroyed in the meanwhile (due to browser shutdown) |