Bug 1254378 - Make new 'speech-synth-started' component service category. r=smaug
authorEitan Isaacson <eitan@monotonous.org>
Wed, 23 Mar 2016 10:32:58 -0700
changeset 291117 3ace54af7a05d57bb02b4360a09c156fd5442d0e
parent 291116 7f8bd64aaadd033af0bd933cbb0f2dca4c2b9245
child 291118 47390c18d9b12131f4849a2625302cf0588ac720
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1254378
milestone48.0a1
Bug 1254378 - Make new 'speech-synth-started' component service category. r=smaug MozReview-Commit-ID: LsPDCdpUA48
dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerModule.cpp
dom/media/webspeech/synth/nsISpeechService.idl
dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp
dom/media/webspeech/synth/speechd/SpeechDispatcherModule.cpp
dom/media/webspeech/synth/windows/SapiModule.cpp
--- 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();
 }