Back out revisions 042d50591265:69f4af72765c (bug 909645) due to Windows bustage causing a CLOSED TREE.
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 28 Aug 2013 01:46:00 -0400
changeset 157542 988f55f8196e70e7da0323f6ae08af9bce02f70b
parent 157541 c98af21f7072dee438f2861bf441eb24e752cc82
child 157543 0f0d1a9777667fe97e87b20105e18fccb8d0d544
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)
bugs909645
milestone26.0a1
backs out042d50591265a2ff09636fe835cf4784a867a6fb
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
Back out revisions 042d50591265:69f4af72765c (bug 909645) due to Windows bustage causing a CLOSED TREE.
content/media/webspeech/recognition/SpeechRecognition.cpp
content/media/webspeech/recognition/SpeechRecognition.h
content/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp
dom/base/nsGlobalWindow.cpp
dom/media/MediaManager.cpp
dom/media/MediaManager.h
dom/power/PowerManager.h
dom/src/geolocation/nsGeolocation.cpp
dom/src/geolocation/nsGeolocation.h
dom/src/notification/DesktopNotification.cpp
dom/src/notification/DesktopNotification.h
dom/system/gonk/AudioManager.cpp
hal/Hal.h
hal/gonk/GonkHal.cpp
hal/gonk/GonkSensor.cpp
hal/gonk/GonkSwitch.cpp
hal/linux/LinuxPower.cpp
toolkit/components/diskspacewatcher/DiskSpaceWatcher.cpp
widget/gonk/nsAppShell.cpp
--- a/content/media/webspeech/recognition/SpeechRecognition.cpp
+++ b/content/media/webspeech/recognition/SpeechRecognition.cpp
@@ -5,26 +5,22 @@
  * 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"
@@ -623,17 +619,18 @@ SpeechRecognition::ProcessTestEventReque
 already_AddRefed<SpeechGrammarList>
 SpeechRecognition::GetGrammars(ErrorResult& aRv) const
 {
   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
   return nullptr;
 }
 
 void
-SpeechRecognition::SetGrammars(SpeechGrammarList& aArg, ErrorResult& aRv)
+SpeechRecognition::SetGrammars(mozilla::dom::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,18 +8,17 @@
 
 #include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 #include "nsTArray.h"
 
-#include "nsIDOMNavigatorUserMedia.h"
-#include "nsITimer.h"
+#include "MediaManager.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,18 +7,16 @@
 #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/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -26,17 +26,16 @@
 #include "nsIPowerManagerService.h"
 #include "nsISizeOfEventTarget.h"
 #include "nsDOMJSUtils.h"
 #include "nsArrayUtils.h"
 #include "nsIDOMWindowCollection.h"
 #include "nsDOMWindowList.h"
 #include "nsIDOMWakeLock.h"
 #include "nsIDocShellTreeOwner.h"
-#include "nsIPermissionManager.h"
 #include "nsIScriptContext.h"
 #include "nsIScriptTimeoutHandler.h"
 
 #ifdef XP_WIN
 // Thanks so much, Microsoft! :(
 #ifdef GetClassName
 #undef GetClassName
 #endif // GetClassName
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -10,17 +10,16 @@
 #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"
 
@@ -1289,17 +1288,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 = services::GetObserverService();
+        nsCOMPtr<nsIObserverService> obs = mozilla::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));
@@ -1328,17 +1327,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 = services::GetObserverService();
+  nsCOMPtr<nsIObserverService> obs = mozilla::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));
     }
@@ -1598,48 +1597,9 @@ 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,13 +1,14 @@
 /* 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"
@@ -206,17 +207,54 @@ class GetUserMediaNotificationEvent: pub
                                   DOMMediaStream::OnTracksAvailableCallback* aOnTracksAvailableCallback)
     : mStream(aStream), mOnTracksAvailableCallback(aOnTracksAvailableCallback),
       mStatus(aStatus) {}
     virtual ~GetUserMediaNotificationEvent()
     {
 
     }
 
-    NS_IMETHOD Run() MOZ_OVERRIDE;
+    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;
+    }
 
   protected:
     nsRefPtr<GetUserMediaCallbackMediaStreamListener> mListener; // threadsafe
     nsRefPtr<DOMMediaStream> mStream;
     nsAutoPtr<DOMMediaStream::OnTracksAvailableCallback> mOnTracksAvailableCallback;
     GetUserMediaStatus mStatus;
 };
 
--- a/dom/power/PowerManager.h
+++ b/dom/power/PowerManager.h
@@ -6,17 +6,16 @@
 #define mozilla_dom_power_PowerManager_h
 
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 #include "nsIDOMPowerManager.h"
 #include "nsIDOMWakeLockListener.h"
 #include "nsIDOMWindow.h"
 #include "nsWeakReference.h"
-#include "nsCycleCollectionParticipant.h"
 
 class nsPIDOMWindow;
 
 namespace mozilla {
 namespace dom {
 namespace power {
 
 class PowerManager
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -18,17 +18,16 @@
 #include "nsIDocument.h"
 #include "nsIObserverService.h"
 #include "nsPIDOMWindow.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Services.h"
 #include "mozilla/unused.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ClearOnShutdown.h"
-#include "PCOMContentPermissionRequestChild.h"
 
 class nsIPrincipal;
 
 #ifdef MOZ_MAEMO_LIBLOCATION
 #include "MaemoLocationProvider.h"
 #endif
 
 #ifdef MOZ_ENABLE_QTMOBILITY
@@ -53,69 +52,21 @@ class nsIPrincipal;
 
 // The settings key.
 #define GEO_SETINGS_ENABLED          "geolocation.enabled"
 
 using mozilla::unused;          // <snicker>
 using namespace mozilla;
 using namespace mozilla::dom;
 
-class nsGeolocationRequest
- : public nsIContentPermissionRequest
- , public nsITimerCallback
- , public nsIGeolocationUpdate
- , public PCOMContentPermissionRequestChild
-{
- public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_NSICONTENTPERMISSIONREQUEST
-  NS_DECL_NSITIMERCALLBACK
-  NS_DECL_NSIGEOLOCATIONUPDATE
-
-  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsGeolocationRequest, nsIContentPermissionRequest)
-
-  nsGeolocationRequest(Geolocation* aLocator,
-                       const GeoPositionCallback& aCallback,
-                       const GeoPositionErrorCallback& aErrorCallback,
-                       idl::GeoPositionOptions* aOptions,
-                       bool aWatchPositionRequest = false,
-                       int32_t aWatchId = 0);
-  void Shutdown();
-
-  void SendLocation(nsIDOMGeoPosition* location);
-  bool WantsHighAccuracy() {return mOptions && mOptions->enableHighAccuracy;}
-  void SetTimeoutTimer();
-  nsIPrincipal* GetPrincipal();
-
-  ~nsGeolocationRequest();
-
-  virtual bool Recv__delete__(const bool& allow) MOZ_OVERRIDE;
-  virtual void IPDLRelease() MOZ_OVERRIDE { Release(); }
-
-  bool IsWatch() { return mIsWatchPositionRequest; }
-  int32_t WatchId() { return mWatchId; }
- private:
-  bool mIsWatchPositionRequest;
-
-  nsCOMPtr<nsITimer> mTimeoutTimer;
-  GeoPositionCallback mCallback;
-  GeoPositionErrorCallback mErrorCallback;
-  nsAutoPtr<idl::GeoPositionOptions> mOptions;
-
-  nsRefPtr<Geolocation> mLocator;
-
-  int32_t mWatchId;
-  bool mShutdown;
-};
-
-static idl::GeoPositionOptions*
+static mozilla::idl::GeoPositionOptions*
 GeoPositionOptionsFromPositionOptions(const PositionOptions& aOptions)
 {
-  nsAutoPtr<idl::GeoPositionOptions> geoOptions(
-    new idl::GeoPositionOptions());
+  nsAutoPtr<mozilla::idl::GeoPositionOptions> geoOptions(
+    new mozilla::idl::GeoPositionOptions());
 
   geoOptions->enableHighAccuracy = aOptions.mEnableHighAccuracy;
   geoOptions->maximumAge = aOptions.mMaximumAge;
   geoOptions->timeout = aOptions.mTimeout;
 
   return geoOptions.forget();
 }
 
@@ -335,17 +286,17 @@ PositionError::NotifyCallback(const GeoP
 }
 ////////////////////////////////////////////////////
 // nsGeolocationRequest
 ////////////////////////////////////////////////////
 
 nsGeolocationRequest::nsGeolocationRequest(Geolocation* aLocator,
                                            const GeoPositionCallback& aCallback,
                                            const GeoPositionErrorCallback& aErrorCallback,
-                                           idl::GeoPositionOptions* aOptions,
+                                           mozilla::idl::GeoPositionOptions* aOptions,
                                            bool aWatchPositionRequest,
                                            int32_t aWatchId)
   : mIsWatchPositionRequest(aWatchPositionRequest),
     mCallback(aCallback),
     mErrorCallback(aErrorCallback),
     mOptions(aOptions),
     mLocator(aLocator),
     mWatchId(aWatchId),
@@ -668,17 +619,17 @@ nsresult nsGeolocationService::Init()
     NS_ENSURE_SUCCESS(rv, rv);
   } else {
     // If we cannot obtain the settings service, we continue
     // assuming that the geolocation is enabled:
     sGeoInitPending = false;
   }
 
   // geolocation service can be enabled -> now register observer
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
+  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (!obs) {
     return NS_ERROR_FAILURE;
   }
 
   obs->AddObserver(this, "quit-application", false);
   obs->AddObserver(this, "mozsettings-changed", false);
 
 #ifdef MOZ_MAEMO_LIBLOCATION
@@ -777,17 +728,17 @@ nsGeolocationService::HandleMozsettingVa
 }
 
 NS_IMETHODIMP
 nsGeolocationService::Observe(nsISupports* aSubject,
                               const char* aTopic,
                               const PRUnichar* aData)
 {
   if (!strcmp("quit-application", aTopic)) {
-    nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
+    nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
       obs->RemoveObserver(this, "quit-application");
       obs->RemoveObserver(this, "mozsettings-changed");
     }
 
     for (uint32_t i = 0; i< mGeolocators.Length(); i++) {
       mGeolocators[i]->Shutdown();
     }
@@ -866,17 +817,17 @@ nsGeolocationService::StartDevice(nsIPri
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     ContentChild* cpc = ContentChild::GetSingleton();
     cpc->SendAddGeolocationListener(IPC::Principal(aPrincipal),
                                     HighAccuracyRequested());
     return NS_OK;
   }
 
   // Start them up!
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
+  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (!obs) {
     return NS_ERROR_FAILURE;
   }
 
   if (!mProvider) {
     return NS_ERROR_FAILURE;
   }
 
@@ -952,17 +903,17 @@ nsGeolocationService::StopDevice()
   }
 
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     ContentChild* cpc = ContentChild::GetSingleton();
     cpc->SendRemoveGeolocationListener();
     return; // bail early
   }
 
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
+  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (!obs) {
     return;
   }
 
   if (!mProvider) {
     return;
   }
 
@@ -1217,30 +1168,30 @@ Geolocation::GetCurrentPosition(Position
   }
 
   return;
 }
 
 NS_IMETHODIMP
 Geolocation::GetCurrentPosition(nsIDOMGeoPositionCallback* aCallback,
                                 nsIDOMGeoPositionErrorCallback* aErrorCallback,
-                                idl::GeoPositionOptions* aOptions)
+                                mozilla::idl::GeoPositionOptions* aOptions)
 {
   NS_ENSURE_ARG_POINTER(aCallback);
 
   GeoPositionCallback successCallback(aCallback);
   GeoPositionErrorCallback errorCallback(aErrorCallback);
 
   return GetCurrentPosition(successCallback, errorCallback, aOptions);
 }
 
 nsresult
 Geolocation::GetCurrentPosition(GeoPositionCallback& callback,
                                 GeoPositionErrorCallback& errorCallback,
-                                idl::GeoPositionOptions *options)
+                                mozilla::idl::GeoPositionOptions *options)
 {
   if (mPendingCallbacks.Length() > MAX_GEO_REQUESTS_PER_WINDOW) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   nsRefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this,
                                                                     callback,
                                                                     errorCallback,
@@ -1306,31 +1257,31 @@ Geolocation::WatchPosition(PositionCallb
   }
 
   return ret;
 }
 
 NS_IMETHODIMP
 Geolocation::WatchPosition(nsIDOMGeoPositionCallback *aCallback,
                            nsIDOMGeoPositionErrorCallback *aErrorCallback,
-                           idl::GeoPositionOptions *aOptions,
+                           mozilla::idl::GeoPositionOptions *aOptions,
                            int32_t* aRv)
 {
   NS_ENSURE_ARG_POINTER(aCallback);
 
   GeoPositionCallback successCallback(aCallback);
   GeoPositionErrorCallback errorCallback(aErrorCallback);
 
   return WatchPosition(successCallback, errorCallback, aOptions, aRv);
 }
 
 nsresult
 Geolocation::WatchPosition(GeoPositionCallback& aCallback,
                            GeoPositionErrorCallback& aErrorCallback,
-                           idl::GeoPositionOptions* aOptions,
+                           mozilla::idl::GeoPositionOptions* aOptions,
                            int32_t* aRv)
 {
   if (mWatchingCallbacks.Length() > MAX_GEO_REQUESTS_PER_WINDOW) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // The watch ID:
   *aRv = mLastWatchId++;
@@ -1504,10 +1455,10 @@ Geolocation::RegisterRequestWithPrompt(n
   nsCOMPtr<nsIRunnable> ev  = new RequestPromptEvent(request);
   NS_DispatchToMainThread(ev);
   return true;
 }
 
 JSObject*
 Geolocation::WrapObject(JSContext *aCtx, JS::Handle<JSObject*> aScope)
 {
-  return GeolocationBinding::Wrap(aCtx, aScope, this);
+  return mozilla::dom::GeolocationBinding::Wrap(aCtx, aScope, this);
 }
--- a/dom/src/geolocation/nsGeolocation.h
+++ b/dom/src/geolocation/nsGeolocation.h
@@ -28,29 +28,77 @@
 #include "mozilla/dom/GeolocationBinding.h"
 #include "mozilla/dom/PositionErrorBinding.h"
 #include "mozilla/dom/CallbackObject.h"
 
 #include "nsIGeolocationProvider.h"
 #include "nsIContentPermissionPrompt.h"
 #include "nsIDOMWindow.h"
 #include "DictionaryHelpers.h"
+#include "PCOMContentPermissionRequestChild.h"
 #include "mozilla/Attributes.h"
 
 class nsGeolocationService;
-class nsGeolocationRequest;
 
 namespace mozilla {
 namespace dom {
 class Geolocation;
 typedef CallbackObjectHolder<PositionCallback, nsIDOMGeoPositionCallback> GeoPositionCallback;
 typedef CallbackObjectHolder<PositionErrorCallback, nsIDOMGeoPositionErrorCallback> GeoPositionErrorCallback;
 }
 }
 
+class nsGeolocationRequest
+ : public nsIContentPermissionRequest
+ , public nsITimerCallback
+ , public nsIGeolocationUpdate
+ , public PCOMContentPermissionRequestChild
+{
+ public:
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_NSICONTENTPERMISSIONREQUEST
+  NS_DECL_NSITIMERCALLBACK
+  NS_DECL_NSIGEOLOCATIONUPDATE
+
+  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsGeolocationRequest, nsIContentPermissionRequest)
+
+  nsGeolocationRequest(mozilla::dom::Geolocation* locator,
+                       const mozilla::dom::GeoPositionCallback& callback,
+                       const mozilla::dom::GeoPositionErrorCallback& errorCallback,
+                       mozilla::idl::GeoPositionOptions* aOptions,
+                       bool watchPositionRequest = false,
+                       int32_t watchId = 0);
+  void Shutdown();
+
+  void SendLocation(nsIDOMGeoPosition* location);
+  bool WantsHighAccuracy() {return mOptions && mOptions->enableHighAccuracy;}
+  void SetTimeoutTimer();
+  nsIPrincipal* GetPrincipal();
+
+  ~nsGeolocationRequest();
+
+  virtual bool Recv__delete__(const bool& allow) MOZ_OVERRIDE;
+  virtual void IPDLRelease() MOZ_OVERRIDE { Release(); }
+
+  bool IsWatch() { return mIsWatchPositionRequest; }
+  int32_t WatchId() { return mWatchId; }
+ private:
+  bool mIsWatchPositionRequest;
+
+  nsCOMPtr<nsITimer> mTimeoutTimer;
+  mozilla::dom::GeoPositionCallback mCallback;
+  mozilla::dom::GeoPositionErrorCallback mErrorCallback;
+  nsAutoPtr<mozilla::idl::GeoPositionOptions> mOptions;
+
+  nsRefPtr<mozilla::dom::Geolocation> mLocator;
+
+  int32_t mWatchId;
+  bool mShutdown;
+};
+
 /**
  * Singleton that manages the geolocation provider
  */
 class nsGeolocationService MOZ_FINAL : public nsIGeolocationUpdate, public nsIObserver
 {
 public:
 
   static already_AddRefed<nsGeolocationService> GetGeolocationService();
--- a/dom/src/notification/DesktopNotification.cpp
+++ b/dom/src/notification/DesktopNotification.cpp
@@ -6,64 +6,19 @@
 #include "nsContentPermissionHelper.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/dom/PBrowserChild.h"
 #include "nsIDOMDesktopNotification.h"
 #include "TabChild.h"
 #include "mozilla/Preferences.h"
 #include "nsGlobalWindow.h"
 #include "nsIAppsService.h"
-#include "PCOMContentPermissionRequestChild.h"
-
 namespace mozilla {
 namespace dom {
 
-/*
- * Simple Request
- */
-class DesktopNotificationRequest : public nsIContentPermissionRequest,
-                                   public nsRunnable,
-                                   public PCOMContentPermissionRequestChild
-
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSICONTENTPERMISSIONREQUEST
-
-  DesktopNotificationRequest(DesktopNotification* notification)
-    : mDesktopNotification(notification) {}
-
-  NS_IMETHOD Run() MOZ_OVERRIDE
-  {
-    nsCOMPtr<nsIContentPermissionPrompt> prompt =
-      do_CreateInstance(NS_CONTENT_PERMISSION_PROMPT_CONTRACTID);
-    if (prompt) {
-      prompt->Prompt(this);
-    }
-    return NS_OK;
-  }
-
-  ~DesktopNotificationRequest()
-  {
-  }
-
-  virtual bool Recv__delete__(const bool& aAllow) MOZ_OVERRIDE
-  {
-    if (aAllow) {
-      (void) Allow();
-    } else {
-     (void) Cancel();
-    }
-   return true;
-  }
-  virtual void IPDLRelease() MOZ_OVERRIDE { Release(); }
-
-  nsRefPtr<DesktopNotification> mDesktopNotification;
-};
-
 /* ------------------------------------------------------------------------ */
 /* AlertServiceObserver                                                     */
 /* ------------------------------------------------------------------------ */
 
 NS_IMPL_ISUPPORTS1(AlertServiceObserver, nsIObserver)
 
 /* ------------------------------------------------------------------------ */
 /* DesktopNotification                                                      */
--- a/dom/src/notification/DesktopNotification.h
+++ b/dom/src/notification/DesktopNotification.h
@@ -1,15 +1,17 @@
 /* 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/. */
 
 #ifndef mozilla_dom_DesktopNotification_h
 #define mozilla_dom_DesktopNotification_h
 
+#include "PCOMContentPermissionRequestChild.h"
+
 #include "nsIPrincipal.h"
 #include "nsIAlertsService.h"
 #include "nsIContentPermissionPrompt.h"
 
 #include "nsIObserver.h"
 #include "nsString.h"
 #include "nsWeakPtr.h"
 #include "nsCycleCollectionParticipant.h"
@@ -77,17 +79,16 @@ public:
                      const nsAString& description,
                      const nsAString& iconURL);
 
 private:
   nsCOMPtr<nsPIDOMWindow> mOwner;
   nsCOMPtr<nsIPrincipal> mPrincipal;
 };
 
-class DesktopNotificationRequest;
 
 class DesktopNotification MOZ_FINAL : public nsDOMEventTargetHelper
 {
   friend class DesktopNotificationRequest;
 
 public:
 
   DesktopNotification(const nsAString& aTitle,
@@ -139,16 +140,58 @@ protected:
   nsRefPtr<AlertServiceObserver> mObserver;
   nsCOMPtr<nsIPrincipal> mPrincipal;
   bool mAllow;
   bool mShowHasBeenCalled;
 
   static uint32_t sCount;
 };
 
+/*
+ * Simple Request
+ */
+class DesktopNotificationRequest : public nsIContentPermissionRequest,
+                                   public nsRunnable,
+                                   public PCOMContentPermissionRequestChild
+
+{
+ public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSICONTENTPERMISSIONREQUEST
+
+  DesktopNotificationRequest(DesktopNotification* notification)
+    : mDesktopNotification(notification) {}
+
+  NS_IMETHOD Run() MOZ_OVERRIDE
+  {
+    nsCOMPtr<nsIContentPermissionPrompt> prompt =
+      do_CreateInstance(NS_CONTENT_PERMISSION_PROMPT_CONTRACTID);
+    if (prompt) {
+      prompt->Prompt(this);
+    }
+    return NS_OK;
+  }
+
+  ~DesktopNotificationRequest()
+  {
+  }
+
+ virtual bool Recv__delete__(const bool& allow) MOZ_OVERRIDE
+ {
+   if (allow)
+     (void) Allow();
+   else
+     (void) Cancel();
+   return true;
+ }
+ virtual void IPDLRelease() MOZ_OVERRIDE { Release(); }
+
+  nsRefPtr<DesktopNotification> mDesktopNotification;
+};
+
 class AlertServiceObserver: public nsIObserver
 {
  public:
   NS_DECL_ISUPPORTS
 
     AlertServiceObserver(DesktopNotification* notification)
     : mNotification(notification) {}
 
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -27,17 +27,16 @@
 #include "base/message_loop.h"
 
 #include "BluetoothCommon.h"
 #include "BluetoothProfileManagerBase.h"
 #include "BluetoothHfpManager.h"
 
 #include "nsJSUtils.h"
 #include "nsCxPusher.h"
-#include "nsThreadUtils.h"
 
 using namespace mozilla::dom::gonk;
 using namespace android;
 using namespace mozilla::hal;
 using namespace mozilla;
 using namespace mozilla::dom::bluetooth;
 
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "AudioManager" , ## args)
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -11,16 +11,17 @@
 #include "mozilla/HalTypes.h"
 #include "base/basictypes.h"
 #include "mozilla/Types.h"
 #include "nsTArray.h"
 #include "prlog.h"
 #include "mozilla/dom/battery/Types.h"
 #include "mozilla/dom/network/Types.h"
 #include "mozilla/dom/power/Types.h"
+#include "mozilla/dom/ContentParent.h"
 #include "mozilla/hal_sandbox/PHal.h"
 #include "mozilla/dom/ScreenOrientation.h"
 
 /*
  * Hal.h contains the public Hal API.
  *
  * By default, this file defines its functions in the hal namespace, but if
  * MOZ_HAL_NAMESPACE is defined, we'll define our functions in that namespace.
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -38,17 +38,16 @@
 
 #include "base/message_loop.h"
 
 #include "Hal.h"
 #include "HalImpl.h"
 #include "mozilla/dom/battery/Constants.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/Monitor.h"
-#include "mozilla/RefPtr.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/Preferences.h"
 #include "nsAlgorithm.h"
 #include "nsPrintfCString.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIRecoveryService.h"
--- a/hal/gonk/GonkSensor.cpp
+++ b/hal/gonk/GonkSensor.cpp
@@ -20,17 +20,16 @@
 #include "mozilla/DebugOnly.h"
 
 #include "base/basictypes.h"
 #include "base/thread.h"
 
 #include "Hal.h"
 #include "HalSensor.h"
 #include "hardware/sensors.h"
-#include "nsThreadUtils.h"
 
 #undef LOG
 
 #include <android/log.h>
 
 using namespace mozilla::hal;
 
 #define LOGE(args...)  __android_log_print(ANDROID_LOG_ERROR, "GonkSensor" , ## args)
--- a/hal/gonk/GonkSwitch.cpp
+++ b/hal/gonk/GonkSwitch.cpp
@@ -17,21 +17,19 @@
 #include <android/log.h>
 #include <fcntl.h>
 #include <sysutils/NetlinkEvent.h>
 
 #include "base/message_loop.h"
 
 #include "Hal.h"
 #include "mozilla/FileUtils.h"
-#include "mozilla/RefPtr.h"
 #include "mozilla/Monitor.h"
 #include "nsPrintfCString.h"
 #include "nsXULAppAPI.h"
-#include "nsThreadUtils.h"
 #include "UeventPoller.h"
 
 using namespace mozilla::hal;
 
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "GonkSwitch" , ## args) 
 
 #define SWITCH_HEADSET_DEVPATH "/devices/virtual/switch/h2w"
 #define SWITCH_USB_DEVPATH_GB  "/devices/virtual/switch/usb_configuration"
--- a/hal/linux/LinuxPower.cpp
+++ b/hal/linux/LinuxPower.cpp
@@ -3,17 +3,16 @@
  * 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 "Hal.h"
 
 #include <unistd.h>
 #include <sys/reboot.h>
 #include "nsIObserverService.h"
-#include "mozilla/Services.h"
 
 namespace mozilla {
 namespace hal_impl {
 
 void
 Reboot()
 {
   nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService();
--- a/toolkit/components/diskspacewatcher/DiskSpaceWatcher.cpp
+++ b/toolkit/components/diskspacewatcher/DiskSpaceWatcher.cpp
@@ -1,20 +1,17 @@
 /* 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 "DiskSpaceWatcher.h"
-#include "nsIObserverService.h"
-#include "nsXULAppAPI.h"
 #include "mozilla/Hal.h"
 #include "mozilla/ModuleUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ClearOnShutdown.h"
-#include "mozilla/Services.h"
 
 #define NS_DISKSPACEWATCHER_CID \
   { 0xab218518, 0xf197, 0x4fb4, { 0x8b, 0x0f, 0x8b, 0xb3, 0x4d, 0xf2, 0x4b, 0xf4 } }
 
 using namespace mozilla;
 
 StaticRefPtr<DiskSpaceWatcher> gDiskSpaceWatcher;
 
--- a/widget/gonk/nsAppShell.cpp
+++ b/widget/gonk/nsAppShell.cpp
@@ -39,17 +39,16 @@
 #include "mozilla/Services.h"
 #include "nsAppShell.h"
 #include "mozilla/dom/Touch.h"
 #include "nsGkAtoms.h"
 #include "nsGUIEvent.h"
 #include "nsIObserverService.h"
 #include "nsIScreen.h"
 #include "nsScreenManagerGonk.h"
-#include "nsThreadUtils.h"
 #include "nsWindow.h"
 #include "OrientationObserver.h"
 #include "GonkMemoryPressureMonitoring.h"
 
 #include "android/log.h"
 #include "libui/EventHub.h"
 #include "libui/InputReader.h"
 #include "libui/InputDispatcher.h"