Tue, 06 Jan 2015 21:39:09 +0100
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_nsSynthVoiceRegistry_h
8 #define mozilla_dom_nsSynthVoiceRegistry_h
10 #include "nsAutoPtr.h"
11 #include "nsISynthVoiceRegistry.h"
12 #include "nsRefPtrHashtable.h"
13 #include "nsTArray.h"
15 class nsISpeechService;
17 namespace mozilla {
18 namespace dom {
20 class RemoteVoice;
21 class SpeechSynthesisUtterance;
22 class SpeechSynthesisChild;
23 class nsSpeechTask;
24 class VoiceData;
26 class nsSynthVoiceRegistry : public nsISynthVoiceRegistry
27 {
28 public:
29 NS_DECL_ISUPPORTS
30 NS_DECL_NSISYNTHVOICEREGISTRY
32 nsSynthVoiceRegistry();
33 virtual ~nsSynthVoiceRegistry();
35 already_AddRefed<nsSpeechTask> SpeakUtterance(SpeechSynthesisUtterance& aUtterance,
36 const nsAString& aDocLang);
38 void Speak(const nsAString& aText, const nsAString& aLang,
39 const nsAString& aUri, const float& aRate, const float& aPitch,
40 nsSpeechTask* aTask);
42 void SendVoices(InfallibleTArray<RemoteVoice>* aVoices,
43 InfallibleTArray<nsString>* aDefaults);
45 static nsSynthVoiceRegistry* GetInstance();
47 static already_AddRefed<nsSynthVoiceRegistry> GetInstanceForService();
49 static void RecvRemoveVoice(const nsAString& aUri);
51 static void RecvAddVoice(const RemoteVoice& aVoice);
53 static void RecvSetDefaultVoice(const nsAString& aUri, bool aIsDefault);
55 static void Shutdown();
57 private:
58 VoiceData* FindBestMatch(const nsAString& aUri, const nsAString& lang);
60 bool FindVoiceByLang(const nsAString& aLang, VoiceData** aRetval);
62 nsresult AddVoiceImpl(nsISpeechService* aService,
63 const nsAString& aUri,
64 const nsAString& aName,
65 const nsAString& aLang,
66 bool aLocalService);
68 nsTArray<nsRefPtr<VoiceData> > mVoices;
70 nsTArray<nsRefPtr<VoiceData> > mDefaultVoices;
72 nsRefPtrHashtable<nsStringHashKey, VoiceData> mUriVoiceMap;
74 SpeechSynthesisChild* mSpeechSynthChild;
75 };
77 } // namespace dom
78 } // namespace mozilla
80 #endif