content/media/webspeech/synth/nsSpeechTask.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_nsSpeechTask_h
michael@0 8 #define mozilla_dom_nsSpeechTask_h
michael@0 9
michael@0 10 #include "MediaStreamGraph.h"
michael@0 11 #include "SpeechSynthesisUtterance.h"
michael@0 12 #include "nsISpeechService.h"
michael@0 13
michael@0 14 namespace mozilla {
michael@0 15 namespace dom {
michael@0 16
michael@0 17 class SpeechSynthesisUtterance;
michael@0 18 class SpeechSynthesis;
michael@0 19 class SynthStreamListener;
michael@0 20
michael@0 21 class nsSpeechTask : public nsISpeechTask
michael@0 22 {
michael@0 23 friend class SynthStreamListener;
michael@0 24
michael@0 25 public:
michael@0 26 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 27 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsSpeechTask, nsISpeechTask)
michael@0 28
michael@0 29 NS_DECL_NSISPEECHTASK
michael@0 30
michael@0 31 nsSpeechTask(SpeechSynthesisUtterance* aUtterance);
michael@0 32 nsSpeechTask(float aVolume, const nsAString& aText);
michael@0 33
michael@0 34 virtual ~nsSpeechTask();
michael@0 35
michael@0 36 virtual void Pause();
michael@0 37
michael@0 38 virtual void Resume();
michael@0 39
michael@0 40 virtual void Cancel();
michael@0 41
michael@0 42 float GetCurrentTime();
michael@0 43
michael@0 44 uint32_t GetCurrentCharOffset();
michael@0 45
michael@0 46 void SetSpeechSynthesis(SpeechSynthesis* aSpeechSynthesis);
michael@0 47
michael@0 48 void SetIndirectAudio(bool aIndirectAudio) { mIndirectAudio = aIndirectAudio; }
michael@0 49
michael@0 50 protected:
michael@0 51 virtual nsresult DispatchStartImpl();
michael@0 52
michael@0 53 virtual nsresult DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex);
michael@0 54
michael@0 55 virtual nsresult DispatchPauseImpl(float aElapsedTime, uint32_t aCharIndex);
michael@0 56
michael@0 57 virtual nsresult DispatchResumeImpl(float aElapsedTime, uint32_t aCharIndex);
michael@0 58
michael@0 59 virtual nsresult DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex);
michael@0 60
michael@0 61 virtual nsresult DispatchBoundaryImpl(const nsAString& aName,
michael@0 62 float aElapsedTime,
michael@0 63 uint32_t aCharIndex);
michael@0 64
michael@0 65 virtual nsresult DispatchMarkImpl(const nsAString& aName,
michael@0 66 float aElapsedTime, uint32_t aCharIndex);
michael@0 67
michael@0 68 nsRefPtr<SpeechSynthesisUtterance> mUtterance;
michael@0 69
michael@0 70 float mVolume;
michael@0 71
michael@0 72 nsString mText;
michael@0 73
michael@0 74 private:
michael@0 75 void End();
michael@0 76
michael@0 77 void SendAudioImpl(int16_t* aData, uint32_t aDataLen);
michael@0 78
michael@0 79 nsRefPtr<SourceMediaStream> mStream;
michael@0 80
michael@0 81 nsCOMPtr<nsISpeechTaskCallback> mCallback;
michael@0 82
michael@0 83 uint32_t mChannels;
michael@0 84
michael@0 85 nsRefPtr<SpeechSynthesis> mSpeechSynthesis;
michael@0 86
michael@0 87 bool mIndirectAudio;
michael@0 88 };
michael@0 89
michael@0 90 } // namespace dom
michael@0 91 } // namespace mozilla
michael@0 92
michael@0 93 #endif

mercurial