Line data Source code
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 : #ifndef mozilla_dom_SpeechSynthesisParent_h
6 : #define mozilla_dom_SpeechSynthesisParent_h
7 :
8 : #include "mozilla/dom/PSpeechSynthesisParent.h"
9 : #include "mozilla/dom/PSpeechSynthesisRequestParent.h"
10 : #include "nsSpeechTask.h"
11 :
12 : namespace mozilla {
13 : namespace dom {
14 :
15 : class ContentParent;
16 : class SpeechTaskParent;
17 : class SpeechSynthesisRequestParent;
18 :
19 : class SpeechSynthesisParent : public PSpeechSynthesisParent
20 : {
21 : friend class ContentParent;
22 : friend class SpeechSynthesisRequestParent;
23 :
24 : public:
25 : void ActorDestroy(ActorDestroyReason aWhy) override;
26 :
27 : bool SendInit();
28 :
29 : protected:
30 : SpeechSynthesisParent();
31 : virtual ~SpeechSynthesisParent();
32 : PSpeechSynthesisRequestParent* AllocPSpeechSynthesisRequestParent(const nsString& aText,
33 : const nsString& aLang,
34 : const nsString& aUri,
35 : const float& aVolume,
36 : const float& aRate,
37 : const float& aPitch)
38 : override;
39 :
40 : bool DeallocPSpeechSynthesisRequestParent(PSpeechSynthesisRequestParent* aActor) override;
41 :
42 : mozilla::ipc::IPCResult RecvPSpeechSynthesisRequestConstructor(PSpeechSynthesisRequestParent* aActor,
43 : const nsString& aText,
44 : const nsString& aLang,
45 : const nsString& aUri,
46 : const float& aVolume,
47 : const float& aRate,
48 : const float& aPitch) override;
49 : };
50 :
51 : class SpeechSynthesisRequestParent : public PSpeechSynthesisRequestParent
52 : {
53 : public:
54 : explicit SpeechSynthesisRequestParent(SpeechTaskParent* aTask);
55 : virtual ~SpeechSynthesisRequestParent();
56 :
57 : RefPtr<SpeechTaskParent> mTask;
58 :
59 : protected:
60 :
61 : void ActorDestroy(ActorDestroyReason aWhy) override;
62 :
63 : mozilla::ipc::IPCResult RecvPause() override;
64 :
65 : mozilla::ipc::IPCResult RecvResume() override;
66 :
67 : mozilla::ipc::IPCResult RecvCancel() override;
68 :
69 : mozilla::ipc::IPCResult RecvForceEnd() override;
70 :
71 : mozilla::ipc::IPCResult RecvSetAudioOutputVolume(const float& aVolume) override;
72 :
73 : mozilla::ipc::IPCResult Recv__delete__() override;
74 : };
75 :
76 0 : class SpeechTaskParent : public nsSpeechTask
77 : {
78 : friend class SpeechSynthesisRequestParent;
79 : public:
80 0 : SpeechTaskParent(float aVolume, const nsAString& aUtterance)
81 0 : : nsSpeechTask(aVolume, aUtterance) {}
82 :
83 : nsresult DispatchStartImpl(const nsAString& aUri);
84 :
85 : nsresult DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex);
86 :
87 : nsresult DispatchPauseImpl(float aElapsedTime, uint32_t aCharIndex);
88 :
89 : nsresult DispatchResumeImpl(float aElapsedTime, uint32_t aCharIndex);
90 :
91 : nsresult DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex);
92 :
93 : nsresult DispatchBoundaryImpl(const nsAString& aName,
94 : float aElapsedTime, uint32_t aCharIndex,
95 : uint32_t aCharLength, uint8_t argc);
96 :
97 : nsresult DispatchMarkImpl(const nsAString& aName,
98 : float aElapsedTime, uint32_t aCharIndex);
99 :
100 : private:
101 : SpeechSynthesisRequestParent* mActor;
102 : };
103 :
104 : } // namespace dom
105 : } // namespace mozilla
106 :
107 : #endif
|