Bug 913847 - stop needlessly including nsThreadUtils.h - r=ehsan
☠☠ backed out by beb3f7611ea4 ☠ ☠
authorBenoit Jacob <bjacob@mozilla.com>
Wed, 18 Sep 2013 18:50:32 -0400
changeset 147814 554bfe767519cb699b62a73cba8cd7d95b3bfc7f
parent 147813 8dd27d839acc22b5303b366afb9a3968e5e219fc
child 147815 4eb44a3149ed0a6dfa637fc572c2f6eaf63e4701
push id25317
push useremorley@mozilla.com
push dateThu, 19 Sep 2013 14:37:38 +0000
treeherdermozilla-central@70a765607344 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs913847
milestone27.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 913847 - stop needlessly including nsThreadUtils.h - r=ehsan
content/base/src/nsDOMFile.cpp
content/base/src/nsDocument.h
content/base/src/nsInProcessTabChildGlobal.h
content/html/content/public/HTMLMediaElement.h
content/media/dash/DASHDecoder.h
dom/camera/CameraCommon.h
dom/file/FileHelper.cpp
dom/file/FileHelper.h
dom/indexedDB/FileInfo.cpp
dom/indexedDB/FileInfo.h
dom/plugins/ipc/PluginHangUIParent.cpp
dom/plugins/ipc/PluginMessageUtils.h
dom/quota/QuotaManager.h
dom/src/notification/DesktopNotification.h
gfx/layers/ImageContainer.h
gfx/thebes/gfxFontUtils.h
media/mtransport/transportflow.h
media/mtransport/transportlayer.cpp
media/mtransport/transportlayer.h
mobile/android/components/build/nsAndroidHistory.cpp
mobile/android/components/build/nsAndroidHistory.h
netwerk/base/src/Dashboard.cpp
netwerk/base/src/EventTokenBucket.cpp
netwerk/base/src/Tickler.cpp
netwerk/base/src/Tickler.h
netwerk/base/src/nsSocketTransport2.cpp
netwerk/base/src/nsSocketTransportService2.cpp
netwerk/base/src/nsSocketTransportService2.h
netwerk/base/src/nsUDPServerSocket.h
netwerk/ipc/ChannelEventQueue.cpp
netwerk/ipc/ChannelEventQueue.h
netwerk/protocol/http/nsHttpChannel.h
parser/html/nsHtml5Parser.h
storage/src/mozStorageAsyncStatementExecution.h
toolkit/components/places/nsNavHistory.h
widget/android/AndroidBridge.h
widget/windows/JumpListBuilder.h
widget/windows/WinUtils.cpp
widget/windows/WinUtils.h
widget/windows/nsSound.cpp
widget/windows/nsSound.h
--- a/content/base/src/nsDOMFile.cpp
+++ b/content/base/src/nsDOMFile.cpp
@@ -30,16 +30,17 @@
 #include "nsHostObjectProtocolHandler.h"
 #include "nsStringStream.h"
 #include "nsJSUtils.h"
 #include "nsPrintfCString.h"
 #include "mozilla/SHA1.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Attributes.h"
+#include "nsThreadUtils.h"
 
 #include "mozilla/dom/FileListBinding.h"
 using namespace mozilla;
 using namespace mozilla::dom;
 
 // XXXkhuey the input stream that we pass out of a DOMFile
 // can outlive the actual DOMFile object.  Thus, we must
 // ensure that the buffer underlying the stream we get
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -48,17 +48,16 @@
 #include "nsContentList.h"
 #include "nsGkAtoms.h"
 #include "nsIApplicationCache.h"
 #include "nsIApplicationCacheContainer.h"
 #include "nsStyleSet.h"
 #include "pldhash.h"
 #include "nsAttrAndChildArray.h"
 #include "nsDOMAttributeMap.h"
-#include "nsThreadUtils.h"
 #include "nsIContentViewer.h"
 #include "nsIDOMXPathNSResolver.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsILoadContext.h"
 #include "nsIProgressEventSink.h"
 #include "nsISecurityEventSink.h"
 #include "nsIChannelEventSink.h"
 #include "imgIRequest.h"
--- a/content/base/src/nsInProcessTabChildGlobal.h
+++ b/content/base/src/nsInProcessTabChildGlobal.h
@@ -13,17 +13,17 @@
 #include "nsIScriptContext.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptContext.h"
 #include "nsIClassInfo.h"
 #include "nsIDocShell.h"
 #include "nsIDOMElement.h"
 #include "nsCOMArray.h"
-#include "nsThreadUtils.h"
+#include "nsIRunnable.h"
 #include "nsIGlobalObject.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsWeakReference.h"
 
 class nsInProcessTabChildGlobal : public nsDOMEventTargetHelper,
                                   public nsFrameScriptExecutor,
                                   public nsIInProcessContentFrameMessageManager,
                                   public nsIGlobalObject,
--- a/content/html/content/public/HTMLMediaElement.h
+++ b/content/html/content/public/HTMLMediaElement.h
@@ -6,17 +6,16 @@
 #ifndef mozilla_dom_HTMLMediaElement_h
 #define mozilla_dom_HTMLMediaElement_h
 
 #include "nsIDOMHTMLMediaElement.h"
 #include "nsGenericHTMLElement.h"
 #include "MediaDecoderOwner.h"
 #include "nsIChannel.h"
 #include "nsIHttpChannel.h"
-#include "nsThreadUtils.h"
 #include "nsIDOMRange.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsILoadGroup.h"
 #include "nsIObserver.h"
 #include "AudioStream.h"
 #include "VideoFrameContainer.h"
 #include "mozilla/CORSMode.h"
 #include "DOMMediaStream.h"
@@ -40,16 +39,17 @@ typedef uint16_t nsMediaReadyState;
 
 namespace mozilla {
 class MediaResource;
 class MediaDecoder;
 }
 
 class nsITimer;
 class nsRange;
+class nsIRunnable;
 
 namespace mozilla {
 namespace dom {
 
 class MediaError;
 class MediaSource;
 
 class HTMLMediaElement : public nsGenericHTMLElement,
--- a/content/media/dash/DASHDecoder.h
+++ b/content/media/dash/DASHDecoder.h
@@ -13,17 +13,16 @@
  * see DASHDecoder.cpp for info on DASH interaction with the media engine.*/
 
 #if !defined(DASHDecoder_h_)
 #define DASHDecoder_h_
 
 #include "nsTArray.h"
 #include "nsIURI.h"
 #include "nsITimer.h"
-#include "nsThreadUtils.h"
 #include "MediaDecoder.h"
 #include "DASHReader.h"
 
 namespace mozilla {
 namespace net {
 class IMPDManager;
 class nsDASHMPDParser;
 class Representation;
--- a/dom/camera/CameraCommon.h
+++ b/dom/camera/CameraCommon.h
@@ -14,17 +14,16 @@
 #define __func__ __FILE__
 #endif
 #endif
 
 #ifndef NAN
 #define NAN std::numeric_limits<double>::quiet_NaN()
 #endif
 
-#include "nsThreadUtils.h"
 #include "nsIDOMCameraManager.h"
 #include "prlog.h"
 
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* GetCameraLog();
 #define DOM_CAMERA_LOG( type, ... ) PR_LOG(GetCameraLog(), (PRLogModuleLevel)type, ( __VA_ARGS__ ))
 #else
 #define DOM_CAMERA_LOG( type, ... )
--- a/dom/file/FileHelper.cpp
+++ b/dom/file/FileHelper.cpp
@@ -10,16 +10,17 @@
 
 #include "nsError.h"
 #include "nsProxyRelease.h"
 
 #include "FileHandle.h"
 #include "FileRequest.h"
 #include "FileService.h"
 #include "nsIRequest.h"
+#include "nsThreadUtils.h"
 
 USING_FILE_NAMESPACE
 
 namespace {
 
 LockedFile* gCurrentLockedFile = nullptr;
 
 } // anonymous namespace
@@ -204,8 +205,22 @@ FileHelper::Finish()
   mListener->OnFileHelperComplete(this);
 
   ReleaseObjects();
 
   NS_ASSERTION(!(mFileStorage || mLockedFile || mFileRequest || mListener ||
                  mRequest), "Subclass didn't call FileHelper::ReleaseObjects!");
 
 }
+
+void
+FileHelper::OnStreamClose()
+{
+  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
+  Finish();
+}
+
+void
+FileHelper::OnStreamDestroy()
+{
+  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
+  Finish();
+}
--- a/dom/file/FileHelper.h
+++ b/dom/file/FileHelper.h
@@ -5,17 +5,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_file_filehelper_h__
 #define mozilla_dom_file_filehelper_h__
 
 #include "FileCommon.h"
 
 #include "nsIRequestObserver.h"
-#include "nsThreadUtils.h"
 
 class nsIFileStorage;
 
 BEGIN_FILE_NAMESPACE
 
 class FileHelper;
 class FileRequest;
 class FileOutputStreamWrapper;
@@ -53,28 +52,20 @@ public:
 
   nsresult
   AsyncRun(FileHelperListener* aListener);
 
   void
   OnStreamProgress(uint64_t aProgress, uint64_t aProgressMax);
 
   void
-  OnStreamClose()
-  {
-    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-    Finish();
-  }
+  OnStreamClose();
 
   void
-  OnStreamDestroy()
-  {
-    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-    Finish();
-  }
+  OnStreamDestroy();
 
   static LockedFile*
   GetCurrentLockedFile();
 
 protected:
   FileHelper(LockedFile* aLockedFile, FileRequest* aRequest);
 
   virtual ~FileHelper();
--- a/dom/indexedDB/FileInfo.cpp
+++ b/dom/indexedDB/FileInfo.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* 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 "FileInfo.h"
-
+#include "nsThreadUtils.h"
 #include "mozilla/dom/quota/QuotaManager.h"
 
 USING_INDEXEDDB_NAMESPACE
 
 // static
 FileInfo*
 FileInfo::Create(FileManager* aFileManager, int64_t aId)
 {
--- a/dom/indexedDB/FileInfo.h
+++ b/dom/indexedDB/FileInfo.h
@@ -4,18 +4,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/. */
 
 #ifndef mozilla_dom_indexeddb_fileinfo_h__
 #define mozilla_dom_indexeddb_fileinfo_h__
 
 #include "IndexedDatabase.h"
 
-#include "nsThreadUtils.h"
-
 #include "FileManager.h"
 #include "IndexedDatabaseManager.h"
 
 BEGIN_INDEXEDDB_NAMESPACE
 
 class FileInfo
 {
   friend class FileManager;
--- a/dom/plugins/ipc/PluginHangUIParent.cpp
+++ b/dom/plugins/ipc/PluginHangUIParent.cpp
@@ -13,16 +13,17 @@
 
 #include "nsContentUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsIFile.h"
 #include "nsIProperties.h"
 #include "nsIWindowMediator.h"
 #include "nsIWinTaskbar.h"
 #include "nsServiceManagerUtils.h"
+#include "nsThreadUtils.h"
 
 #include "WidgetUtils.h"
 
 #define NS_TASKBAR_CONTRACTID "@mozilla.org/windows-taskbar;1"
 
 using base::ProcessHandle;
 
 using mozilla::widget::WidgetUtils;
--- a/dom/plugins/ipc/PluginMessageUtils.h
+++ b/dom/plugins/ipc/PluginMessageUtils.h
@@ -15,17 +15,16 @@
 #include "gfxipc/ShadowLayerUtils.h"
 
 #include "npapi.h"
 #include "npruntime.h"
 #include "npfunctions.h"
 #include "nsAutoPtr.h"
 #include "nsStringGlue.h"
 #include "nsTArray.h"
-#include "nsThreadUtils.h"
 #include "prlog.h"
 #include "nsHashKeys.h"
 #ifdef MOZ_CRASHREPORTER
 #  include "nsExceptionHandler.h"
 #endif
 #ifdef XP_MACOSX
 #include "PluginInterposeOSX.h"
 #else
--- a/dom/quota/QuotaManager.h
+++ b/dom/quota/QuotaManager.h
@@ -12,32 +12,32 @@
 #include "nsIObserver.h"
 #include "nsIQuotaManager.h"
 
 #include "mozilla/dom/Nullable.h"
 #include "mozilla/Mutex.h"
 
 #include "nsClassHashtable.h"
 #include "nsRefPtrHashtable.h"
-#include "nsThreadUtils.h"
 
 #include "ArrayCluster.h"
 #include "Client.h"
 #include "PersistenceType.h"
 #include "StoragePrivilege.h"
 
 #define QUOTA_MANAGER_CONTRACTID "@mozilla.org/dom/quota/manager;1"
 
 class nsIAtom;
 class nsIOfflineStorage;
 class nsIPrincipal;
 class nsIThread;
 class nsITimer;
 class nsIURI;
 class nsPIDOMWindow;
+class nsIRunnable;
 
 BEGIN_QUOTA_NAMESPACE
 
 class AcquireListener;
 class AsyncUsageRunnable;
 class CheckQuotaHelper;
 class CollectOriginsHelper;
 class FinalizeOriginEvictionRunnable;
--- a/dom/src/notification/DesktopNotification.h
+++ b/dom/src/notification/DesktopNotification.h
@@ -10,17 +10,16 @@
 #include "nsIContentPermissionPrompt.h"
 
 #include "nsIObserver.h"
 #include "nsString.h"
 #include "nsWeakPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIDOMWindow.h"
 #include "nsIScriptObjectPrincipal.h"
-#include "nsThreadUtils.h"
 
 #include "nsDOMEventTargetHelper.h"
 #include "nsIDOMEvent.h"
 #include "nsIDocument.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "nsWrapperCache.h"
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -20,17 +20,16 @@
 #include "nsAutoPtr.h"                  // for nsRefPtr, nsAutoArrayPtr, etc
 #include "nsAutoRef.h"                  // for nsCountedRef
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupportsImpl.h"            // for Image::Release, etc
 #include "nsRect.h"                     // for nsIntRect
 #include "nsSize.h"                     // for nsIntSize
 #include "nsTArray.h"                   // for nsTArray
-#include "nsThreadUtils.h"              // for NS_IsMainThread
 #include "mozilla/Atomics.h"
 
 class nsMainThreadSurfaceRef;
 
 #ifdef XP_WIN
 struct ID3D10Texture2D;
 struct ID3D10Device;
 struct ID3D10ShaderResourceView;
@@ -812,17 +811,16 @@ public:
   {
     mSurface = aData.mSurface;
     mSize = aData.mSize;
   }
 
 
   virtual already_AddRefed<gfxASurface> GetAsSurface()
   {
-    NS_ASSERTION(NS_IsMainThread(), "Must be main thread");
     nsRefPtr<gfxASurface> surface = mSurface.get();
     return surface.forget();
   }
 
   gfxIntSize GetSize() { return mSize; }
 
   CairoImage() : Image(nullptr, CAIRO_SURFACE) {}
 
--- a/gfx/thebes/gfxFontUtils.h
+++ b/gfx/thebes/gfxFontUtils.h
@@ -11,18 +11,16 @@
 
 #include "nsAlgorithm.h"
 #include "prcpucfg.h"
 
 #include "nsDataHashtable.h"
 
 #include "nsITimer.h"
 #include "nsCOMPtr.h"
-#include "nsIRunnable.h"
-#include "nsThreadUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsTArray.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Endian.h"
 #include "mozilla/MemoryReporting.h"
 
 #include "zlib.h"
--- a/media/mtransport/transportflow.h
+++ b/media/mtransport/transportflow.h
@@ -13,16 +13,17 @@
 #include <queue>
 #include <string>
 
 #include "nscore.h"
 #include "nsISupportsImpl.h"
 #include "mozilla/Scoped.h"
 #include "transportlayer.h"
 #include "m_cpp_utils.h"
+#include "nsAutoPtr.h"
 
 // A stack of transport layers acts as a flow.
 // Generally, one reads and writes to the top layer.
 
 // This code has a confusing hybrid threading model which
 // probably needs some eventual refactoring.
 // TODO(ekr@rtfm.com): Bug 844891
 //
--- a/media/mtransport/transportlayer.cpp
+++ b/media/mtransport/transportlayer.cpp
@@ -3,16 +3,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/. */
 
 // Original author: ekr@rtfm.com
 #include "logging.h"
 #include "transportflow.h"
 #include "transportlayer.h"
+#include "nsThreadUtils.h"
 
 // Logging context
 namespace mozilla {
 
 MOZ_MTLOG_MODULE("mtransport")
 
 nsresult TransportLayer::Init() {
   if (state_ != TS_NONE)
@@ -41,9 +42,24 @@ void TransportLayer::Inserted(TransportF
 void TransportLayer::SetState(State state) {
   if (state != state_) {
     MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "state " << state_ << "->" << state);
     state_ = state;
     SignalStateChange(this, state);
   }
 }
 
+nsresult TransportLayer::RunOnThread(nsIRunnable *event) {
+  if (target_) {
+    nsIThread *thr;
+
+    DebugOnly<nsresult> rv = NS_GetCurrentThread(&thr);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
+
+    if (target_ != thr) {
+      return target_->Dispatch(event, NS_DISPATCH_SYNC);
+    }
+  }
+
+  return event->Run();
+}
+
 }  // close namespace
--- a/media/mtransport/transportlayer.h
+++ b/media/mtransport/transportlayer.h
@@ -10,17 +10,16 @@
 #define transportlayer_h__
 
 #include "sigslot.h"
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/RefPtr.h"
 #include "nsCOMPtr.h"
 #include "nsIEventTarget.h"
-#include "nsThreadUtils.h"
 
 #include "m_cpp_utils.h"
 
 namespace mozilla {
 
 class TransportFlow;
 
 typedef int TransportResult;
@@ -57,30 +56,17 @@ class TransportLayer : public sigslot::h
   // Called when inserted into a flow
   virtual void Inserted(TransportFlow *flow, TransportLayer *downward);
 
   // Downward interface
   TransportLayer *downward() { return downward_; }
 
   // Dispatch a call onto our thread (or run on the same thread if
   // thread is not set). This is always synchronous.
-  nsresult RunOnThread(nsIRunnable *event) {
-    if (target_) {
-      nsIThread *thr;
-
-      DebugOnly<nsresult> rv = NS_GetCurrentThread(&thr);
-      MOZ_ASSERT(NS_SUCCEEDED(rv));
-
-      if (target_ != thr) {
-        return target_->Dispatch(event, NS_DISPATCH_SYNC);
-      }
-    }
-
-    return event->Run();
-  }
+  nsresult RunOnThread(nsIRunnable *event);
 
   // Get the state
   State state() const { return state_; }
   // Must be implemented by derived classes
   virtual TransportResult SendPacket(const unsigned char *data, size_t len) = 0;
 
   // Get the thread.
   const nsCOMPtr<nsIEventTarget> GetThread() const {
--- a/mobile/android/components/build/nsAndroidHistory.cpp
+++ b/mobile/android/components/build/nsAndroidHistory.cpp
@@ -1,12 +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 "nsThreadUtils.h"
 #include "nsAndroidHistory.h"
 #include "AndroidBridge.h"
 #include "Link.h"
 #include "nsIURI.h"
 
 using namespace mozilla;
 using mozilla::dom::Link;
 
--- a/mobile/android/components/build/nsAndroidHistory.h
+++ b/mobile/android/components/build/nsAndroidHistory.h
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef NS_ANDROIDHISTORY_H
 #define NS_ANDROIDHISTORY_H
 
 #include "IHistory.h"
 #include "nsDataHashtable.h"
 #include "nsTPriorityQueue.h"
-#include "nsThreadUtils.h"
+#include "nsIRunnable.h"
 
 #define NS_ANDROIDHISTORY_CID \
     {0xCCAA4880, 0x44DD, 0x40A7, {0xA1, 0x3F, 0x61, 0x56, 0xFC, 0x88, 0x2C, 0x0B}}
 
 class nsAndroidHistory : public mozilla::IHistory, public nsIRunnable
 {
 public:
   NS_DECL_ISUPPORTS
--- a/netwerk/base/src/Dashboard.cpp
+++ b/netwerk/base/src/Dashboard.cpp
@@ -5,16 +5,17 @@
 #include "mozilla/dom/NetDashboardBinding.h"
 #include "mozilla/net/Dashboard.h"
 #include "mozilla/net/HttpInfo.h"
 #include "nsCxPusher.h"
 #include "nsHttp.h"
 #include "nsIDNSService.h"
 #include "nsIThread.h"
 #include "nsSocketTransport2.h"
+#include "nsThreadUtils.h"
 
 using mozilla::AutoSafeJSContext;
 namespace mozilla {
 namespace net {
 
 NS_IMPL_ISUPPORTS5(Dashboard, nsIDashboard, nsIDashboardEventNotifier,
                               nsITransportEventSink, nsITimerCallback,
                               nsIDNSListener)
--- a/netwerk/base/src/EventTokenBucket.cpp
+++ b/netwerk/base/src/EventTokenBucket.cpp
@@ -3,16 +3,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 "EventTokenBucket.h"
 
 #include "nsNetUtil.h"
 #include "nsSocketTransportService2.h"
+#include "nsThreadUtils.h"
 
 #ifdef XP_WIN
 #include <windows.h>
 #include <mmsystem.h>
 #endif
 
 extern PRThread *gSocketThread;
 
--- a/netwerk/base/src/Tickler.cpp
+++ b/netwerk/base/src/Tickler.cpp
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsComponentManagerUtils.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsServiceManagerUtils.h"
 #include "prnetdb.h"
 #include "Tickler.h"
+#include "nsThreadUtils.h"
 
 #ifdef MOZ_USE_WIFI_TICKLER
 
 #include "AndroidBridge.h"
 
 namespace mozilla {
 namespace net {
 
--- a/netwerk/base/src/Tickler.h
+++ b/netwerk/base/src/Tickler.h
@@ -27,17 +27,16 @@
 // The tickler only applies to wifi on mobile right now. Hopefully it
 // can also be restricted to particular handset models in the future.
 
 #include "mozilla/Mutex.h"
 #include "mozilla/TimeStamp.h"
 #include "nsAutoPtr.h"
 #include "nsISupports.h"
 #include "nsIThread.h"
-#include "nsThreadUtils.h"
 #include "nsITimer.h"
 #include "nsWeakReference.h"
 
 class nsIPrefBranch;
 
 namespace mozilla {
 namespace net {
 
--- a/netwerk/base/src/nsSocketTransport2.cpp
+++ b/netwerk/base/src/nsSocketTransport2.cpp
@@ -21,17 +21,17 @@
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "netCore.h"
 #include "plstr.h"
 #include "prnetdb.h"
 #include "prerr.h"
 #include "NetworkActivityMonitor.h"
 #include "mozilla/VisualEventTracer.h"
-
+#include "nsThreadUtils.h"
 #include "nsIServiceManager.h"
 #include "nsISocketProviderService.h"
 #include "nsISocketProvider.h"
 #include "nsISSLSocketControl.h"
 #include "nsINSSErrorsService.h"
 #include "nsIPipe.h"
 #include "nsIProgrammingLanguage.h"
 #include "nsIClassInfoImpl.h"
--- a/netwerk/base/src/nsSocketTransportService2.cpp
+++ b/netwerk/base/src/nsSocketTransportService2.cpp
@@ -19,16 +19,17 @@
 #include "nsServiceManagerUtils.h"
 #include "nsIOService.h"
 #include "NetworkActivityMonitor.h"
 #include "nsIObserverService.h"
 #include "mozilla/Services.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Likely.h"
 #include "mozilla/PublicSSL.h"
+#include "nsThreadUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::net;
 
 #if defined(PR_LOGGING)
 PRLogModuleInfo *gSocketTransportLog = nullptr;
 #endif
 
--- a/netwerk/base/src/nsSocketTransportService2.h
+++ b/netwerk/base/src/nsSocketTransportService2.h
@@ -3,17 +3,17 @@
  * 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 nsSocketTransportService2_h__
 #define nsSocketTransportService2_h__
 
 #include "nsPISocketTransportService.h"
 #include "nsIThreadInternal.h"
-#include "nsThreadUtils.h"
+#include "nsIRunnable.h"
 #include "nsEventQueue.h"
 #include "nsCOMPtr.h"
 #include "pldhash.h"
 #include "prinrval.h"
 #include "prlog.h"
 #include "prinit.h"
 #include "prio.h"
 #include "nsASocketHandler.h"
--- a/netwerk/base/src/nsUDPServerSocket.h
+++ b/netwerk/base/src/nsUDPServerSocket.h
@@ -5,16 +5,17 @@
 
 #ifndef nsUDPServerSocket_h__
 #define nsUDPServerSocket_h__
 
 #include "nsIUDPServerSocket.h"
 #include "nsSocketTransportService2.h"
 #include "mozilla/Mutex.h"
 #include "nsIOutputStream.h"
+#include "nsAutoPtr.h"
 
 //-----------------------------------------------------------------------------
 
 class nsUDPServerSocket : public nsASocketHandler
                         , public nsIUDPServerSocket
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
--- a/netwerk/ipc/ChannelEventQueue.cpp
+++ b/netwerk/ipc/ChannelEventQueue.cpp
@@ -2,16 +2,17 @@
  * vim: set sw=2 ts=8 et tw=80 :
  */
 /* 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 "nsISupports.h"
 #include "mozilla/net/ChannelEventQueue.h"
+#include "nsThreadUtils.h"
 
 namespace mozilla {
 namespace net {
 
 void
 ChannelEventQueue::FlushQueue()
 {
   // Events flushed could include destruction of channel (and our own
@@ -36,11 +37,26 @@ ChannelEventQueue::FlushQueue()
   // It is possible for new callbacks to be enqueued as we are
   // flushing the queue, so the queue must not be cleared until
   // all callbacks have run.
   mEventQueue.RemoveElementsAt(0, i);
 
   mFlushing = false;
 }
 
+void
+ChannelEventQueue::Resume()
+{
+  // Resuming w/o suspend: error in debug mode, ignore in build
+  MOZ_ASSERT(mSuspendCount > 0);
+  if (mSuspendCount <= 0) {
+    return;
+  }
+
+  if (!--mSuspendCount) {
+    nsRefPtr<nsRunnableMethod<ChannelEventQueue> > event =
+      NS_NewRunnableMethod(this, &ChannelEventQueue::CompleteResume);
+    NS_DispatchToCurrentThread(event);
+  }
+}
 
 }
 }
--- a/netwerk/ipc/ChannelEventQueue.h
+++ b/netwerk/ipc/ChannelEventQueue.h
@@ -5,17 +5,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/. */
 
 #ifndef mozilla_net_ChannelEventQueue_h
 #define mozilla_net_ChannelEventQueue_h
 
 #include <nsTArray.h>
 #include <nsAutoPtr.h>
-#include <nsThreadUtils.h>
 
 class nsISupports;
 
 namespace mozilla {
 namespace net {
 
 class ChannelEvent
 {
@@ -65,17 +64,17 @@ class ChannelEventQueue
   inline void EndForcedQueueing();
 
   // Suspend/resume event queue.  ShouldEnqueue() will return true and no events
   // will be run/flushed until resume is called.  These should be called when
   // the channel owning the event queue is suspended/resumed.
   inline void Suspend();
   // Resume flushes the queue asynchronously, i.e. items in queue will be
   // dispatched in a new event on the current thread.
-  inline void Resume();
+  void Resume();
 
  private:
   inline void MaybeFlushQueue();
   void FlushQueue();
   inline void CompleteResume();
 
   nsTArray<nsAutoPtr<ChannelEvent> > mEventQueue;
 
@@ -136,32 +135,16 @@ ChannelEventQueue::CompleteResume()
     // messages) until this point, else new incoming messages could run before
     // queued ones.
     mSuspended = false;
     MaybeFlushQueue();
   }
 }
 
 inline void
-ChannelEventQueue::Resume()
-{
-  // Resuming w/o suspend: error in debug mode, ignore in build
-  MOZ_ASSERT(mSuspendCount > 0);
-  if (mSuspendCount <= 0) {
-    return;
-  }
-
-  if (!--mSuspendCount) {
-    nsRefPtr<nsRunnableMethod<ChannelEventQueue> > event =
-      NS_NewRunnableMethod(this, &ChannelEventQueue::CompleteResume);
-    NS_DispatchToCurrentThread(event);
-  }
-}
-
-inline void
 ChannelEventQueue::MaybeFlushQueue()
 {
   // Don't flush if forced queuing on, we're already being flushed, or
   // suspended, or there's nothing to flush
   if (!mForced && !mFlushing && !mSuspended && !mEventQueue.IsEmpty())
     FlushQueue();
 }
 
--- a/netwerk/protocol/http/nsHttpChannel.h
+++ b/netwerk/protocol/http/nsHttpChannel.h
@@ -6,17 +6,16 @@
 
 #ifndef nsHttpChannel_h__
 #define nsHttpChannel_h__
 
 #include "HttpBaseChannel.h"
 
 #include "nsHttpTransaction.h"
 #include "nsInputStreamPump.h"
-#include "nsThreadUtils.h"
 #include "nsTArray.h"
 
 #include "nsIHttpEventSink.h"
 #include "nsICachingChannel.h"
 #include "nsICacheEntryDescriptor.h"
 #include "nsICacheListener.h"
 #include "nsIApplicationCacheChannel.h"
 #include "nsIPrompt.h"
--- a/parser/html/nsHtml5Parser.h
+++ b/parser/html/nsHtml5Parser.h
@@ -7,17 +7,16 @@
 #define NS_HTML5_PARSER
 
 #include "nsAutoPtr.h"
 #include "nsIParser.h"
 #include "nsDeque.h"
 #include "nsIURL.h"
 #include "nsParserCIID.h"
 #include "nsITokenizer.h"
-#include "nsThreadUtils.h"
 #include "nsIContentSink.h"
 #include "nsIRequest.h"
 #include "nsIChannel.h"
 #include "nsCOMArray.h"
 #include "nsContentSink.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIInputStream.h"
 #include "nsDetectionConfident.h"
--- a/storage/src/mozStorageAsyncStatementExecution.h
+++ b/storage/src/mozStorageAsyncStatementExecution.h
@@ -5,20 +5,20 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozStorageAsyncStatementExecution_h
 #define mozStorageAsyncStatementExecution_h
 
 #include "nscore.h"
 #include "nsTArray.h"
 #include "nsAutoPtr.h"
-#include "nsThreadUtils.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Attributes.h"
+#include "nsIRunnable.h"
 
 #include "SQLiteMutex.h"
 #include "mozIStoragePendingStatement.h"
 #include "mozIStorageStatementCallback.h"
 #include "mozStorageHelper.h"
 
 struct sqlite3_stmt;
 
--- a/toolkit/components/places/nsNavHistory.h
+++ b/toolkit/components/places/nsNavHistory.h
@@ -16,17 +16,16 @@
 #include "nsIObserverService.h"
 #include "nsICollation.h"
 #include "nsIStringBundle.h"
 #include "nsITimer.h"
 #include "nsMaybeWeakPtr.h"
 #include "nsCategoryCache.h"
 #include "nsNetCID.h"
 #include "nsToolkitCompsCID.h"
-#include "nsThreadUtils.h"
 #include "nsURIHashKey.h"
 #include "nsTHashtable.h"
 
 #include "nsNavHistoryResult.h"
 #include "nsNavHistoryQuery.h"
 #include "Database.h"
 #include "mozilla/Attributes.h"
 
--- a/widget/android/AndroidBridge.h
+++ b/widget/android/AndroidBridge.h
@@ -8,19 +8,16 @@
 
 #include <jni.h>
 #include <android/log.h>
 #include <cstdlib>
 #include <pthread.h>
 
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
-#include "nsIRunnable.h"
-#include "nsIObserver.h"
-#include "nsThreadUtils.h"
 
 #include "AndroidJavaWrappers.h"
 
 #include "nsIMutableArray.h"
 #include "nsIMIMEInfo.h"
 #include "nsColor.h"
 #include "gfxRect.h"
 
@@ -33,16 +30,17 @@
 #include "mozilla/TimeStamp.h"
 
 // Some debug #defines
 // #define DEBUG_ANDROID_EVENTS
 // #define DEBUG_ANDROID_WIDGET
 
 class nsWindow;
 class nsIDOMMozSmsMessage;
+class nsIObserver;
 
 /* See the comment in AndroidBridge about this function before using it */
 extern "C" JNIEnv * GetJNIForThread();
 
 extern bool mozilla_AndroidBridge_SetMainThread(pthread_t);
 extern jclass GetGeckoAppShellClass();
 
 namespace base {
--- a/widget/windows/JumpListBuilder.h
+++ b/widget/windows/JumpListBuilder.h
@@ -15,17 +15,16 @@
 
 #include "nsString.h"
 #include "nsIMutableArray.h"
 
 #include "nsIJumpListBuilder.h"
 #include "nsIJumpListItem.h"
 #include "JumpListItem.h"
 #include "nsIObserver.h"
-#include "nsThreadUtils.h"
 #include "mozilla/Attributes.h"
 
 namespace mozilla {
 namespace widget {
 
 class JumpListBuilder : public nsIJumpListBuilder, 
                         public nsIObserver
 {
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -22,16 +22,17 @@
 #include "mozIAsyncFavicons.h"
 #endif
 #include "nsIIconURI.h"
 #include "nsIDownloader.h"
 #include "nsINetUtil.h"
 #include "nsIChannel.h"
 #include "nsIObserver.h"
 #include "imgIEncoder.h"
+#include "nsIThread.h"
 
 #ifdef NS_ENABLE_TSF
 #include <textstor.h>
 #include "nsTextStore.h"
 #endif // #ifdef NS_ENABLE_TSF
 
 namespace mozilla {
 namespace widget {
--- a/widget/windows/WinUtils.h
+++ b/widget/windows/WinUtils.h
@@ -10,31 +10,32 @@
 #include <windows.h>
 #include <shobjidl.h>
 #include <uxtheme.h>
 #include <dwmapi.h>
 #include "nsAutoPtr.h"
 #include "nsString.h"
 #include "nsRegion.h"
 
-#include "nsThreadUtils.h"
+#include "nsIRunnable.h"
 #include "nsICryptoHash.h"
 #ifdef MOZ_PLACES
 #include "nsIFaviconService.h"
 #endif
 #include "nsIDownloader.h"
 #include "nsIURI.h"
 #include "nsIWidget.h"
 
 #include "mozilla/Attributes.h"
 
 class nsWindow;
 class nsWindowBase;
 struct KeyPair;
 struct nsIntRect;
+class nsIThread;
 
 namespace mozilla {
 namespace widget {
 
 // More complete QS definitions for MsgWaitForMultipleObjects() and
 // GetQueueStatus() that include newer win8 specific defines.
 
 #ifndef QS_RAWINPUT
--- a/widget/windows/nsSound.cpp
+++ b/widget/windows/nsSound.cpp
@@ -19,16 +19,17 @@
 #include "nsCRT.h"
 
 #include "prlog.h"
 #include "prtime.h"
 #include "prprf.h"
 #include "prmem.h"
 
 #include "nsNativeCharsetUtils.h"
+#include "nsThreadUtils.h"
 
 #ifdef PR_LOGGING
 PRLogModuleInfo* gWin32SoundLog = nullptr;
 #endif
 
 class nsSoundPlayer: public nsRunnable {
 public:
   nsSoundPlayer(nsSound *aSound, const wchar_t* aSoundName) :
--- a/widget/windows/nsSound.h
+++ b/widget/windows/nsSound.h
@@ -4,17 +4,19 @@
  * 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 __nsSound_h__
 #define __nsSound_h__
 
 #include "nsISound.h"
 #include "nsIStreamLoader.h"
-#include "nsThreadUtils.h"
+#include "nsCOMPtr.h"
+
+class nsIThread;
 
 class nsSound : public nsISound,
                 public nsIStreamLoaderObserver
 
 {
 public: 
   nsSound();
   virtual ~nsSound();