tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SpeechDispatcherService.h (1693B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      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/. */
      6 
      7 #ifndef mozilla_dom_SpeechDispatcherService_h
      8 #define mozilla_dom_SpeechDispatcherService_h
      9 
     10 #include "mozilla/StaticPtr.h"
     11 #include "nsIObserver.h"
     12 #include "nsISpeechService.h"
     13 #include "nsIThread.h"
     14 #include "nsRefPtrHashtable.h"
     15 #include "nsTArray.h"
     16 
     17 struct SPDConnection;
     18 
     19 namespace mozilla {
     20 namespace dom {
     21 
     22 class SpeechDispatcherCallback;
     23 class SpeechDispatcherVoice;
     24 
     25 class SpeechDispatcherService final : public nsIObserver,
     26                                      public nsISpeechService {
     27  friend class SpeechDispatcherCallback;
     28 
     29 public:
     30  NS_DECL_THREADSAFE_ISUPPORTS
     31  NS_DECL_NSIOBSERVER
     32  NS_DECL_NSISPEECHSERVICE
     33 
     34  SpeechDispatcherService();
     35 
     36  void Init();
     37 
     38  void Setup();
     39 
     40  void EventNotify(uint32_t aMsgId, uint32_t aState);
     41 
     42  static SpeechDispatcherService* GetInstance(bool create = true);
     43  static already_AddRefed<SpeechDispatcherService> GetInstanceForService();
     44 
     45  static StaticRefPtr<SpeechDispatcherService> sSingleton;
     46 
     47 private:
     48  virtual ~SpeechDispatcherService();
     49 
     50  void NotifyError(const nsString& aError);
     51 
     52  void RegisterVoices();
     53 
     54  bool mInitialized;
     55 
     56  SPDConnection* mSpeechdClient;
     57 
     58  nsRefPtrHashtable<nsUint32HashKey, SpeechDispatcherCallback> mCallbacks;
     59 
     60  nsCOMPtr<nsIThread> mInitThread;
     61 
     62  nsRefPtrHashtable<nsStringHashKey, SpeechDispatcherVoice> mVoices;
     63 };
     64 
     65 }  // namespace dom
     66 }  // namespace mozilla
     67 #endif