/src/mozilla-central/dom/media/webspeech/synth/ipc/SpeechSynthesisChild.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
2 | | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
3 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | | |
5 | | #include "SpeechSynthesisChild.h" |
6 | | #include "nsSynthVoiceRegistry.h" |
7 | | |
8 | | namespace mozilla { |
9 | | namespace dom { |
10 | | |
11 | | SpeechSynthesisChild::SpeechSynthesisChild() |
12 | 0 | { |
13 | 0 | MOZ_COUNT_CTOR(SpeechSynthesisChild); |
14 | 0 | } |
15 | | |
16 | | SpeechSynthesisChild::~SpeechSynthesisChild() |
17 | 0 | { |
18 | 0 | MOZ_COUNT_DTOR(SpeechSynthesisChild); |
19 | 0 | } |
20 | | |
21 | | mozilla::ipc::IPCResult |
22 | | SpeechSynthesisChild::RecvInitialVoicesAndState(nsTArray<RemoteVoice>&& aVoices, |
23 | | nsTArray<nsString>&& aDefaults, |
24 | | const bool& aIsSpeaking) |
25 | 0 | { |
26 | 0 | nsSynthVoiceRegistry::RecvInitialVoicesAndState(aVoices, aDefaults, aIsSpeaking); |
27 | 0 | return IPC_OK(); |
28 | 0 | } |
29 | | |
30 | | mozilla::ipc::IPCResult |
31 | | SpeechSynthesisChild::RecvVoiceAdded(const RemoteVoice& aVoice) |
32 | 0 | { |
33 | 0 | nsSynthVoiceRegistry::RecvAddVoice(aVoice); |
34 | 0 | return IPC_OK(); |
35 | 0 | } |
36 | | |
37 | | mozilla::ipc::IPCResult |
38 | | SpeechSynthesisChild::RecvVoiceRemoved(const nsString& aUri) |
39 | 0 | { |
40 | 0 | nsSynthVoiceRegistry::RecvRemoveVoice(aUri); |
41 | 0 | return IPC_OK(); |
42 | 0 | } |
43 | | |
44 | | mozilla::ipc::IPCResult |
45 | | SpeechSynthesisChild::RecvSetDefaultVoice(const nsString& aUri, |
46 | | const bool& aIsDefault) |
47 | 0 | { |
48 | 0 | nsSynthVoiceRegistry::RecvSetDefaultVoice(aUri, aIsDefault); |
49 | 0 | return IPC_OK(); |
50 | 0 | } |
51 | | |
52 | | mozilla::ipc::IPCResult |
53 | | SpeechSynthesisChild::RecvIsSpeakingChanged(const bool& aIsSpeaking) |
54 | 0 | { |
55 | 0 | nsSynthVoiceRegistry::RecvIsSpeakingChanged(aIsSpeaking); |
56 | 0 | return IPC_OK(); |
57 | 0 | } |
58 | | |
59 | | mozilla::ipc::IPCResult |
60 | | SpeechSynthesisChild::RecvNotifyVoicesChanged() |
61 | 0 | { |
62 | 0 | nsSynthVoiceRegistry::RecvNotifyVoicesChanged(); |
63 | 0 | return IPC_OK(); |
64 | 0 | } |
65 | | |
66 | | PSpeechSynthesisRequestChild* |
67 | | SpeechSynthesisChild::AllocPSpeechSynthesisRequestChild(const nsString& aText, |
68 | | const nsString& aLang, |
69 | | const nsString& aUri, |
70 | | const float& aVolume, |
71 | | const float& aRate, |
72 | | const float& aPitch, |
73 | | const bool& aIsChrome) |
74 | 0 | { |
75 | 0 | MOZ_CRASH("Caller is supposed to manually construct a request!"); |
76 | 0 | } |
77 | | |
78 | | bool |
79 | | SpeechSynthesisChild::DeallocPSpeechSynthesisRequestChild(PSpeechSynthesisRequestChild* aActor) |
80 | 0 | { |
81 | 0 | delete aActor; |
82 | 0 | return true; |
83 | 0 | } |
84 | | |
85 | | // SpeechSynthesisRequestChild |
86 | | |
87 | | SpeechSynthesisRequestChild::SpeechSynthesisRequestChild(SpeechTaskChild* aTask) |
88 | | : mTask(aTask) |
89 | 0 | { |
90 | 0 | mTask->mActor = this; |
91 | 0 | MOZ_COUNT_CTOR(SpeechSynthesisRequestChild); |
92 | 0 | } |
93 | | |
94 | | SpeechSynthesisRequestChild::~SpeechSynthesisRequestChild() |
95 | 0 | { |
96 | 0 | MOZ_COUNT_DTOR(SpeechSynthesisRequestChild); |
97 | 0 | } |
98 | | |
99 | | mozilla::ipc::IPCResult |
100 | | SpeechSynthesisRequestChild::RecvOnStart(const nsString& aUri) |
101 | 0 | { |
102 | 0 | mTask->DispatchStartImpl(aUri); |
103 | 0 | return IPC_OK(); |
104 | 0 | } |
105 | | |
106 | | mozilla::ipc::IPCResult |
107 | | SpeechSynthesisRequestChild::RecvOnEnd(const bool& aIsError, |
108 | | const float& aElapsedTime, |
109 | | const uint32_t& aCharIndex) |
110 | 0 | { |
111 | 0 | SpeechSynthesisRequestChild* actor = mTask->mActor; |
112 | 0 | mTask->mActor = nullptr; |
113 | 0 |
|
114 | 0 | if (aIsError) { |
115 | 0 | mTask->DispatchErrorImpl(aElapsedTime, aCharIndex); |
116 | 0 | } else { |
117 | 0 | mTask->DispatchEndImpl(aElapsedTime, aCharIndex); |
118 | 0 | } |
119 | 0 |
|
120 | 0 | SpeechSynthesisRequestChild::Send__delete__(actor); |
121 | 0 |
|
122 | 0 | return IPC_OK(); |
123 | 0 | } |
124 | | |
125 | | mozilla::ipc::IPCResult |
126 | | SpeechSynthesisRequestChild::RecvOnPause(const float& aElapsedTime, |
127 | | const uint32_t& aCharIndex) |
128 | 0 | { |
129 | 0 | mTask->DispatchPauseImpl(aElapsedTime, aCharIndex); |
130 | 0 | return IPC_OK(); |
131 | 0 | } |
132 | | |
133 | | mozilla::ipc::IPCResult |
134 | | SpeechSynthesisRequestChild::RecvOnResume(const float& aElapsedTime, |
135 | | const uint32_t& aCharIndex) |
136 | 0 | { |
137 | 0 | mTask->DispatchResumeImpl(aElapsedTime, aCharIndex); |
138 | 0 | return IPC_OK(); |
139 | 0 | } |
140 | | |
141 | | mozilla::ipc::IPCResult |
142 | | SpeechSynthesisRequestChild::RecvOnBoundary(const nsString& aName, |
143 | | const float& aElapsedTime, |
144 | | const uint32_t& aCharIndex, |
145 | | const uint32_t& aCharLength, |
146 | | const uint8_t& argc) |
147 | 0 | { |
148 | 0 | mTask->DispatchBoundaryImpl(aName, aElapsedTime, aCharIndex, aCharLength, argc); |
149 | 0 | return IPC_OK(); |
150 | 0 | } |
151 | | |
152 | | mozilla::ipc::IPCResult |
153 | | SpeechSynthesisRequestChild::RecvOnMark(const nsString& aName, |
154 | | const float& aElapsedTime, |
155 | | const uint32_t& aCharIndex) |
156 | 0 | { |
157 | 0 | mTask->DispatchMarkImpl(aName, aElapsedTime, aCharIndex); |
158 | 0 | return IPC_OK(); |
159 | 0 | } |
160 | | |
161 | | // SpeechTaskChild |
162 | | |
163 | | SpeechTaskChild::SpeechTaskChild(SpeechSynthesisUtterance* aUtterance, bool aIsChrome) |
164 | | : nsSpeechTask(aUtterance, aIsChrome) |
165 | | , mActor(nullptr) |
166 | 0 | { |
167 | 0 | } |
168 | | |
169 | | NS_IMETHODIMP |
170 | | SpeechTaskChild::Setup(nsISpeechTaskCallback* aCallback) |
171 | 0 | { |
172 | 0 | MOZ_CRASH("Should never be called from child"); |
173 | 0 | } |
174 | | |
175 | | void |
176 | | SpeechTaskChild::Pause() |
177 | 0 | { |
178 | 0 | MOZ_ASSERT(mActor); |
179 | 0 | mActor->SendPause(); |
180 | 0 | } |
181 | | |
182 | | void |
183 | | SpeechTaskChild::Resume() |
184 | 0 | { |
185 | 0 | MOZ_ASSERT(mActor); |
186 | 0 | mActor->SendResume(); |
187 | 0 | } |
188 | | |
189 | | void |
190 | | SpeechTaskChild::Cancel() |
191 | 0 | { |
192 | 0 | MOZ_ASSERT(mActor); |
193 | 0 | mActor->SendCancel(); |
194 | 0 | } |
195 | | |
196 | | void |
197 | | SpeechTaskChild::ForceEnd() |
198 | 0 | { |
199 | 0 | MOZ_ASSERT(mActor); |
200 | 0 | mActor->SendForceEnd(); |
201 | 0 | } |
202 | | |
203 | | void |
204 | | SpeechTaskChild::SetAudioOutputVolume(float aVolume) |
205 | 0 | { |
206 | 0 | if (mActor) { |
207 | 0 | mActor->SendSetAudioOutputVolume(aVolume); |
208 | 0 | } |
209 | 0 | } |
210 | | |
211 | | } // namespace dom |
212 | | } // namespace mozilla |