Bug 909645 part 3. Make including SpeechRecognition.h and MediaManager.h not pull ipdl headers. r=ms2ger
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 28 Aug 2013 00:14:57 -0400
changeset 157537 b00996f5cb3b0e84cf45f57e5f201d981b8980c9
parent 157536 8bfc1b74520332b285c68a0de786f8e659a439f9
child 157538 69f4af72765c06dff92c6e3ed7b78e15b541f556
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersms2ger
bugs909645
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 909645 part 3. Make including SpeechRecognition.h and MediaManager.h not pull ipdl headers. r=ms2ger
content/media/webspeech/recognition/SpeechRecognition.cpp
content/media/webspeech/recognition/SpeechRecognition.h
content/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp
dom/media/MediaManager.cpp
dom/media/MediaManager.h
--- a/content/media/webspeech/recognition/SpeechRecognition.cpp
+++ b/content/media/webspeech/recognition/SpeechRecognition.cpp
@@ -5,22 +5,26 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SpeechRecognition.h"
 
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 
 #include "mozilla/dom/SpeechRecognitionBinding.h"
+#include "mozilla/MediaManager.h"
+#include "mozilla/Services.h"
 
 #include "AudioSegment.h"
 #include "endpointer.h"
 
 #include "GeneratedEvents.h"
 #include "nsIDOMSpeechRecognitionEvent.h"
+#include "nsIObserverService.h"
+#include "nsServiceManagerUtils.h"
 
 #include <algorithm>
 
 namespace mozilla {
 namespace dom {
 
 #define PREFERENCE_DEFAULT_RECOGNITION_SERVICE "media.webspeech.service.default"
 #define DEFAULT_RECOGNITION_SERVICE "google"
@@ -619,18 +623,17 @@ SpeechRecognition::ProcessTestEventReque
 already_AddRefed<SpeechGrammarList>
 SpeechRecognition::GetGrammars(ErrorResult& aRv) const
 {
   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
   return nullptr;
 }
 
 void
-SpeechRecognition::SetGrammars(mozilla::dom::SpeechGrammarList& aArg,
-                               ErrorResult& aRv)
+SpeechRecognition::SetGrammars(SpeechGrammarList& aArg, ErrorResult& aRv)
 {
   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
   return;
 }
 
 void
 SpeechRecognition::GetLang(nsString& aRetVal, ErrorResult& aRv) const
 {
--- a/content/media/webspeech/recognition/SpeechRecognition.h
+++ b/content/media/webspeech/recognition/SpeechRecognition.h
@@ -8,17 +8,18 @@
 
 #include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 #include "nsTArray.h"
 
-#include "MediaManager.h"
+#include "nsIDOMNavigatorUserMedia.h"
+#include "nsITimer.h"
 #include "MediaEngine.h"
 #include "MediaStreamGraph.h"
 #include "AudioSegment.h"
 #include "mozilla/WeakPtr.h"
 #include "mozilla/Preferences.h"
 
 #include "EnableWebSpeechRecognitionCheck.h"
 #include "SpeechGrammarList.h"
--- a/content/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp
+++ b/content/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp
@@ -7,16 +7,18 @@
 #include "nsThreadUtils.h"
 
 #include "FakeSpeechRecognitionService.h"
 
 #include "SpeechRecognition.h"
 #include "SpeechRecognitionAlternative.h"
 #include "SpeechRecognitionResult.h"
 #include "SpeechRecognitionResultList.h"
+#include "nsIObserverService.h"
+#include "mozilla/Services.h"
 
 namespace mozilla {
 
 using namespace dom;
 
 NS_IMPL_ISUPPORTS2(FakeSpeechRecognitionService, nsISpeechRecognitionService, nsIObserver)
 
 FakeSpeechRecognitionService::FakeSpeechRecognitionService()
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -10,16 +10,17 @@
 #include "nsIUUIDGenerator.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIPopupWindowManager.h"
 #include "nsISupportsArray.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIInterfaceRequestorUtils.h"
+#include "mozilla/dom/ContentChild.h"
 
 // For PR_snprintf
 #include "prprf.h"
 
 #include "nsJSUtils.h"
 #include "nsDOMFile.h"
 #include "nsGlobalWindow.h"
 
@@ -1288,17 +1289,17 @@ MediaManager::RemoveFromWindowList(uint6
         uint64_t outerID = outer->WindowID();
 
         // Notify the UI that this window no longer has gUM active
         char windowBuffer[32];
         PR_snprintf(windowBuffer, sizeof(windowBuffer), "%llu", outerID);
         nsAutoString data;
         data.Append(NS_ConvertUTF8toUTF16(windowBuffer));
 
-        nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
+        nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
         obs->NotifyObservers(nullptr, "recording-window-ended", data.get());
         LOG(("Sent recording-window-ended for window %llu (outer %llu)",
              aWindowID, outerID));
       } else {
         LOG(("No outer window for inner %llu", aWindowID));
       }
     } else {
       LOG(("No inner window for %llu", aWindowID));
@@ -1327,17 +1328,17 @@ MediaManager::GetPrefs(nsIPrefBranch *aB
   GetPref(aBranch, "media.navigator.video.default_minfps", aData, &mPrefs.mMinFPS);
 }
 
 nsresult
 MediaManager::Observe(nsISupports* aSubject, const char* aTopic,
   const PRUnichar* aData)
 {
   NS_ASSERTION(NS_IsMainThread(), "Observer invoked off the main thread");
-  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
+  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
 
   if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
     nsCOMPtr<nsIPrefBranch> branch( do_QueryInterface(aSubject) );
     if (branch) {
       GetPrefs(branch,NS_ConvertUTF16toUTF8(aData).get());
       LOG(("%s: %dx%d @%dfps (min %d)", __FUNCTION__,
            mPrefs.mWidth, mPrefs.mHeight, mPrefs.mFPS, mPrefs.mMinFPS));
     }
@@ -1597,9 +1598,48 @@ GetUserMediaCallbackMediaStreamListener:
     MM_LOG(("Listener removed by DOM Destroy(), mFinished = %d", (int) mFinished));
     mRemoved = true;
   }
   if (!mFinished) {
     NotifyFinished(aGraph);
   }
 }
 
+NS_IMETHODIMP
+GetUserMediaNotificationEvent::Run()
+{
+  NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
+  // Make sure mStream is cleared and our reference to the DOMMediaStream
+  // is dropped on the main thread, no matter what happens in this method.
+  // Otherwise this object might be destroyed off the main thread,
+  // releasing DOMMediaStream off the main thread, which is not allowed.
+  nsRefPtr<DOMMediaStream> stream = mStream.forget();
+
+  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
+  if (!obs) {
+    NS_WARNING("Could not get the Observer service for GetUserMedia recording notification.");
+    return NS_ERROR_FAILURE;
+  }
+  nsString msg;
+  switch (mStatus) {
+  case STARTING:
+    msg = NS_LITERAL_STRING("starting");
+    stream->OnTracksAvailable(mOnTracksAvailableCallback.forget());
+    break;
+  case STOPPING:
+    msg = NS_LITERAL_STRING("shutdown");
+    if (mListener) {
+      mListener->SetStopped();
+    }
+    break;
+  }
+  obs->NotifyObservers(nullptr,
+		       "recording-device-events",
+		       msg.get());
+  // Forward recording events to parent process.
+  // The events are gathered in chrome process and used for recording indicator
+  if (XRE_GetProcessType() != GeckoProcessType_Default) {
+    unused << dom::ContentChild::GetSingleton()->SendRecordingDeviceEvents(msg);
+  }
+  return NS_OK;
+}
+
 } // namespace mozilla
--- a/dom/media/MediaManager.h
+++ b/dom/media/MediaManager.h
@@ -1,14 +1,13 @@
 /* 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 "MediaEngine.h"
-#include "mozilla/dom/ContentChild.h"
 #include "mozilla/Services.h"
 #include "mozilla/unused.h"
 #include "nsIMediaManager.h"
 
 #include "nsHashKeys.h"
 #include "nsGlobalWindow.h"
 #include "nsClassHashtable.h"
 #include "nsRefPtrHashtable.h"
@@ -207,54 +206,17 @@ class GetUserMediaNotificationEvent: pub
                                   DOMMediaStream::OnTracksAvailableCallback* aOnTracksAvailableCallback)
     : mStream(aStream), mOnTracksAvailableCallback(aOnTracksAvailableCallback),
       mStatus(aStatus) {}
     virtual ~GetUserMediaNotificationEvent()
     {
 
     }
 
-    NS_IMETHOD
-    Run() MOZ_OVERRIDE
-    {
-      NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
-      // Make sure mStream is cleared and our reference to the DOMMediaStream
-      // is dropped on the main thread, no matter what happens in this method.
-      // Otherwise this object might be destroyed off the main thread,
-      // releasing DOMMediaStream off the main thread, which is not allowed.
-      nsRefPtr<DOMMediaStream> stream = mStream.forget();
-
-      nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-      if (!obs) {
-        NS_WARNING("Could not get the Observer service for GetUserMedia recording notification.");
-        return NS_ERROR_FAILURE;
-      }
-      nsString msg;
-      switch (mStatus) {
-        case STARTING:
-          msg = NS_LITERAL_STRING("starting");
-          stream->OnTracksAvailable(mOnTracksAvailableCallback.forget());
-          break;
-        case STOPPING:
-          msg = NS_LITERAL_STRING("shutdown");
-          if (mListener) {
-            mListener->SetStopped();
-          }
-          break;
-      }
-      obs->NotifyObservers(nullptr,
-                           "recording-device-events",
-                           msg.get());
-      // Forward recording events to parent process.
-      // The events are gathered in chrome process and used for recording indicator
-      if (XRE_GetProcessType() != GeckoProcessType_Default) {
-        unused << mozilla::dom::ContentChild::GetSingleton()->SendRecordingDeviceEvents(msg);
-      }
-      return NS_OK;
-    }
+    NS_IMETHOD Run() MOZ_OVERRIDE;
 
   protected:
     nsRefPtr<GetUserMediaCallbackMediaStreamListener> mListener; // threadsafe
     nsRefPtr<DOMMediaStream> mStream;
     nsAutoPtr<DOMMediaStream::OnTracksAvailableCallback> mOnTracksAvailableCallback;
     GetUserMediaStatus mStatus;
 };