| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ |
| 6 #define CHROME_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ | 6 #define CHROME_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "chrome/browser/speech/speech_input_manager.h" | 11 #include "chrome/browser/speech/speech_input_manager.h" |
| 12 #include "ipc/ipc_message.h" | 12 #include "ipc/ipc_message.h" |
| 13 | 13 |
| 14 namespace speech_input { | 14 namespace speech_input { |
| 15 | 15 |
| 16 // SpeechInputDispatcherHost is a delegate for Speech API messages used by | 16 // SpeechInputDispatcherHost is a delegate for Speech API messages used by |
| 17 // ResourceMessageFilter. | 17 // ResourceMessageFilter. |
| 18 // It's the complement of SpeechInputDispatcher (owned by RenderView). | 18 // It's the complement of SpeechInputDispatcher (owned by RenderView). |
| 19 class SpeechInputDispatcherHost | 19 class SpeechInputDispatcherHost |
| 20 : public base::RefCountedThreadSafe<SpeechInputDispatcherHost>, | 20 : public base::RefCountedThreadSafe<SpeechInputDispatcherHost>, |
| 21 public SpeechInputManager::Delegate { | 21 public SpeechInputManager::Delegate { |
| 22 public: | 22 public: |
| 23 explicit SpeechInputDispatcherHost(int resource_message_filter_process_id); | 23 explicit SpeechInputDispatcherHost(int resource_message_filter_process_id); |
| 24 | 24 |
| 25 // SpeechInputManager::Delegate methods. | 25 // SpeechInputManager::Delegate methods. |
| 26 void SetRecognitionResult(int caller_id, | 26 virtual void SetRecognitionResult(int caller_id, |
| 27 const SpeechInputResultArray& result); | 27 const SpeechInputResultArray& result); |
| 28 void DidCompleteRecording(int caller_id); | 28 virtual void DidCompleteRecording(int caller_id); |
| 29 void DidCompleteRecognition(int caller_id); | 29 virtual void DidCompleteRecognition(int caller_id); |
| 30 | 30 |
| 31 // Called to possibly handle the incoming IPC message. Returns true if | 31 // Called to possibly handle the incoming IPC message. Returns true if |
| 32 // handled. | 32 // handled. |
| 33 bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok); | 33 bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok); |
| 34 | 34 |
| 35 // Singleton accessor setter useful for tests. | 35 // Singleton accessor setter useful for tests. |
| 36 static void set_manager_accessor(SpeechInputManager::AccessorMethod* method) { | 36 static void set_manager_accessor(SpeechInputManager::AccessorMethod* method) { |
| 37 manager_accessor_ = method; | 37 manager_accessor_ = method; |
| 38 } | 38 } |
| 39 | 39 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 59 SpeechInputCallers* callers_; // weak reference to a singleton. | 59 SpeechInputCallers* callers_; // weak reference to a singleton. |
| 60 | 60 |
| 61 static SpeechInputManager::AccessorMethod* manager_accessor_; | 61 static SpeechInputManager::AccessorMethod* manager_accessor_; |
| 62 | 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(SpeechInputDispatcherHost); | 63 DISALLOW_COPY_AND_ASSIGN(SpeechInputDispatcherHost); |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 } // namespace speech_input | 66 } // namespace speech_input |
| 67 | 67 |
| 68 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ | 68 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ |
| OLD | NEW |