mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-24 05:44:10 +00:00
Bug 1080863 - Make nsPicoService an observer and initialize on profile-after-change. r=smaug
This commit is contained in:
parent
8c488b9625
commit
0c3af88521
@ -411,7 +411,8 @@ 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)
|
||||
@ -427,10 +428,6 @@ nsPicoService::nsPicoService()
|
||||
, 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()
|
||||
@ -447,6 +444,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,6 +36,7 @@ class nsPicoService : public nsISpeechService
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSISPEECHSERVICE
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
nsPicoService();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user