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 nsPicoService_h
8 #define nsPicoService_h
10 #include "mozilla/Mutex.h"
11 #include "nsAutoPtr.h"
12 #include "nsTArray.h"
13 #include "nsIThread.h"
14 #include "nsISpeechService.h"
15 #include "nsRefPtrHashtable.h"
16 #include "mozilla/StaticPtr.h"
17 #include "mozilla/Monitor.h"
19 namespace mozilla {
20 namespace dom {
22 class PicoVoice;
23 class PicoCallbackRunnable;
25 typedef void* pico_System;
26 typedef void* pico_Resource;
27 typedef void* pico_Engine;
29 class nsPicoService : public nsISpeechService
30 {
31 friend class PicoCallbackRunnable;
32 friend class PicoInitRunnable;
34 public:
35 NS_DECL_THREADSAFE_ISUPPORTS
36 NS_DECL_NSISPEECHSERVICE
38 nsPicoService();
40 virtual ~nsPicoService();
42 static nsPicoService* GetInstance();
44 static already_AddRefed<nsPicoService> GetInstanceForService();
46 static void Shutdown();
48 private:
50 void Init();
52 void RegisterVoices();
54 bool GetVoiceFileLanguage(const nsACString& aFileName, nsAString& aLang);
56 void LoadEngine(PicoVoice* aVoice);
58 void UnloadEngine();
60 PicoVoice* CurrentVoice();
62 bool mInitialized;
64 nsCOMPtr<nsIThread> mThread;
66 nsRefPtrHashtable<nsStringHashKey, PicoVoice> mVoices;
68 Monitor mVoicesMonitor;
70 PicoVoice* mCurrentVoice;
72 Atomic<nsISpeechTask*> mCurrentTask;
74 pico_System mPicoSystem;
76 pico_Engine mPicoEngine;
78 pico_Resource mSgResource;
80 pico_Resource mTaResource;
82 nsAutoPtr<uint8_t> mPicoMemArea;
84 static StaticRefPtr<nsPicoService> sSingleton;
85 };
87 } // namespace dom
88 } // namespace mozilla
90 #endif