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