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.

     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/. */
     7 #ifndef mozilla_dom_nsSpeechTask_h
     8 #define mozilla_dom_nsSpeechTask_h
    10 #include "MediaStreamGraph.h"
    11 #include "SpeechSynthesisUtterance.h"
    12 #include "nsISpeechService.h"
    14 namespace mozilla {
    15 namespace dom {
    17 class SpeechSynthesisUtterance;
    18 class SpeechSynthesis;
    19 class SynthStreamListener;
    21 class nsSpeechTask : public nsISpeechTask
    22 {
    23   friend class SynthStreamListener;
    25 public:
    26   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    27   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsSpeechTask, nsISpeechTask)
    29   NS_DECL_NSISPEECHTASK
    31   nsSpeechTask(SpeechSynthesisUtterance* aUtterance);
    32   nsSpeechTask(float aVolume, const nsAString& aText);
    34   virtual ~nsSpeechTask();
    36   virtual void Pause();
    38   virtual void Resume();
    40   virtual void Cancel();
    42   float GetCurrentTime();
    44   uint32_t GetCurrentCharOffset();
    46   void SetSpeechSynthesis(SpeechSynthesis* aSpeechSynthesis);
    48   void SetIndirectAudio(bool aIndirectAudio) { mIndirectAudio = aIndirectAudio; }
    50 protected:
    51   virtual nsresult DispatchStartImpl();
    53   virtual nsresult DispatchEndImpl(float aElapsedTime, uint32_t aCharIndex);
    55   virtual nsresult DispatchPauseImpl(float aElapsedTime, uint32_t aCharIndex);
    57   virtual nsresult DispatchResumeImpl(float aElapsedTime, uint32_t aCharIndex);
    59   virtual nsresult DispatchErrorImpl(float aElapsedTime, uint32_t aCharIndex);
    61   virtual nsresult DispatchBoundaryImpl(const nsAString& aName,
    62                                         float aElapsedTime,
    63                                         uint32_t aCharIndex);
    65   virtual nsresult DispatchMarkImpl(const nsAString& aName,
    66                                     float aElapsedTime, uint32_t aCharIndex);
    68   nsRefPtr<SpeechSynthesisUtterance> mUtterance;
    70   float mVolume;
    72   nsString mText;
    74 private:
    75   void End();
    77   void SendAudioImpl(int16_t* aData, uint32_t aDataLen);
    79   nsRefPtr<SourceMediaStream> mStream;
    81   nsCOMPtr<nsISpeechTaskCallback> mCallback;
    83   uint32_t mChannels;
    85   nsRefPtr<SpeechSynthesis> mSpeechSynthesis;
    87   bool mIndirectAudio;
    88 };
    90 } // namespace dom
    91 } // namespace mozilla
    93 #endif

mercurial