mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1080863 - Make nsPicoService an observer and initialize on profile-after-change. r=smaug
This commit is contained in:
parent
5d709c8f0d
commit
1aa1fb3352
@ -411,28 +411,13 @@ PicoCallbackRunnable::OnCancel()
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsPicoService)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISpeechService)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISpeechService)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(nsPicoService)
|
||||
NS_IMPL_RELEASE(nsPicoService)
|
||||
|
||||
nsPicoService::nsPicoService()
|
||||
: mInitialized(false)
|
||||
, mVoicesMonitor("nsPicoService::mVoices")
|
||||
, mCurrentTask(nullptr)
|
||||
, mPicoSystem(nullptr)
|
||||
, mPicoEngine(nullptr)
|
||||
, mSgResource(nullptr)
|
||||
, mTaResource(nullptr)
|
||||
, mPicoMemArea(nullptr)
|
||||
{
|
||||
DebugOnly<nsresult> rv = NS_NewNamedThread("Pico Worker", getter_AddRefs(mThread));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
rv = mThread->Dispatch(NS_NewRunnableMethod(this, &nsPicoService::Init), NS_DISPATCH_NORMAL);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
|
||||
nsPicoService::~nsPicoService()
|
||||
{
|
||||
// We don't worry about removing the voices because this gets
|
||||
@ -447,6 +432,20 @@ nsPicoService::~nsPicoService()
|
||||
UnloadEngine();
|
||||
}
|
||||
|
||||
// nsIObserver
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPicoService::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const char16_t* aData)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ENSURE_TRUE(!strcmp(aTopic, "profile-after-change"), NS_ERROR_UNEXPECTED);
|
||||
|
||||
DebugOnly<nsresult> rv = NS_NewNamedThread("Pico Worker", getter_AddRefs(mThread));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
return mThread->Dispatch(
|
||||
NS_NewRunnableMethod(this, &nsPicoService::Init), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
// nsISpeechService
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsISpeechService.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
@ -26,7 +27,8 @@ typedef void* pico_System;
|
||||
typedef void* pico_Resource;
|
||||
typedef void* pico_Engine;
|
||||
|
||||
class nsPicoService : public nsISpeechService
|
||||
class nsPicoService : public nsIObserver,
|
||||
public nsISpeechService
|
||||
{
|
||||
friend class PicoCallbackRunnable;
|
||||
friend class PicoInitRunnable;
|
||||
@ -34,8 +36,7 @@ class nsPicoService : public nsISpeechService
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSISPEECHSERVICE
|
||||
|
||||
nsPicoService();
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
static nsPicoService* GetInstance();
|
||||
|
||||
@ -82,8 +83,19 @@ private:
|
||||
nsAutoPtr<uint8_t> mPicoMemArea;
|
||||
|
||||
static StaticRefPtr<nsPicoService> sSingleton;
|
||||
};
|
||||
|
||||
protected:
|
||||
nsPicoService() : mInitialized(false)
|
||||
, mVoicesMonitor("nsPicoService::mVoices")
|
||||
, mCurrentTask(nullptr)
|
||||
, mPicoSystem(nullptr)
|
||||
, mPicoEngine(nullptr)
|
||||
, mSgResource(nullptr)
|
||||
, mTaResource(nullptr)
|
||||
, mPicoMemArea(nullptr)
|
||||
{
|
||||
}
|
||||
};
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user