Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/webspeech/synth/ipc/SpeechSynthesisParent.h
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
#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
                                                                    const bool& aIsChrome)
39
                                                                    override;
40
41
  bool DeallocPSpeechSynthesisRequestParent(PSpeechSynthesisRequestParent* aActor) override;
42
43
  mozilla::ipc::IPCResult RecvPSpeechSynthesisRequestConstructor(PSpeechSynthesisRequestParent* aActor,
44
                                                                 const nsString& aText,
45
                                                                 const nsString& aLang,
46
                                                                 const nsString& aUri,
47
                                                                 const float& aVolume,
48
                                                                 const float& aRate,
49
                                                                 const float& aPitch,
50
                                                                 const bool& aIsChrome) override;
51
};
52
53
class SpeechSynthesisRequestParent : public PSpeechSynthesisRequestParent
54
{
55
public:
56
  explicit SpeechSynthesisRequestParent(SpeechTaskParent* aTask);
57
  virtual ~SpeechSynthesisRequestParent();
58
59
  RefPtr<SpeechTaskParent> mTask;
60
61
protected:
62
63
  void ActorDestroy(ActorDestroyReason aWhy) override;
64
65
  mozilla::ipc::IPCResult RecvPause() override;
66
67
  mozilla::ipc::IPCResult RecvResume() override;
68
69
  mozilla::ipc::IPCResult RecvCancel() override;
70
71
  mozilla::ipc::IPCResult RecvForceEnd() override;
72
73
  mozilla::ipc::IPCResult RecvSetAudioOutputVolume(const float& aVolume) override;
74
75
  mozilla::ipc::IPCResult Recv__delete__() override;
76
};
77
78
class SpeechTaskParent : public nsSpeechTask
79
{
80
  friend class SpeechSynthesisRequestParent;
81
public:
82
  SpeechTaskParent(float aVolume, const nsAString& aUtterance, bool aIsChrome)
83
    : nsSpeechTask(aVolume
84
    , aUtterance, aIsChrome)
85
    , mActor(nullptr)
86
0
    {
87
0
    }
88
89
  nsresult DispatchStartImpl(const nsAString& aUri) override;
90
91
  nsresult DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex) override;
92
93
  nsresult DispatchPauseImpl(float aElapsedTime, uint32_t aCharIndex) override;
94
95
  nsresult DispatchResumeImpl(float aElapsedTime, uint32_t aCharIndex) override;
96
97
  nsresult DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex) override;
98
99
  nsresult DispatchBoundaryImpl(const nsAString& aName,
100
                                float aElapsedTime, uint32_t aCharIndex,
101
                                uint32_t aCharLength, uint8_t argc) override;
102
103
  nsresult DispatchMarkImpl(const nsAString& aName,
104
                            float aElapsedTime, uint32_t aCharIndex) override;
105
106
private:
107
  SpeechSynthesisRequestParent* mActor;
108
};
109
110
} // namespace dom
111
} // namespace mozilla
112
113
#endif