content/media/webspeech/synth/nsSynthVoiceRegistry.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_nsSynthVoiceRegistry_h
michael@0 8 #define mozilla_dom_nsSynthVoiceRegistry_h
michael@0 9
michael@0 10 #include "nsAutoPtr.h"
michael@0 11 #include "nsISynthVoiceRegistry.h"
michael@0 12 #include "nsRefPtrHashtable.h"
michael@0 13 #include "nsTArray.h"
michael@0 14
michael@0 15 class nsISpeechService;
michael@0 16
michael@0 17 namespace mozilla {
michael@0 18 namespace dom {
michael@0 19
michael@0 20 class RemoteVoice;
michael@0 21 class SpeechSynthesisUtterance;
michael@0 22 class SpeechSynthesisChild;
michael@0 23 class nsSpeechTask;
michael@0 24 class VoiceData;
michael@0 25
michael@0 26 class nsSynthVoiceRegistry : public nsISynthVoiceRegistry
michael@0 27 {
michael@0 28 public:
michael@0 29 NS_DECL_ISUPPORTS
michael@0 30 NS_DECL_NSISYNTHVOICEREGISTRY
michael@0 31
michael@0 32 nsSynthVoiceRegistry();
michael@0 33 virtual ~nsSynthVoiceRegistry();
michael@0 34
michael@0 35 already_AddRefed<nsSpeechTask> SpeakUtterance(SpeechSynthesisUtterance& aUtterance,
michael@0 36 const nsAString& aDocLang);
michael@0 37
michael@0 38 void Speak(const nsAString& aText, const nsAString& aLang,
michael@0 39 const nsAString& aUri, const float& aRate, const float& aPitch,
michael@0 40 nsSpeechTask* aTask);
michael@0 41
michael@0 42 void SendVoices(InfallibleTArray<RemoteVoice>* aVoices,
michael@0 43 InfallibleTArray<nsString>* aDefaults);
michael@0 44
michael@0 45 static nsSynthVoiceRegistry* GetInstance();
michael@0 46
michael@0 47 static already_AddRefed<nsSynthVoiceRegistry> GetInstanceForService();
michael@0 48
michael@0 49 static void RecvRemoveVoice(const nsAString& aUri);
michael@0 50
michael@0 51 static void RecvAddVoice(const RemoteVoice& aVoice);
michael@0 52
michael@0 53 static void RecvSetDefaultVoice(const nsAString& aUri, bool aIsDefault);
michael@0 54
michael@0 55 static void Shutdown();
michael@0 56
michael@0 57 private:
michael@0 58 VoiceData* FindBestMatch(const nsAString& aUri, const nsAString& lang);
michael@0 59
michael@0 60 bool FindVoiceByLang(const nsAString& aLang, VoiceData** aRetval);
michael@0 61
michael@0 62 nsresult AddVoiceImpl(nsISpeechService* aService,
michael@0 63 const nsAString& aUri,
michael@0 64 const nsAString& aName,
michael@0 65 const nsAString& aLang,
michael@0 66 bool aLocalService);
michael@0 67
michael@0 68 nsTArray<nsRefPtr<VoiceData> > mVoices;
michael@0 69
michael@0 70 nsTArray<nsRefPtr<VoiceData> > mDefaultVoices;
michael@0 71
michael@0 72 nsRefPtrHashtable<nsStringHashKey, VoiceData> mUriVoiceMap;
michael@0 73
michael@0 74 SpeechSynthesisChild* mSpeechSynthChild;
michael@0 75 };
michael@0 76
michael@0 77 } // namespace dom
michael@0 78 } // namespace mozilla
michael@0 79
michael@0 80 #endif

mercurial