Bug 1254378 - Make new 'speech-synth-started' component service category. r=smaug
MozReview-Commit-ID: LsPDCdpUA48
--- a/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp
+++ b/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp
@@ -15,31 +15,31 @@ using namespace mozilla::dom;
{0x914e73b4, 0x6337, 0x4bef, {0x97, 0xf3, 0x4d, 0x06, 0x9e, 0x05, 0x3a, 0x12}}
#define OSXSPEECHSYNTHESIZERSERVICE_CONTRACTID "@mozilla.org/synthsystem;1"
// Defines OSXSpeechSynthesizerServiceConstructor
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(OSXSpeechSynthesizerService,
OSXSpeechSynthesizerService::GetInstanceForService)
-// Defines kSAPISERVICE_CID
+// Defines kOSXSERVICE_CID
NS_DEFINE_NAMED_CID(OSXSPEECHSYNTHESIZERSERVICE_CID);
static const mozilla::Module::CIDEntry kCIDs[] = {
{ &kOSXSPEECHSYNTHESIZERSERVICE_CID, true, nullptr, OSXSpeechSynthesizerServiceConstructor },
{ nullptr }
};
static const mozilla::Module::ContractIDEntry kContracts[] = {
{ OSXSPEECHSYNTHESIZERSERVICE_CONTRACTID, &kOSXSPEECHSYNTHESIZERSERVICE_CID },
{ nullptr }
};
static const mozilla::Module::CategoryEntry kCategories[] = {
- { "profile-after-change", "Sapi Speech Synth", OSXSPEECHSYNTHESIZERSERVICE_CONTRACTID },
+ { "speech-synth-started", "OSX Speech Synth", OSXSPEECHSYNTHESIZERSERVICE_CONTRACTID },
{ nullptr }
};
static void
UnloadOSXSpeechSynthesizerModule()
{
OSXSpeechSynthesizerService::Shutdown();
}
--- a/dom/media/webspeech/synth/nsISpeechService.idl
+++ b/dom/media/webspeech/synth/nsISpeechService.idl
@@ -160,8 +160,14 @@ interface nsISpeechService : nsISupports
in float aVolume, in float aRate, in float aPitch,
in nsISpeechTask aTask);
const SpeechServiceType SERVICETYPE_DIRECT_AUDIO = 1;
const SpeechServiceType SERVICETYPE_INDIRECT_AUDIO = 2;
readonly attribute SpeechServiceType serviceType;
};
+
+%{C++
+// This is the service category speech services could use to start up as
+// a component.
+#define NS_SPEECH_SYNTH_STARTED "speech-synth-started"
+%}
--- a/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp
+++ b/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp
@@ -2,16 +2,17 @@
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsILocaleService.h"
#include "nsISpeechService.h"
#include "nsServiceManagerUtils.h"
+#include "nsCategoryManagerUtils.h"
#include "SpeechSynthesisUtterance.h"
#include "SpeechSynthesisVoice.h"
#include "nsSynthVoiceRegistry.h"
#include "nsSpeechTask.h"
#include "AudioChannelService.h"
#include "nsString.h"
@@ -185,16 +186,21 @@ nsSynthVoiceRegistry*
nsSynthVoiceRegistry::GetInstance()
{
MOZ_ASSERT(NS_IsMainThread());
if (!gSynthVoiceRegistry) {
gSynthVoiceRegistry = new nsSynthVoiceRegistry();
Preferences::AddBoolVarCache(&sForceGlobalQueue,
"media.webspeech.synth.force_global_queue");
+ if (XRE_IsParentProcess()) {
+ // Start up all speech synth services.
+ NS_CreateServicesFromCategory(NS_SPEECH_SYNTH_STARTED, nullptr,
+ NS_SPEECH_SYNTH_STARTED);
+ }
}
return gSynthVoiceRegistry;
}
already_AddRefed<nsSynthVoiceRegistry>
nsSynthVoiceRegistry::GetInstanceForService()
{
--- a/dom/media/webspeech/synth/speechd/SpeechDispatcherModule.cpp
+++ b/dom/media/webspeech/synth/speechd/SpeechDispatcherModule.cpp
@@ -28,17 +28,17 @@ static const mozilla::Module::CIDEntry k
};
static const mozilla::Module::ContractIDEntry kContracts[] = {
{ SPEECHDISPATCHERSERVICE_CONTRACTID, &kSPEECHDISPATCHERSERVICE_CID },
{ nullptr }
};
static const mozilla::Module::CategoryEntry kCategories[] = {
- { "profile-after-change", "SpeechDispatcher Speech Synth", SPEECHDISPATCHERSERVICE_CONTRACTID },
+ { "speech-synth-started", "SpeechDispatcher Speech Synth", SPEECHDISPATCHERSERVICE_CONTRACTID },
{ nullptr }
};
static void
UnloadSpeechDispatcherModule()
{
SpeechDispatcherService::Shutdown();
}
--- a/dom/media/webspeech/synth/windows/SapiModule.cpp
+++ b/dom/media/webspeech/synth/windows/SapiModule.cpp
@@ -29,17 +29,17 @@ static const mozilla::Module::CIDEntry k
};
static const mozilla::Module::ContractIDEntry kContracts[] = {
{ SAPISERVICE_CONTRACTID, &kSAPISERVICE_CID },
{ nullptr }
};
static const mozilla::Module::CategoryEntry kCategories[] = {
- { "profile-after-change", "Sapi Speech Synth", SAPISERVICE_CONTRACTID },
+ { "speech-synth-started", "Sapi Speech Synth", SAPISERVICE_CONTRACTID },
{ nullptr }
};
static void
UnloadSapiModule()
{
SapiService::Shutdown();
}