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

Side by Side Diff: chrome/browser/speech/speech_input_dispatcher_host.h

Issue 5711001: Add a new GetInstance() method for remaining files with singleton classes under chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 class SpeechInputCallers;
24
23 explicit SpeechInputDispatcherHost(int resource_message_filter_process_id); 25 explicit SpeechInputDispatcherHost(int resource_message_filter_process_id);
24 26
25 // SpeechInputManager::Delegate methods. 27 // SpeechInputManager::Delegate methods.
26 virtual void SetRecognitionResult(int caller_id, 28 virtual void SetRecognitionResult(int caller_id,
27 const SpeechInputResultArray& result); 29 const SpeechInputResultArray& result);
28 virtual void DidCompleteRecording(int caller_id); 30 virtual void DidCompleteRecording(int caller_id);
29 virtual void DidCompleteRecognition(int caller_id); 31 virtual void DidCompleteRecognition(int caller_id);
30 32
31 // Called to possibly handle the incoming IPC message. Returns true if 33 // Called to possibly handle the incoming IPC message. Returns true if
32 // handled. 34 // handled.
33 bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok); 35 bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok);
34 36
35 // Singleton accessor setter useful for tests. 37 // Singleton accessor setter useful for tests.
36 static void set_manager_accessor(SpeechInputManager::AccessorMethod* method) { 38 static void set_manager_accessor(SpeechInputManager::AccessorMethod* method) {
37 manager_accessor_ = method; 39 manager_accessor_ = method;
38 } 40 }
39 41
40 private: 42 private:
41 class SpeechInputCallers;
42 friend class base::RefCountedThreadSafe<SpeechInputDispatcherHost>; 43 friend class base::RefCountedThreadSafe<SpeechInputDispatcherHost>;
43 44
44 virtual ~SpeechInputDispatcherHost(); 45 virtual ~SpeechInputDispatcherHost();
45 void SendMessageToRenderView(IPC::Message* message, int render_view_id); 46 void SendMessageToRenderView(IPC::Message* message, int render_view_id);
46 47
47 void OnStartRecognition(int render_view_id, int request_id, 48 void OnStartRecognition(int render_view_id, int request_id,
48 const gfx::Rect& element_rect, 49 const gfx::Rect& element_rect,
49 const std::string& language, 50 const std::string& language,
50 const std::string& grammar); 51 const std::string& grammar);
51 void OnCancelRecognition(int render_view_id, int request_id); 52 void OnCancelRecognition(int render_view_id, int request_id);
52 void OnStopRecording(int render_view_id, int request_id); 53 void OnStopRecording(int render_view_id, int request_id);
53 54
54 // Returns the speech input manager to forward events to, creating one if 55 // Returns the speech input manager to forward events to, creating one if
55 // needed. 56 // needed.
56 SpeechInputManager* manager(); 57 SpeechInputManager* manager();
57 58
58 int resource_message_filter_process_id_; 59 int resource_message_filter_process_id_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698