Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/nsSpeechTask.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim:set ts=2 sw=2 sts=2 et cindent: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozilla_dom_nsSpeechTask_h
8
#define mozilla_dom_nsSpeechTask_h
9
10
#include "SpeechSynthesisUtterance.h"
11
#include "nsIAudioChannelAgent.h"
12
#include "nsISpeechService.h"
13
14
namespace mozilla {
15
16
class SharedBuffer;
17
18
namespace dom {
19
20
class SpeechSynthesisUtterance;
21
class SpeechSynthesis;
22
class SynthStreamListener;
23
24
class nsSpeechTask : public nsISpeechTask
25
                   , public nsIAudioChannelAgentCallback
26
                   , public nsSupportsWeakReference
27
{
28
  friend class SynthStreamListener;
29
30
public:
31
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32
  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsSpeechTask, nsISpeechTask)
33
34
  NS_DECL_NSISPEECHTASK
35
  NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
36
37
  explicit nsSpeechTask(SpeechSynthesisUtterance* aUtterance, bool aIsChrome);
38
  nsSpeechTask(float aVolume, const nsAString& aText, bool aIsChrome);
39
40
  virtual void Pause();
41
42
  virtual void Resume();
43
44
  virtual void Cancel();
45
46
  virtual void ForceEnd();
47
48
  void SetSpeechSynthesis(SpeechSynthesis* aSpeechSynthesis);
49
50
  void Init();
51
52
  void SetChosenVoiceURI(const nsAString& aUri);
53
54
  virtual void SetAudioOutputVolume(float aVolume);
55
56
  void ForceError(float aElapsedTime, uint32_t aCharIndex);
57
58
0
  bool IsPreCanceled() { return mPreCanceled; };
59
60
0
  bool IsPrePaused() { return mPrePaused; }
61
62
0
  bool IsChrome() { return mIsChrome; }
63
64
protected:
65
  virtual ~nsSpeechTask();
66
67
  nsresult DispatchStartImpl();
68
69
  virtual nsresult DispatchStartImpl(const nsAString& aUri);
70
71
  virtual nsresult DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex);
72
73
  virtual nsresult DispatchPauseImpl(float aElapsedTime, uint32_t aCharIndex);
74
75
  virtual nsresult DispatchResumeImpl(float aElapsedTime, uint32_t aCharIndex);
76
77
  virtual nsresult DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex);
78
79
  virtual nsresult DispatchBoundaryImpl(const nsAString& aName,
80
                                        float aElapsedTime,
81
                                        uint32_t aCharIndex,
82
                                        uint32_t aCharLength,
83
                                        uint8_t argc);
84
85
  virtual nsresult DispatchMarkImpl(const nsAString& aName,
86
                                    float aElapsedTime, uint32_t aCharIndex);
87
88
  RefPtr<SpeechSynthesisUtterance> mUtterance;
89
90
  float mVolume;
91
92
  nsString mText;
93
94
  bool mInited;
95
96
  bool mPrePaused;
97
98
  bool mPreCanceled;
99
100
private:
101
  void End();
102
103
  void CreateAudioChannelAgent();
104
105
  void DestroyAudioChannelAgent();
106
107
  nsCOMPtr<nsISpeechTaskCallback> mCallback;
108
109
  nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
110
111
  RefPtr<SpeechSynthesis> mSpeechSynthesis;
112
113
  nsString mChosenVoiceURI;
114
115
  bool mIsChrome;
116
};
117
118
} // namespace dom
119
} // namespace mozilla
120
121
#endif