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

Side by Side Diff: chrome/renderer/tts_dispatcher.h

Issue 15031002: Implement TTS dispatcher using RenderProcessObserver instead of MessageFilter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/renderer/tts_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_RENDERER_TTS_DISPATCHER_H_ 5 #ifndef CHROME_RENDERER_TTS_DISPATCHER_H_
6 #define CHROME_RENDERER_TTS_DISPATCHER_H_ 6 #define CHROME_RENDERER_TTS_DISPATCHER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
11 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
12 #include "content/public/renderer/render_view.h" 13 #include "content/public/renderer/render_process_observer.h"
13 #include "ipc/ipc_channel_proxy.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebSpeechSynthesize r.h" 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebSpeechSynthesize r.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebSpeechSynthesize rClient.h" 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebSpeechSynthesize rClient.h"
16 16
17 class RenderViewImpl; 17 namespace IPC {
18 class Message;
19 }
20
18 struct TtsVoice; 21 struct TtsVoice;
19 22
20 // TtsDispatcher is a delegate for methods used by WebKit for 23 // TtsDispatcher is a delegate for methods used by WebKit for
21 // speech synthesis APIs. It's the complement of 24 // speech synthesis APIs. It's the complement of
22 // TtsDispatcherHost (owned by RenderViewHost). 25 // TtsDispatcherHost (owned by RenderViewHost).
23 class TtsDispatcher 26 class TtsDispatcher
24 : public WebKit::WebSpeechSynthesizer, 27 : public WebKit::WebSpeechSynthesizer,
25 public IPC::ChannelProxy::MessageFilter { 28 public content::RenderProcessObserver {
26 public: 29 public:
27 explicit TtsDispatcher(WebKit::WebSpeechSynthesizerClient* client); 30 explicit TtsDispatcher(WebKit::WebSpeechSynthesizerClient* client);
28 31
29 private: 32 private:
30 virtual ~TtsDispatcher(); 33 virtual ~TtsDispatcher();
31 34
32 // IPC::ChannelProxy::MessageFilter override. 35 // RenderProcessObserver override.
33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 36 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
34 37
35 // WebKit::WebSpeechSynthesizer implementation. 38 // WebKit::WebSpeechSynthesizer implementation.
36 virtual void updateVoiceList() OVERRIDE; 39 virtual void updateVoiceList() OVERRIDE;
37 virtual void speak(const WebKit::WebSpeechSynthesisUtterance& utterance) 40 virtual void speak(const WebKit::WebSpeechSynthesisUtterance& utterance)
38 OVERRIDE; 41 OVERRIDE;
39 virtual void pause() OVERRIDE; 42 virtual void pause() OVERRIDE;
40 virtual void resume() OVERRIDE; 43 virtual void resume() OVERRIDE;
41 virtual void cancel() OVERRIDE; 44 virtual void cancel() OVERRIDE;
42 45
43 WebKit::WebSpeechSynthesisUtterance FindUtterance(int utterance_id); 46 WebKit::WebSpeechSynthesisUtterance FindUtterance(int utterance_id);
44 47
45 void OnSetVoiceList(const std::vector<TtsVoice>& voices); 48 void OnSetVoiceList(const std::vector<TtsVoice>& voices);
46 void OnDidStartSpeaking(int utterance_id); 49 void OnDidStartSpeaking(int utterance_id);
47 void OnDidFinishSpeaking(int utterance_id); 50 void OnDidFinishSpeaking(int utterance_id);
48 void OnDidPauseSpeaking(int utterance_id); 51 void OnDidPauseSpeaking(int utterance_id);
49 void OnDidResumeSpeaking(int utterance_id); 52 void OnDidResumeSpeaking(int utterance_id);
50 void OnWordBoundary(int utterance_id, int char_index); 53 void OnWordBoundary(int utterance_id, int char_index);
51 void OnSentenceBoundary(int utterance_id, int char_index); 54 void OnSentenceBoundary(int utterance_id, int char_index);
52 void OnMarkerEvent(int utterance_id, int char_index); 55 void OnMarkerEvent(int utterance_id, int char_index);
53 void OnWasInterrupted(int utterance_id); 56 void OnWasInterrupted(int utterance_id);
54 void OnWasCancelled(int utterance_id); 57 void OnWasCancelled(int utterance_id);
55 void OnSpeakingErrorOccurred(int utterance_id, 58 void OnSpeakingErrorOccurred(int utterance_id,
56 const std::string& error_message); 59 const std::string& error_message);
57 60
58 // The WebKit client class that we use to send events back to the JS world. 61 // The WebKit client class that we use to send events back to the JS world.
59 // Weak reference, this will be valid as long as this object exists. 62 // Weak reference, this will be valid as long as this object exists.
60 WebKit::WebSpeechSynthesizerClient* synthesizer_client_; 63 WebKit::WebSpeechSynthesizerClient* synthesizer_client_;
61 64
62 // Message loop for the main render thread. Utilized to
63 // ensure that callbacks into WebKit happen on the main thread
64 // instead of the originating IO thread.
65 scoped_refptr<base::MessageLoopProxy> main_loop_;
66
67 // Next utterance id, used to map response IPCs to utterance objects. 65 // Next utterance id, used to map response IPCs to utterance objects.
68 static int next_utterance_id_; 66 static int next_utterance_id_;
69 67
70 // Map from id to utterance objects. 68 // Map from id to utterance objects.
71 base::hash_map<int, WebKit::WebSpeechSynthesisUtterance> utterance_id_map_; 69 base::hash_map<int, WebKit::WebSpeechSynthesisUtterance> utterance_id_map_;
72 70
73 DISALLOW_COPY_AND_ASSIGN(TtsDispatcher); 71 DISALLOW_COPY_AND_ASSIGN(TtsDispatcher);
74 }; 72 };
75 73
76 #endif // CHROME_RENDERER_TTS_DISPATCHER_H_ 74 #endif // CHROME_RENDERER_TTS_DISPATCHER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/tts_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698