try: -b do -p all -u all[x64] -t none
authorBobby Holley <bobbyholley@gmail.com>
Tue, 28 Jul 2015 17:52:52 -0700
changeset 516712 539c90722429cbe02b16143c97cae317e63ed623
parent 516711 4542acce4fbc33df8561e91b3874e09ec42006a0
child 568006 5d3f74705e0bf0bb622ea0bad58244071e32ca9e
push id80569
push userbobbyholley@gmail.com
push dateWed, 29 Jul 2015 01:11:02 +0000
treeherdertry@539c90722429 [default view] [failures only]
bugs1188696
milestone42.0a1
try: -b do -p all -u all[x64] -t none Bug 1188696 - Hoist nsRefPtr.h into MFBT. v1
docshell/base/timeline/AutoGlobalTimelineMarker.h
docshell/base/timeline/AutoTimelineMarker.h
docshell/base/timeline/ObservedDocShell.h
dom/base/PostMessageEvent.h
dom/base/SameProcessMessageQueue.h
dom/bindings/OwningNonNull.h
dom/broadcastchannel/BroadcastChannel.h
dom/cache/ActorChild.h
dom/cache/CacheOpChild.h
dom/cache/DBAction.h
dom/cache/Manager.h
dom/cache/ManagerId.cpp
dom/cache/ReadStream.h
dom/cache/StreamControl.h
dom/cache/StreamList.h
dom/canvas/WebGL2ContextUniforms.cpp
dom/canvas/WebGLContextGL.cpp
dom/canvas/WebGLContextUnchecked.h
dom/canvas/WebGLProgram.cpp
dom/fetch/FetchDriver.h
dom/media/AbstractThread.h
dom/media/AudioSink.h
dom/media/DecodedStream.h
dom/media/MediaData.h
dom/media/MediaDataDemuxer.h
dom/media/MediaInfo.h
dom/media/MediaStreamError.h
dom/media/MediaTimer.h
dom/media/mediasource/ContainerParser.h
dom/media/omx/MediaCodecProxy.h
dom/media/omx/OMXCodecProxy.h
dom/media/omx/OMXCodecWrapper.h
dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h
dom/media/systemservices/MediaSystemResourceClient.h
dom/media/webrtc/RTCIdentityProviderRegistrar.h
dom/presentation/provider/MulticastDNSDeviceProvider.h
dom/promise/PromiseDebugging.h
dom/push/PushManager.h
dom/workers/WorkerThread.h
gfx/layers/apz/src/HitTestingTreeNode.h
gfx/layers/apz/util/APZEventState.h
gfx/layers/apz/util/ChromeProcessController.h
gfx/layers/composite/AsyncCompositionManager.h
gfx/layers/composite/CanvasLayerComposite.cpp
gfx/layers/composite/CompositableHost.cpp
gfx/layers/composite/ContainerLayerComposite.cpp
gfx/layers/composite/FrameUniformityData.h
gfx/layers/composite/ImageLayerComposite.cpp
gfx/layers/composite/LayerManagerComposite.cpp
gfx/layers/composite/LayerManagerComposite.h
gfx/layers/composite/PaintedLayerComposite.cpp
gfx/layers/composite/TextureHost.cpp
gfx/layers/ipc/FenceUtils.h
gfx/src/nsRenderingContext.h
gfx/tests/gtest/TestVsync.cpp
gfx/thebes/VsyncSource.h
gfx/vr/gfxVR.h
gfx/vr/gfxVROculus.h
image/DecodePool.h
image/DecoderFactory.cpp
image/SourceBuffer.h
ipc/glue/BackgroundParentImpl.cpp
ipc/ipdl/ipdl/builtin.py
layout/base/AccessibleCaret.h
layout/base/AccessibleCaretEventHub.h
layout/base/AccessibleCaretManager.h
layout/ipc/VsyncChild.h
layout/ipc/VsyncParent.h
media/libstagefright/binding/Index.cpp
media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
media/libstagefright/binding/include/mp4_demuxer/ResourceStream.h
mfbt/moz.build
mfbt/nsRefPtr.h
modules/libjar/InterceptedJARChannel.h
netwerk/base/Predictor.h
netwerk/dns/mdns/libmdns/MDNSResponderOperator.h
netwerk/dns/mdns/libmdns/MDNSResponderReply.h
netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.h
netwerk/protocol/http/InterceptedChannel.h
security/manager/ssl/nsProtectedAuthThread.cpp
toolkit/components/url-classifier/LookupCache.h
widget/ContentCache.cpp
widget/VsyncDispatcher.h
widget/gonk/GeckoTouchDispatcher.h
widget/nsPrintSettingsImpl.cpp
xpcom/base/moz.build
xpcom/base/nsAutoPtr.h
xpcom/base/nsQueryObject.h
xpcom/base/nsRefPtr.h
xpcom/glue/nsCOMPtr.h
xpcom/glue/nsISupportsUtils.h
xpcom/io/nsPipe3.cpp
xpcom/tests/gtest/TestStrings.cpp
--- a/docshell/base/timeline/AutoGlobalTimelineMarker.h
+++ b/docshell/base/timeline/AutoGlobalTimelineMarker.h
@@ -3,17 +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/. */
 
 #ifndef mozilla_AutoGlobalTimelineMarker_h_
 #define mozilla_AutoGlobalTimelineMarker_h_
 
 #include "mozilla/GuardObjects.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 class nsDocShell;
 
 namespace mozilla {
 
 // # AutoGlobalTimelineMarker
 //
 // Similar to `AutoTimelineMarker`, but adds its traced marker to all docshells,
--- a/docshell/base/timeline/AutoTimelineMarker.h
+++ b/docshell/base/timeline/AutoTimelineMarker.h
@@ -3,17 +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/. */
 
 #ifndef mozilla_AutoTimelineMarker_h_
 #define mozilla_AutoTimelineMarker_h_
 
 #include "mozilla/GuardObjects.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 class nsIDocShell;
 class nsDocShell;
 
 namespace mozilla {
 
 // # AutoTimelineMarker
 //
--- a/docshell/base/timeline/ObservedDocShell.h
+++ b/docshell/base/timeline/ObservedDocShell.h
@@ -4,17 +4,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 ObservedDocShell_h_
 #define ObservedDocShell_h_
 
 #include "GeckoProfiler.h"
 #include "nsTArray.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 class nsDocShell;
 class TimelineMarker;
 
 namespace mozilla {
 namespace dom {
 struct ProfileTimelineMarker;
 }
--- a/dom/base/PostMessageEvent.h
+++ b/dom/base/PostMessageEvent.h
@@ -4,17 +4,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 mozilla_dom_PostMessageEvent_h
 #define mozilla_dom_PostMessageEvent_h
 
 #include "mozilla/dom/StructuredCloneHelper.h"
 #include "nsCOMPtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
 
 class nsGlobalWindow;
 class nsIPrincipal;
 class nsPIDOMWindow;
 
 namespace mozilla {
--- a/dom/base/SameProcessMessageQueue.h
+++ b/dom/base/SameProcessMessageQueue.h
@@ -3,17 +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/. */
 
 #ifndef mozilla_dom_SameProcessMessageQueue_h
 #define mozilla_dom_SameProcessMessageQueue_h
 
 #include "nsIRunnable.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 namespace dom {
 
 class CancelableRunnable;
 
 class SameProcessMessageQueue
--- a/dom/bindings/OwningNonNull.h
+++ b/dom/bindings/OwningNonNull.h
@@ -142,17 +142,17 @@ nsCOMPtr<T>::nsCOMPtr(const mozilla::dom
 
 template<class T> template<class U>
 nsCOMPtr<T>&
 nsCOMPtr<T>::operator=(const mozilla::dom::OwningNonNull<U>& aOther)
 {
   return operator=(aOther.get());
 }
 
-// Declared in nsRefPtr.h
+// Declared in mozilla/nsRefPtr.h
 template<class T> template<class U>
 nsRefPtr<T>::nsRefPtr(const mozilla::dom::OwningNonNull<U>& aOther)
   : nsRefPtr(aOther.get())
 {}
 
 template<class T> template<class U>
 nsRefPtr<T>&
 nsRefPtr<T>::operator=(const mozilla::dom::OwningNonNull<U>& aOther)
--- a/dom/broadcastchannel/BroadcastChannel.h
+++ b/dom/broadcastchannel/BroadcastChannel.h
@@ -7,17 +7,17 @@
 #ifndef mozilla_dom_BroadcastChannel_h
 #define mozilla_dom_BroadcastChannel_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "nsIIPCBackgroundChildCreateCallback.h"
 #include "nsIObserver.h"
 #include "nsTArray.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 class nsPIDOMWindow;
 
 namespace mozilla {
 
 namespace ipc {
 class PrincipalInfo;
 } // namespace ipc
--- a/dom/cache/ActorChild.h
+++ b/dom/cache/ActorChild.h
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=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/. */
 
 #ifndef mozilla_dom_cache_ActioChild_h
 #define mozilla_dom_cache_ActioChild_h
 
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 namespace dom {
 namespace cache {
 
 class Feature;
 
 class ActorChild
--- a/dom/cache/CacheOpChild.h
+++ b/dom/cache/CacheOpChild.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_cache_CacheOpChild_h
 #define mozilla_dom_cache_CacheOpChild_h
 
 #include "mozilla/dom/cache/ActorChild.h"
 #include "mozilla/dom/cache/PCacheOpChild.h"
 #include "mozilla/dom/cache/TypeUtils.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 class nsIGlobalObject;
 
 namespace mozilla {
 namespace dom {
 
 class Promise;
 
--- a/dom/cache/DBAction.h
+++ b/dom/cache/DBAction.h
@@ -3,17 +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/. */
 
 #ifndef mozilla_dom_cache_DBAction_h
 #define mozilla_dom_cache_DBAction_h
 
 #include "mozilla/dom/cache/Action.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsString.h"
 
 class mozIStorageConnection;
 class nsIFile;
 
 namespace mozilla {
 namespace dom {
 namespace cache {
--- a/dom/cache/Manager.h
+++ b/dom/cache/Manager.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_cache_Manager_h
 #define mozilla_dom_cache_Manager_h
 
 #include "mozilla/dom/cache/Types.h"
 #include "nsCOMPtr.h"
 #include "nsISupportsImpl.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsString.h"
 #include "nsTArray.h"
 
 class nsIInputStream;
 class nsIThread;
 
 namespace mozilla {
 
--- a/dom/cache/ManagerId.cpp
+++ b/dom/cache/ManagerId.cpp
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=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 "mozilla/dom/cache/ManagerId.h"
 #include "nsIPrincipal.h"
 #include "nsProxyRelease.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 namespace dom {
 namespace cache {
 
 // static
 nsresult
--- a/dom/cache/ReadStream.h
+++ b/dom/cache/ReadStream.h
@@ -7,17 +7,17 @@
 #ifndef mozilla_dom_cache_ReadStream_h
 #define mozilla_dom_cache_ReadStream_h
 
 #include "mozilla/ipc/FileDescriptor.h"
 #include "nsCOMPtr.h"
 #include "nsID.h"
 #include "nsIInputStream.h"
 #include "nsISupportsImpl.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsTArrayForwardDeclare.h"
 
 namespace mozilla {
 namespace dom {
 namespace cache {
 
 class CacheReadStream;
 class CacheReadStreamOrVoid;
--- a/dom/cache/StreamControl.h
+++ b/dom/cache/StreamControl.h
@@ -3,17 +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/. */
 
 #ifndef mozilla_dom_cache_StreamControl_h
 #define mozilla_dom_cache_StreamControl_h
 
 #include "mozilla/dom/cache/ReadStream.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsTObserverArray.h"
 
 struct nsID;
 
 namespace mozilla {
 namespace ipc {
  class FileDescriptor;
 } // namespace ipc
--- a/dom/cache/StreamList.h
+++ b/dom/cache/StreamList.h
@@ -4,17 +4,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 mozilla_dom_cache_StreamList_h
 #define mozilla_dom_cache_StreamList_h
 
 #include "mozilla/dom/cache/Context.h"
 #include "mozilla/dom/cache/Types.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsTArray.h"
 
 class nsIInputStream;
 
 namespace mozilla {
 namespace dom {
 namespace cache {
 
--- a/dom/canvas/WebGL2ContextUniforms.cpp
+++ b/dom/canvas/WebGL2ContextUniforms.cpp
@@ -2,17 +2,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 "WebGL2Context.h"
 
 #include "GLContext.h"
 #include "mozilla/dom/WebGL2RenderingContextBinding.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "WebGLBuffer.h"
 #include "WebGLContext.h"
 #include "WebGLProgram.h"
 #include "WebGLVertexArray.h"
 #include "WebGLVertexAttribData.h"
 
 namespace mozilla {
 
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -16,17 +16,16 @@
 #include "WebGLRenderbuffer.h"
 #include "WebGLShaderPrecisionFormat.h"
 #include "WebGLTexture.h"
 #include "WebGLExtensions.h"
 #include "WebGLVertexArray.h"
 
 #include "nsDebug.h"
 #include "nsReadableUtils.h"
-#include "../../xpcom/base/nsRefPtr.h"
 #include "nsString.h"
 
 #include "gfxContext.h"
 #include "gfxPlatform.h"
 #include "GLContext.h"
 
 #include "nsContentUtils.h"
 #include "nsError.h"
@@ -46,16 +45,17 @@
 #include "nsCocoaFeatures.h"
 #endif
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/ImageData.h"
 #include "mozilla/dom/ToJSValue.h"
 #include "mozilla/Endian.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 using namespace mozilla::gl;
 
 static const WebGLRectangleObject*
--- a/dom/canvas/WebGLContextUnchecked.h
+++ b/dom/canvas/WebGLContextUnchecked.h
@@ -3,17 +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/. */
 
 #ifndef WEBGLCONTEXTUNCHECKED_H
 #define WEBGLCONTEXTUNCHECKED_H
 
 #include "GLDefs.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "WebGLTypes.h"
 
 namespace mozilla {
 
 class WebGLBuffer;
 class WebGLSampler;
 namespace gl {
     class GLContext;
--- a/dom/canvas/WebGLProgram.cpp
+++ b/dom/canvas/WebGLProgram.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WebGLProgram.h"
 
 #include "GLContext.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/dom/WebGL2RenderingContextBinding.h"
 #include "mozilla/dom/WebGLRenderingContextBinding.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "WebGLActiveInfo.h"
 #include "WebGLContext.h"
 #include "WebGLShader.h"
 #include "WebGLUniformLocation.h"
 #include "WebGLValidateStrings.h"
 
 namespace mozilla {
 
--- a/dom/fetch/FetchDriver.h
+++ b/dom/fetch/FetchDriver.h
@@ -7,17 +7,17 @@
 #ifndef mozilla_dom_FetchDriver_h
 #define mozilla_dom_FetchDriver_h
 
 #include "nsAutoPtr.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIChannelEventSink.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIStreamListener.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/net/ReferrerPolicy.h"
 
 class nsIDocument;
 class nsIOutputStream;
 class nsILoadGroup;
 class nsIPrincipal;
--- a/dom/media/AbstractThread.h
+++ b/dom/media/AbstractThread.h
@@ -6,17 +6,17 @@
 
 #if !defined(AbstractThread_h_)
 #define AbstractThread_h_
 
 #include "nscore.h"
 #include "nsIRunnable.h"
 #include "nsISupportsImpl.h"
 #include "nsIThread.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #include "mozilla/ThreadLocal.h"
 
 namespace mozilla {
 
 class TaskQueue;
 class TaskDispatcher;
 
--- a/dom/media/AudioSink.h
+++ b/dom/media/AudioSink.h
@@ -2,17 +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/. */
 #if !defined(AudioSink_h__)
 #define AudioSink_h__
 
 #include "MediaInfo.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsISupportsImpl.h"
 
 #include "mozilla/dom/AudioChannelBinding.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/MozPromise.h"
 #include "mozilla/ReentrantMonitor.h"
 
 namespace mozilla {
--- a/dom/media/DecodedStream.h
+++ b/dom/media/DecodedStream.h
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=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/. */
 
 #ifndef DecodedStream_h_
 #define DecodedStream_h_
 
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsTArray.h"
 #include "MediaInfo.h"
 
 #include "mozilla/UniquePtr.h"
 #include "mozilla/gfx/Point.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "mozilla/Maybe.h"
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -7,17 +7,17 @@
 #define MediaData_h
 
 #include "nsSize.h"
 #include "mozilla/gfx/Rect.h"
 #include "nsRect.h"
 #include "AudioSampleFormat.h"
 #include "nsIMemoryReporter.h"
 #include "SharedBuffer.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 
 namespace layers {
 class Image;
 class ImageContainer;
 } // namespace layers
--- a/dom/media/MediaDataDemuxer.h
+++ b/dom/media/MediaDataDemuxer.h
@@ -9,17 +9,17 @@
 
 #include "mozilla/MozPromise.h"
 #include "mozilla/UniquePtr.h"
 
 #include "MediaData.h"
 #include "MediaInfo.h"
 #include "TimeUnits.h"
 #include "nsISupportsImpl.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 
 class MediaTrackDemuxer;
 class TrackMetadataHolder;
 
 enum class DemuxerFailureReason : int8_t
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -3,17 +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/. */
 #if !defined(MediaInfo_h)
 #define MediaInfo_h
 
 #include "mozilla/UniquePtr.h"
 #include "nsRect.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsSize.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "ImageTypes.h"
 #include "MediaData.h"
 #include "StreamBuffer.h" // for TrackID
 #include "TimeUnits.h"
 
--- a/dom/media/MediaStreamError.h
+++ b/dom/media/MediaStreamError.h
@@ -7,17 +7,17 @@
 #ifndef mozilla_dom_MediaStreamError_h
 #define mozilla_dom_MediaStreamError_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "nsWrapperCache.h"
 #include "js/TypeDecls.h"
 #include "nsPIDOMWindow.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #if defined(XP_WIN) && defined(GetMessage)
 #undef GetMessage
 #endif
 
 namespace mozilla {
 namespace dom {
 
--- a/dom/media/MediaTimer.h
+++ b/dom/media/MediaTimer.h
@@ -9,17 +9,17 @@
 
 #include "mozilla/Monitor.h"
 #include "mozilla/MozPromise.h"
 #include "mozilla/TimeStamp.h"
 
 #include <queue>
 
 #include "nsITimer.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 
 extern PRLogModuleInfo* gMediaTimerLog;
 
 #define TIMER_LOG(x, ...) \
   MOZ_ASSERT(gMediaTimerLog); \
   MOZ_LOG(gMediaTimerLog, LogLevel::Debug, ("[MediaTimer=%p relative_t=%lld]" x, this, \
--- a/dom/media/mediasource/ContainerParser.h
+++ b/dom/media/mediasource/ContainerParser.h
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=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/. */
 
 #ifndef MOZILLA_CONTAINERPARSER_H_
 #define MOZILLA_CONTAINERPARSER_H_
 
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsString.h"
 #include "MediaResource.h"
 
 namespace mozilla {
 
 class MediaByteBuffer;
 class SourceBufferResource;
 
--- a/dom/media/omx/MediaCodecProxy.h
+++ b/dom/media/omx/MediaCodecProxy.h
@@ -9,17 +9,17 @@
 
 #include <nsString.h>
 #include <stagefright/MediaCodec.h>
 #include <stagefright/MediaBuffer.h>
 #include <utils/threads.h>
 
 #include "mozilla/media/MediaSystemResourceClient.h"
 #include "mozilla/Monitor.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace android {
 // This class is intended to be a proxy for MediaCodec with codec resource
 // management. Basically user can use it like MediaCodec, but need to handle
 // the listener when Codec is reserved for Async case. A good example is
 // MediaCodecReader.cpp. Another useage is to use configure(), Prepare(),
 // Input(), and Output(). It is used in GonkVideoDecoderManager.cpp which
 // doesn't need to handle the buffers for codec.
--- a/dom/media/omx/OMXCodecProxy.h
+++ b/dom/media/omx/OMXCodecProxy.h
@@ -9,17 +9,17 @@
 
 #include <android/native_window.h>
 #include <media/IOMX.h>
 #include <stagefright/MediaBuffer.h>
 #include <stagefright/MediaSource.h>
 #include <utils/threads.h>
 
 #include "mozilla/media/MediaSystemResourceClient.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace android {
 
 struct MetaData;
 
 class OMXCodecProxy : public MediaSource
                     , public mozilla::MediaSystemResourceReservationListener
 {
--- a/dom/media/omx/OMXCodecWrapper.h
+++ b/dom/media/omx/OMXCodecWrapper.h
@@ -11,17 +11,17 @@
 #include <stagefright/foundation/ABuffer.h>
 #include <stagefright/foundation/AMessage.h>
 #include <stagefright/MediaCodec.h>
 
 #include "AudioSegment.h"
 #include "GonkNativeWindow.h"
 #include "GonkNativeWindowClient.h"
 #include "mozilla/media/MediaSystemResourceClient.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #include <speex/speex_resampler.h>
 
 namespace android {
 
 // Wrapper class for managing HW codec reservations
 class OMXCodecReservation : public RefBase
 {
--- a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h
+++ b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h
@@ -3,17 +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/. */
 
 #if !defined(MediaDataDecoderProxy_h_)
 #define MediaDataDecoderProxy_h_
 
 #include "PlatformDecoderModule.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsThreadUtils.h"
 #include "nscore.h"
 
 namespace mozilla {
 
 class InputTask : public nsRunnable {
 public:
   InputTask(MediaDataDecoder* aDecoder,
--- a/dom/media/systemservices/MediaSystemResourceClient.h
+++ b/dom/media/systemservices/MediaSystemResourceClient.h
@@ -7,17 +7,17 @@
 #if !defined(MediaSystemResourceClient_h_)
 #define MediaSystemResourceClient_h_
 
 #include "MediaSystemResourceManager.h"
 #include "MediaSystemResourceTypes.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/media/MediaSystemResourceTypes.h"
 #include "mozilla/Monitor.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 
 class MediaSystemResourceManager;
 
 
 /**
  * This is a base class for listener callbacks.
--- a/dom/media/webrtc/RTCIdentityProviderRegistrar.h
+++ b/dom/media/webrtc/RTCIdentityProviderRegistrar.h
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
 /* 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 RTCIDENTITYPROVIDER_H_
 #define RTCIDENTITYPROVIDER_H_
 
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsCOMPtr.h"
 #include "nsISupportsImpl.h"
 #include "nsIGlobalObject.h"
 #include "nsWrapperCache.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/BindingDeclarations.h"
 
--- a/dom/presentation/provider/MulticastDNSDeviceProvider.h
+++ b/dom/presentation/provider/MulticastDNSDeviceProvider.h
@@ -6,17 +6,17 @@
 #ifndef mozilla_dom_presentation_provider_MulticastDNSDeviceProvider_h
 #define mozilla_dom_presentation_provider_MulticastDNSDeviceProvider_h
 
 #include "nsCOMPtr.h"
 #include "nsICancelable.h"
 #include "nsIDNSServiceDiscovery.h"
 #include "nsIPresentationDeviceProvider.h"
 #include "nsITCPPresentationServer.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsString.h"
 #include "nsWeakPtr.h"
 
 namespace mozilla {
 namespace dom {
 namespace presentation {
 
 class DNSServiceWrappedListener;
--- a/dom/promise/PromiseDebugging.h
+++ b/dom/promise/PromiseDebugging.h
@@ -4,17 +4,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 mozilla_dom_PromiseDebugging_h
 #define mozilla_dom_PromiseDebugging_h
 
 #include "js/TypeDecls.h"
 #include "nsTArray.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 
 class ErrorResult;
 
 namespace dom {
 namespace workers {
 class WorkerPrivate;
--- a/dom/push/PushManager.h
+++ b/dom/push/PushManager.h
@@ -33,17 +33,17 @@
 
 #include "nsWrapperCache.h"
 
 #include "mozilla/AlreadyAddRefed.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/BindingDeclarations.h"
 
 #include "nsCOMPtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "jsapi.h"
 
 class nsIGlobalObject;
 class nsIPrincipal;
 
 namespace mozilla {
 namespace dom {
 
--- a/dom/workers/WorkerThread.h
+++ b/dom/workers/WorkerThread.h
@@ -6,17 +6,17 @@
 
 #ifndef mozilla_dom_workers_WorkerThread_h__
 #define mozilla_dom_workers_WorkerThread_h__
 
 #include "mozilla/Attributes.h"
 #include "mozilla/CondVar.h"
 #include "mozilla/DebugOnly.h"
 #include "nsISupportsImpl.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsThread.h"
 
 class nsIRunnable;
 
 namespace mozilla {
 namespace dom {
 namespace workers {
 
--- a/gfx/layers/apz/src/HitTestingTreeNode.h
+++ b/gfx/layers/apz/src/HitTestingTreeNode.h
@@ -7,17 +7,17 @@
 #ifndef mozilla_layers_HitTestingTreeNode_h
 #define mozilla_layers_HitTestingTreeNode_h
 
 #include "APZUtils.h"                       // for HitTestResult
 #include "FrameMetrics.h"                   // for ScrollableLayerGuid
 #include "mozilla/gfx/Matrix.h"             // for Matrix4x4
 #include "mozilla/layers/LayersTypes.h"     // for EventRegions
 #include "mozilla/Maybe.h"                  // for Maybe
-#include "nsRefPtr.h"                       // for nsRefPtr
+#include "mozilla/nsRefPtr.h"                       // for nsRefPtr
 
 namespace mozilla {
 namespace layers {
 
 class AsyncPanZoomController;
 
 /**
  * This class represents a node in a tree that is used by the APZCTreeManager
--- a/gfx/layers/apz/util/APZEventState.h
+++ b/gfx/layers/apz/util/APZEventState.h
@@ -10,17 +10,17 @@
 
 #include "FrameMetrics.h"     // for ScrollableLayerGuid
 #include "Units.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/layers/GeckoContentController.h"  // for APZStateChange
 #include "nsCOMPtr.h"
 #include "nsISupportsImpl.h"  // for NS_INLINE_DECL_REFCOUNTING
 #include "nsIWeakReferenceUtils.h"  // for nsWeakPtr
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 template <class> class nsCOMPtr;
 class nsIDocument;
 class nsIPresShell;
 class nsIWidget;
 
 namespace mozilla {
 namespace layers {
--- a/gfx/layers/apz/util/ChromeProcessController.h
+++ b/gfx/layers/apz/util/ChromeProcessController.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 mozilla_layers_ChromeProcessController_h
 #define mozilla_layers_ChromeProcessController_h
 
 #include "mozilla/layers/GeckoContentController.h"
 #include "nsCOMPtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 class nsIDOMWindowUtils;
 class nsIDocument;
 class nsIPresShell;
 class nsIWidget;
 
 class MessageLoop;
 
--- a/gfx/layers/composite/AsyncCompositionManager.h
+++ b/gfx/layers/composite/AsyncCompositionManager.h
@@ -11,17 +11,17 @@
 #include "mozilla/Attributes.h"         // for final, etc
 #include "mozilla/RefPtr.h"             // for RefCounted
 #include "mozilla/TimeStamp.h"          // for TimeStamp
 #include "mozilla/dom/ScreenOrientation.h"  // for ScreenOrientation
 #include "mozilla/gfx/BasePoint.h"      // for BasePoint
 #include "mozilla/gfx/Matrix.h"         // for Matrix4x4
 #include "mozilla/layers/FrameUniformityData.h" // For FrameUniformityData
 #include "mozilla/layers/LayersMessages.h"  // for TargetConfig
-#include "nsRefPtr.h"                   // for nsRefPtr
+#include "mozilla/nsRefPtr.h"                   // for nsRefPtr
 #include "nsISupportsImpl.h"            // for LayerManager::AddRef, etc
 
 namespace mozilla {
 namespace layers {
 
 class AsyncPanZoomController;
 class Layer;
 class LayerManagerComposite;
--- a/gfx/layers/composite/CanvasLayerComposite.cpp
+++ b/gfx/layers/composite/CanvasLayerComposite.cpp
@@ -10,17 +10,17 @@
 #include "gfxUtils.h"                   // for gfxUtils, etc
 #include "mozilla/gfx/Matrix.h"         // for Matrix4x4
 #include "mozilla/gfx/Point.h"          // for Point
 #include "mozilla/gfx/Rect.h"           // for Rect
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/Effects.h"     // for EffectChain
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAString.h"
-#include "nsRefPtr.h"                   // for nsRefPtr
+#include "mozilla/nsRefPtr.h"                   // for nsRefPtr
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsString.h"                   // for nsAutoCString
 #include "gfxVR.h"
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
--- a/gfx/layers/composite/CompositableHost.cpp
+++ b/gfx/layers/composite/CompositableHost.cpp
@@ -9,17 +9,17 @@
 #include "ContentHost.h"                // for ContentHostDoubleBuffered, etc
 #include "Effects.h"                    // for EffectMask, Effect, etc
 #include "gfxUtils.h"
 #include "ImageHost.h"                  // for ImageHostBuffered, etc
 #include "TiledContentHost.h"           // for TiledContentHost
 #include "mozilla/layers/ImageContainerParent.h"
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
 #include "mozilla/layers/TextureHost.h"  // for TextureHost, etc
-#include "nsRefPtr.h"                   // for nsRefPtr
+#include "mozilla/nsRefPtr.h"                   // for nsRefPtr
 #include "nsDebug.h"                    // for NS_WARNING
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "gfxPlatform.h"                // for gfxPlatform
 #include "mozilla/layers/PCompositableParent.h"
 
 namespace mozilla {
 
 using namespace gfx;
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -19,17 +19,17 @@
 #include "mozilla/gfx/Rect.h"           // for IntRect, Rect
 #include "mozilla/layers/Compositor.h"  // for Compositor, etc
 #include "mozilla/layers/CompositorTypes.h"  // for DiagnosticFlags::CONTAINER
 #include "mozilla/layers/Effects.h"     // for Effect, EffectChain, etc
 #include "mozilla/layers/TextureHost.h"  // for CompositingRenderTarget
 #include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
 #include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
 #include "mozilla/mozalloc.h"           // for operator delete, etc
-#include "nsRefPtr.h"                   // for nsRefPtr
+#include "mozilla/nsRefPtr.h"                   // for nsRefPtr
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsISupportsUtils.h"           // for NS_ADDREF, NS_RELEASE
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nsTArray.h"                   // for nsAutoTArray
 #include "TextRenderer.h"               // for TextRenderer
 #include <vector>
 #include "GeckoProfiler.h"              // for GeckoProfiler
--- a/gfx/layers/composite/FrameUniformityData.h
+++ b/gfx/layers/composite/FrameUniformityData.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 mozilla_layers_FrameUniformityData_h_
 #define mozilla_layers_FrameUniformityData_h_
 
 #include "ipc/IPCMessageUtils.h"
 #include "js/TypeDecls.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 namespace layers {
 class Layer;
 
 class FrameUniformityData {
   friend struct IPC::ParamTraits<FrameUniformityData>;
 
--- a/gfx/layers/composite/ImageLayerComposite.cpp
+++ b/gfx/layers/composite/ImageLayerComposite.cpp
@@ -13,17 +13,17 @@
 #include "mozilla/gfx/Matrix.h"         // for Matrix4x4
 #include "mozilla/gfx/Point.h"          // for IntSize, Point
 #include "mozilla/gfx/Rect.h"           // for Rect
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/Effects.h"     // for EffectChain
 #include "mozilla/layers/TextureHost.h"  // for TextureHost, etc
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAString.h"
-#include "nsRefPtr.h"                   // for nsRefPtr
+#include "mozilla/nsRefPtr.h"                   // for nsRefPtr
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsString.h"                   // for nsAutoCString
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -39,17 +39,17 @@
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/Effects.h"     // for Effect, EffectChain, etc
 #include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
 #include "mozilla/layers/LayersTypes.h"  // for etc
 #include "ipc/CompositorBench.h"        // for CompositorBench
 #include "ipc/ShadowLayerUtils.h"
 #include "mozilla/mozalloc.h"           // for operator new, etc
 #include "nsAppRunner.h"
-#include "nsRefPtr.h"                   // for nsRefPtr
+#include "mozilla/nsRefPtr.h"                   // for nsRefPtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_WARNING, NS_RUNTIMEABORT, etc
 #include "nsISupportsImpl.h"            // for Layer::AddRef, etc
 #include "nsIWidget.h"                  // for nsIWidget
 #include "nsPoint.h"                    // for nsIntPoint
 #include "nsRect.h"                     // for mozilla::gfx::IntRect
 #include "nsRegion.h"                   // for nsIntRegion, etc
 #ifdef MOZ_WIDGET_ANDROID
--- a/gfx/layers/composite/LayerManagerComposite.h
+++ b/gfx/layers/composite/LayerManagerComposite.h
@@ -20,17 +20,17 @@
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/Effects.h"     // for EffectChain
 #include "mozilla/layers/LayersMessages.h"
 #include "mozilla/layers/LayersTypes.h"  // for LayersBackend, etc
 #include "mozilla/Maybe.h"              // for Maybe
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
 #include "nsAString.h"
-#include "nsRefPtr.h"                   // for nsRefPtr
+#include "mozilla/nsRefPtr.h"                   // for nsRefPtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupportsImpl.h"            // for Layer::AddRef, etc
 #include "nsRect.h"                     // for mozilla::gfx::IntRect
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nscore.h"                     // for nsAString, etc
 #include "LayerTreeInvalidation.h"
 
--- a/gfx/layers/composite/PaintedLayerComposite.cpp
+++ b/gfx/layers/composite/PaintedLayerComposite.cpp
@@ -13,17 +13,17 @@
 #include "mozilla/gfx/Point.h"          // for Point
 #include "mozilla/gfx/Rect.h"           // for RoundedToInt, Rect
 #include "mozilla/gfx/Types.h"          // for Filter::Filter::LINEAR
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/ContentHost.h"  // for ContentHost
 #include "mozilla/layers/Effects.h"     // for EffectChain
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAString.h"
-#include "nsRefPtr.h"                   // for nsRefPtr
+#include "mozilla/nsRefPtr.h"                   // for nsRefPtr
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsMathUtils.h"                // for NS_lround
 #include "nsString.h"                   // for nsAutoCString
 #include "TextRenderer.h"
 #include "GeckoProfiler.h"
 
 namespace mozilla {
 namespace layers {
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -12,17 +12,17 @@
 #include "mozilla/layers/CompositableTransactionParent.h" // for CompositableParentManager
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator
 #include "mozilla/layers/ImageDataSerializer.h"
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
 #include "mozilla/layers/TextureHostOGL.h"  // for TextureHostOGL
 #include "mozilla/layers/YCbCrImageDataSerializer.h"
 #include "nsAString.h"
-#include "nsRefPtr.h"                   // for nsRefPtr
+#include "mozilla/nsRefPtr.h"                   // for nsRefPtr
 #include "nsPrintfCString.h"            // for nsPrintfCString
 #include "mozilla/layers/PTextureParent.h"
 #include "mozilla/unused.h"
 #include <limits>
 #include "../opengl/CompositorOGL.h"
 #include "gfxUtils.h"
 
 #ifdef MOZ_ENABLE_D3D10_LAYER
--- a/gfx/layers/ipc/FenceUtils.h
+++ b/gfx/layers/ipc/FenceUtils.h
@@ -4,17 +4,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 IPC_FencerUtils_h
 #define IPC_FencerUtils_h
 
 #include "ipc/IPCMessageUtils.h"
-#include "nsRefPtr.h"             // for nsRefPtr
+#include "mozilla/nsRefPtr.h"             // for nsRefPtr
 
 namespace mozilla {
 namespace layers {
 
 class FenceHandle {
 public:
   class FdObj {
     NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FdObj)
--- a/gfx/src/nsRenderingContext.h
+++ b/gfx/src/nsRenderingContext.h
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef NSRENDERINGCONTEXT__H__
 #define NSRENDERINGCONTEXT__H__
 
 #include "gfxContext.h"
 #include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 namespace gfx {
 class DrawTarget;
 } // namespace gfx
 } // namespace mozilla
 
 class MOZ_STACK_CLASS nsRenderingContext final
--- a/gfx/tests/gtest/TestVsync.cpp
+++ b/gfx/tests/gtest/TestVsync.cpp
@@ -4,17 +4,17 @@
  */
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include "gfxPlatform.h"
 #include "gfxPrefs.h"
 #include "MainThreadUtils.h"
 #include "nsIThread.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "SoftwareVsyncSource.h"
 #include "VsyncSource.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/VsyncDispatcher.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
--- a/gfx/thebes/VsyncSource.h
+++ b/gfx/thebes/VsyncSource.h
@@ -2,17 +2,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 GFX_VSYNCSOURCE_H
 #define GFX_VSYNCSOURCE_H
 
 #include "nsTArray.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/TimeStamp.h"
 #include "nsISupportsImpl.h"
 
 namespace mozilla {
 class RefreshTimerVsyncDispatcher;
 class CompositorVsyncDispatcher;
 
--- a/gfx/vr/gfxVR.h
+++ b/gfx/vr/gfxVR.h
@@ -5,17 +5,17 @@
 
 #ifndef GFX_VR_H
 #define GFX_VR_H
 
 #include "nsTArray.h"
 #include "nsIScreen.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #include "mozilla/gfx/2D.h"
 #include "mozilla/EnumeratedArray.h"
 #include "mozilla/Atomics.h"
 
 namespace mozilla {
 namespace gfx {
 
--- a/gfx/vr/gfxVROculus.h
+++ b/gfx/vr/gfxVROculus.h
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_VR_OCULUS_H
 #define GFX_VR_OCULUS_H
 
 #include "nsTArray.h"
 #include "nsIScreen.h"
 #include "nsCOMPtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #include "mozilla/gfx/2D.h"
 #include "mozilla/EnumeratedArray.h"
 
 #include "gfxVR.h"
 #include "ovr_capi_dynamic.h"
 
 namespace mozilla {
--- a/image/DecodePool.h
+++ b/image/DecodePool.h
@@ -11,17 +11,17 @@
 #define mozilla_image_DecodePool_h
 
 #include "mozilla/Mutex.h"
 #include "mozilla/StaticPtr.h"
 #include "nsCOMArray.h"
 #include "nsCOMPtr.h"
 #include "nsIEventTarget.h"
 #include "nsIObserver.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 class nsIThread;
 class nsIThreadPool;
 
 namespace mozilla {
 namespace image {
 
 class Decoder;
--- a/image/DecoderFactory.cpp
+++ b/image/DecoderFactory.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 "DecoderFactory.h"
 
 #include "nsMimeTypes.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsString.h"
 
 #include "Decoder.h"
 #include "nsPNGDecoder.h"
 #include "nsGIFDecoder2.h"
 #include "nsJPEGDecoder.h"
 #include "nsBMPDecoder.h"
 #include "nsICODecoder.h"
--- a/image/SourceBuffer.h
+++ b/image/SourceBuffer.h
@@ -13,17 +13,17 @@
 
 #include "mozilla/Maybe.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/Move.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsTArray.h"
 
 namespace mozilla {
 namespace image {
 
 class SourceBuffer;
 
 /**
--- a/ipc/glue/BackgroundParentImpl.cpp
+++ b/ipc/glue/BackgroundParentImpl.cpp
@@ -19,17 +19,17 @@
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
 #include "mozilla/ipc/PBackgroundTestParent.h"
 #include "mozilla/layout/VsyncParent.h"
 #include "mozilla/dom/network/UDPSocketParent.h"
 #include "nsIAppsService.h"
 #include "nsNetUtil.h"
 #include "nsIScriptSecurityManager.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsThreadUtils.h"
 #include "nsTraceRefcnt.h"
 #include "nsXULAppAPI.h"
 #include "ServiceWorkerManagerParent.h"
 
 #ifdef DISABLE_ASSERTS_FOR_FUZZING
 #define ASSERT_UNLESS_FUZZING(...) do { } while (0)
 #else
--- a/ipc/ipdl/ipdl/builtin.py
+++ b/ipc/ipdl/ipdl/builtin.py
@@ -41,17 +41,17 @@ Types = (
 )
 
 
 HeaderIncludes = (
     'mozilla/Attributes.h',
     'prtime.h',
     'IPCMessageStart.h',
     'ipc/IPCMessageUtils.h',
-    'nsRefPtr.h',
+    'mozilla/nsRefPtr.h',
     'nsStringGlue.h',
     'nsTArray.h',
     'mozilla/ipc/ProtocolUtils.h',
 )
 
 CppIncludes = (
     'nsIFile.h',
     'GeckoProfiler.h',
--- a/layout/base/AccessibleCaret.h
+++ b/layout/base/AccessibleCaret.h
@@ -10,17 +10,17 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/AnonymousContent.h"
 #include "mozilla/dom/Element.h"
 #include "nsCOMPtr.h"
 #include "nsIDOMEventListener.h"
 #include "nsISupportsBase.h"
 #include "nsISupportsImpl.h"
 #include "nsRect.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsString.h"
 
 class nsIDocument;
 class nsIFrame;
 class nsIPresShell;
 struct nsPoint;
 
 namespace mozilla {
--- a/layout/base/AccessibleCaretEventHub.h
+++ b/layout/base/AccessibleCaretEventHub.h
@@ -11,17 +11,17 @@
 #include "mozilla/UniquePtr.h"
 #include "mozilla/WeakPtr.h"
 #include "nsCOMPtr.h"
 #include "nsIFrame.h"
 #include "nsIReflowObserver.h"
 #include "nsIScrollObserver.h"
 #include "nsISelectionListener.h"
 #include "nsPoint.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsWeakReference.h"
 
 class nsDocShell;
 class nsIPresShell;
 class nsITimer;
 
 namespace mozilla {
 class AccessibleCaretManager;
--- a/layout/base/AccessibleCaretManager.h
+++ b/layout/base/AccessibleCaretManager.h
@@ -6,17 +6,17 @@
 
 #ifndef AccessibleCaretManager_h
 #define AccessibleCaretManager_h
 
 #include "nsCOMPtr.h"
 #include "nsCoord.h"
 #include "nsIFrame.h"
 #include "nsISelectionListener.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsWeakReference.h"
 #include "mozilla/dom/CaretStateChangedEvent.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/WeakPtr.h"
 
 class nsFrameSelection;
 class nsIContent;
--- a/layout/ipc/VsyncChild.h
+++ b/layout/ipc/VsyncChild.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 mozilla_layout_ipc_VsyncChild_h
 #define mozilla_layout_ipc_VsyncChild_h
 
 #include "mozilla/layout/PVsyncChild.h"
 #include "nsISupportsImpl.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 
 class VsyncObserver;
 
 namespace ipc {
 class BackgroundChildImpl;
 } // namespace ipc
--- a/layout/ipc/VsyncParent.h
+++ b/layout/ipc/VsyncParent.h
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_layout_ipc_VsyncParent_h
 #define mozilla_layout_ipc_VsyncParent_h
 
 #include "mozilla/layout/PVsyncParent.h"
 #include "mozilla/VsyncDispatcher.h"
 #include "nsCOMPtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 class nsIThread;
 
 namespace mozilla {
 
 namespace ipc {
 class BackgroundParentImpl;
 } // namespace ipc
--- a/media/libstagefright/binding/Index.cpp
+++ b/media/libstagefright/binding/Index.cpp
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mp4_demuxer/ByteReader.h"
 #include "mp4_demuxer/Index.h"
 #include "mp4_demuxer/Interval.h"
 #include "mp4_demuxer/MoofParser.h"
 #include "mp4_demuxer/SinfParser.h"
 #include "nsAutoPtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #include <algorithm>
 #include <limits>
 
 using namespace stagefright;
 using namespace mozilla;
 
 namespace mp4_demuxer
--- a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
@@ -4,17 +4,17 @@
 
 #ifndef DECODER_DATA_H_
 #define DECODER_DATA_H_
 
 #include "MediaData.h"
 #include "MediaInfo.h"
 #include "mozilla/Types.h"
 #include "mozilla/Vector.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsString.h"
 
 namespace stagefright
 {
 class MetaData;
 }
--- a/media/libstagefright/binding/include/mp4_demuxer/ResourceStream.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/ResourceStream.h
@@ -2,17 +2,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 RESOURCESTREAM_H_
 #define RESOURCESTREAM_H_
 
 #include "MediaResource.h"
 #include "mp4_demuxer/Stream.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mp4_demuxer
 {
 
 class ResourceStream : public Stream
 {
 public:
   explicit ResourceStream(mozilla::MediaResource* aResource);
--- a/mfbt/moz.build
+++ b/mfbt/moz.build
@@ -52,16 +52,17 @@ EXPORTS.mozilla = [
     'MacroArgs.h',
     'MacroForEach.h',
     'MathAlgorithms.h',
     'Maybe.h',
     'MaybeOneOf.h',
     'MemoryChecking.h',
     'MemoryReporting.h',
     'Move.h',
+    'nsRefPtr.h',
     'NullPtr.h',
     'NumericLimits.h',
     'Pair.h',
     'PodOperations.h',
     'Poison.h',
     'Range.h',
     'RangedArray.h',
     'RangedPtr.h',
new file mode 100644
--- /dev/null
+++ b/mfbt/nsRefPtr.h
@@ -0,0 +1,522 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=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/. */
+
+#ifndef mozilla_nsRefPtr_h
+#define mozilla_nsRefPtr_h
+
+#include "mozilla/AlreadyAddRefed.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+
+/*****************************************************************************/
+
+// template <class T> class nsRefPtrGetterAddRefs;
+
+class nsCOMPtr_helper;
+
+namespace mozilla {
+namespace dom {
+template<class T> class OwningNonNull;
+} // namespace dom
+} // namespace mozilla
+
+template <class T>
+class nsRefPtr
+{
+private:
+  void
+  assign_with_AddRef(T* aRawPtr)
+  {
+    if (aRawPtr) {
+      aRawPtr->AddRef();
+    }
+    assign_assuming_AddRef(aRawPtr);
+  }
+
+  void**
+  begin_assignment()
+  {
+    assign_assuming_AddRef(0);
+    return reinterpret_cast<void**>(&mRawPtr);
+  }
+
+  void
+  assign_assuming_AddRef(T* aNewPtr)
+  {
+    T* oldPtr = mRawPtr;
+    mRawPtr = aNewPtr;
+    if (oldPtr) {
+      oldPtr->Release();
+    }
+  }
+
+private:
+  T* MOZ_OWNING_REF mRawPtr;
+
+public:
+  typedef T element_type;
+
+  ~nsRefPtr()
+  {
+    if (mRawPtr) {
+      mRawPtr->Release();
+    }
+  }
+
+  // Constructors
+
+  nsRefPtr()
+    : mRawPtr(0)
+    // default constructor
+  {
+  }
+
+  nsRefPtr(const nsRefPtr<T>& aSmartPtr)
+    : mRawPtr(aSmartPtr.mRawPtr)
+    // copy-constructor
+  {
+    if (mRawPtr) {
+      mRawPtr->AddRef();
+    }
+  }
+
+  nsRefPtr(nsRefPtr<T>&& aRefPtr)
+    : mRawPtr(aRefPtr.mRawPtr)
+  {
+    aRefPtr.mRawPtr = nullptr;
+  }
+
+  // construct from a raw pointer (of the right type)
+
+  MOZ_IMPLICIT nsRefPtr(T* aRawPtr)
+    : mRawPtr(aRawPtr)
+  {
+    if (mRawPtr) {
+      mRawPtr->AddRef();
+    }
+  }
+
+  template <typename I>
+  nsRefPtr(already_AddRefed<I>& aSmartPtr)
+    : mRawPtr(aSmartPtr.take())
+    // construct from |already_AddRefed|
+  {
+  }
+
+  template <typename I>
+  nsRefPtr(already_AddRefed<I>&& aSmartPtr)
+    : mRawPtr(aSmartPtr.take())
+    // construct from |otherRefPtr.forget()|
+  {
+  }
+
+  template <typename I>
+  nsRefPtr(nsRefPtr<I>&& aSmartPtr)
+    : mRawPtr(aSmartPtr.forget().take())
+    // construct from |Move(nsRefPtr<SomeSubclassOfT>)|.
+  {
+  }
+
+  MOZ_IMPLICIT nsRefPtr(const nsCOMPtr_helper& aHelper);
+
+  // Defined in OwningNonNull.h
+  template<class U>
+  MOZ_IMPLICIT nsRefPtr(const mozilla::dom::OwningNonNull<U>& aOther);
+
+  // Assignment operators
+
+  nsRefPtr<T>&
+  operator=(const nsRefPtr<T>& aRhs)
+  // copy assignment operator
+  {
+    assign_with_AddRef(aRhs.mRawPtr);
+    return *this;
+  }
+
+  nsRefPtr<T>&
+  operator=(T* aRhs)
+  // assign from a raw pointer (of the right type)
+  {
+    assign_with_AddRef(aRhs);
+    return *this;
+  }
+
+  template <typename I>
+  nsRefPtr<T>&
+  operator=(already_AddRefed<I>& aRhs)
+  // assign from |already_AddRefed|
+  {
+    assign_assuming_AddRef(aRhs.take());
+    return *this;
+  }
+
+  template <typename I>
+  nsRefPtr<T>&
+  operator=(already_AddRefed<I> && aRhs)
+  // assign from |otherRefPtr.forget()|
+  {
+    assign_assuming_AddRef(aRhs.take());
+    return *this;
+  }
+
+  nsRefPtr<T>& operator=(const nsCOMPtr_helper& aHelper);
+
+  nsRefPtr<T>&
+  operator=(nsRefPtr<T> && aRefPtr)
+  {
+    assign_assuming_AddRef(aRefPtr.mRawPtr);
+    aRefPtr.mRawPtr = nullptr;
+    return *this;
+  }
+
+  // Defined in OwningNonNull.h
+  template<class U>
+  nsRefPtr<T>&
+  operator=(const mozilla::dom::OwningNonNull<U>& aOther);
+
+  // Other pointer operators
+
+  void
+  swap(nsRefPtr<T>& aRhs)
+  // ...exchange ownership with |aRhs|; can save a pair of refcount operations
+  {
+    T* temp = aRhs.mRawPtr;
+    aRhs.mRawPtr = mRawPtr;
+    mRawPtr = temp;
+  }
+
+  void
+  swap(T*& aRhs)
+  // ...exchange ownership with |aRhs|; can save a pair of refcount operations
+  {
+    T* temp = aRhs;
+    aRhs = mRawPtr;
+    mRawPtr = temp;
+  }
+
+  already_AddRefed<T>
+  forget()
+  // return the value of mRawPtr and null out mRawPtr. Useful for
+  // already_AddRefed return values.
+  {
+    T* temp = 0;
+    swap(temp);
+    return already_AddRefed<T>(temp);
+  }
+
+  template <typename I>
+  void
+  forget(I** aRhs)
+  // Set the target of aRhs to the value of mRawPtr and null out mRawPtr.
+  // Useful to avoid unnecessary AddRef/Release pairs with "out"
+  // parameters where aRhs bay be a T** or an I** where I is a base class
+  // of T.
+  {
+    MOZ_ASSERT(aRhs, "Null pointer passed to forget!");
+    *aRhs = mRawPtr;
+    mRawPtr = 0;
+  }
+
+  T*
+  get() const
+  /*
+    Prefer the implicit conversion provided automatically by |operator T*() const|.
+    Use |get()| to resolve ambiguity or to get a castable pointer.
+  */
+  {
+    return const_cast<T*>(mRawPtr);
+  }
+
+  operator T*() const
+  /*
+    ...makes an |nsRefPtr| act like its underlying raw pointer type whenever it
+    is used in a context where a raw pointer is expected.  It is this operator
+    that makes an |nsRefPtr| substitutable for a raw pointer.
+
+    Prefer the implicit use of this operator to calling |get()|, except where
+    necessary to resolve ambiguity.
+  */
+  {
+    return get();
+  }
+
+  T*
+  operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN
+  {
+    MOZ_ASSERT(mRawPtr != 0,
+               "You can't dereference a NULL nsRefPtr with operator->().");
+    return get();
+  }
+
+  // This operator is needed for gcc <= 4.0.* and for Sun Studio; it
+  // causes internal compiler errors for some MSVC versions.  (It's not
+  // clear to me whether it should be needed.)
+#ifndef _MSC_VER
+  template <class U, class V>
+  U&
+  operator->*(U V::* aMember)
+  {
+    MOZ_ASSERT(mRawPtr != 0,
+               "You can't dereference a NULL nsRefPtr with operator->*().");
+    return get()->*aMember;
+  }
+#endif
+
+  nsRefPtr<T>*
+  get_address()
+  // This is not intended to be used by clients.  See |address_of|
+  // below.
+  {
+    return this;
+  }
+
+  const nsRefPtr<T>*
+  get_address() const
+  // This is not intended to be used by clients.  See |address_of|
+  // below.
+  {
+    return this;
+  }
+
+public:
+  T&
+  operator*() const
+  {
+    MOZ_ASSERT(mRawPtr != 0,
+               "You can't dereference a NULL nsRefPtr with operator*().");
+    return *get();
+  }
+
+  T**
+  StartAssignment()
+  {
+    assign_assuming_AddRef(0);
+    return reinterpret_cast<T**>(&mRawPtr);
+  }
+};
+
+class nsCycleCollectionTraversalCallback;
+template <typename T>
+void
+CycleCollectionNoteChild(nsCycleCollectionTraversalCallback& aCallback,
+                         T* aChild, const char* aName, uint32_t aFlags);
+
+template <typename T>
+inline void
+ImplCycleCollectionUnlink(nsRefPtr<T>& aField)
+{
+  aField = nullptr;
+}
+
+template <typename T>
+inline void
+ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
+                            nsRefPtr<T>& aField,
+                            const char* aName,
+                            uint32_t aFlags = 0)
+{
+  CycleCollectionNoteChild(aCallback, aField.get(), aName, aFlags);
+}
+
+template <class T>
+inline nsRefPtr<T>*
+address_of(nsRefPtr<T>& aPtr)
+{
+  return aPtr.get_address();
+}
+
+template <class T>
+inline const nsRefPtr<T>*
+address_of(const nsRefPtr<T>& aPtr)
+{
+  return aPtr.get_address();
+}
+
+template <class T>
+class nsRefPtrGetterAddRefs
+/*
+  ...
+
+  This class is designed to be used for anonymous temporary objects in the
+  argument list of calls that return COM interface pointers, e.g.,
+
+    nsRefPtr<IFoo> fooP;
+    ...->GetAddRefedPointer(getter_AddRefs(fooP))
+
+  DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE.  Use |getter_AddRefs()| instead.
+
+  When initialized with a |nsRefPtr|, as in the example above, it returns
+  a |void**|, a |T**|, or an |nsISupports**| as needed, that the
+  outer call (|GetAddRefedPointer| in this case) can fill in.
+
+  This type should be a nested class inside |nsRefPtr<T>|.
+*/
+{
+public:
+  explicit
+  nsRefPtrGetterAddRefs(nsRefPtr<T>& aSmartPtr)
+    : mTargetSmartPtr(aSmartPtr)
+  {
+    // nothing else to do
+  }
+
+  operator void**()
+  {
+    return reinterpret_cast<void**>(mTargetSmartPtr.StartAssignment());
+  }
+
+  operator T**()
+  {
+    return mTargetSmartPtr.StartAssignment();
+  }
+
+  T*&
+  operator*()
+  {
+    return *(mTargetSmartPtr.StartAssignment());
+  }
+
+private:
+  nsRefPtr<T>& mTargetSmartPtr;
+};
+
+template <class T>
+inline nsRefPtrGetterAddRefs<T>
+getter_AddRefs(nsRefPtr<T>& aSmartPtr)
+/*
+  Used around a |nsRefPtr| when
+  ...makes the class |nsRefPtrGetterAddRefs<T>| invisible.
+*/
+{
+  return nsRefPtrGetterAddRefs<T>(aSmartPtr);
+}
+
+
+// Comparing two |nsRefPtr|s
+
+template <class T, class U>
+inline bool
+operator==(const nsRefPtr<T>& aLhs, const nsRefPtr<U>& aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs.get());
+}
+
+
+template <class T, class U>
+inline bool
+operator!=(const nsRefPtr<T>& aLhs, const nsRefPtr<U>& aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs.get());
+}
+
+
+// Comparing an |nsRefPtr| to a raw pointer
+
+template <class T, class U>
+inline bool
+operator==(const nsRefPtr<T>& aLhs, const U* aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs);
+}
+
+template <class T, class U>
+inline bool
+operator==(const U* aLhs, const nsRefPtr<T>& aRhs)
+{
+  return static_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get());
+}
+
+template <class T, class U>
+inline bool
+operator!=(const nsRefPtr<T>& aLhs, const U* aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs);
+}
+
+template <class T, class U>
+inline bool
+operator!=(const U* aLhs, const nsRefPtr<T>& aRhs)
+{
+  return static_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
+}
+
+template <class T, class U>
+inline bool
+operator==(const nsRefPtr<T>& aLhs, U* aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) == const_cast<const U*>(aRhs);
+}
+
+template <class T, class U>
+inline bool
+operator==(U* aLhs, const nsRefPtr<T>& aRhs)
+{
+  return const_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get());
+}
+
+template <class T, class U>
+inline bool
+operator!=(const nsRefPtr<T>& aLhs, U* aRhs)
+{
+  return static_cast<const T*>(aLhs.get()) != const_cast<const U*>(aRhs);
+}
+
+template <class T, class U>
+inline bool
+operator!=(U* aLhs, const nsRefPtr<T>& aRhs)
+{
+  return const_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
+}
+
+namespace detail {
+class nsRefPtrZero;
+} // namespace detail
+
+// Comparing an |nsRefPtr| to |0|
+
+template <class T>
+inline bool
+operator==(const nsRefPtr<T>& aLhs, ::detail::nsRefPtrZero* aRhs)
+// specifically to allow |smartPtr == 0|
+{
+  return static_cast<const void*>(aLhs.get()) == reinterpret_cast<const void*>(aRhs);
+}
+
+template <class T>
+inline bool
+operator==(::detail::nsRefPtrZero* aLhs, const nsRefPtr<T>& aRhs)
+// specifically to allow |0 == smartPtr|
+{
+  return reinterpret_cast<const void*>(aLhs) == static_cast<const void*>(aRhs.get());
+}
+
+template <class T>
+inline bool
+operator!=(const nsRefPtr<T>& aLhs, ::detail::nsRefPtrZero* aRhs)
+// specifically to allow |smartPtr != 0|
+{
+  return static_cast<const void*>(aLhs.get()) != reinterpret_cast<const void*>(aRhs);
+}
+
+template <class T>
+inline bool
+operator!=(::detail::nsRefPtrZero* aLhs, const nsRefPtr<T>& aRhs)
+// specifically to allow |0 != smartPtr|
+{
+  return reinterpret_cast<const void*>(aLhs) != static_cast<const void*>(aRhs.get());
+}
+
+/*****************************************************************************/
+
+template <class T>
+inline already_AddRefed<T>
+do_AddRef(T*&& aObj)
+{
+  nsRefPtr<T> ref(aObj);
+  return ref.forget();
+}
+
+#endif /* mozilla_nsRefPtr_h */
--- a/modules/libjar/InterceptedJARChannel.h
+++ b/modules/libjar/InterceptedJARChannel.h
@@ -8,17 +8,17 @@
 #define InterceptedJARChannel_h
 
 #include "nsJAR.h"
 #include "nsJARChannel.h"
 #include "nsIInputStream.h"
 #include "nsIInputStreamPump.h"
 #include "nsINetworkInterceptController.h"
 #include "nsIOutputStream.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #include "mozilla/Maybe.h"
 
 class nsIStreamListener;
 class nsJARChannel;
 
 namespace mozilla {
 namespace net {
--- a/netwerk/base/Predictor.h
+++ b/netwerk/base/Predictor.h
@@ -12,17 +12,17 @@
 #include "nsCOMPtr.h"
 #include "nsICacheEntry.h"
 #include "nsICacheEntryOpenCallback.h"
 #include "nsICacheStorageVisitor.h"
 #include "nsIDNSListener.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIObserver.h"
 #include "nsISpeculativeConnect.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsString.h"
 #include "nsTArray.h"
 
 #include "mozilla/TimeStamp.h"
 
 class nsICacheStorage;
 class nsIDNSService;
 class nsIIOService;
--- a/netwerk/dns/mdns/libmdns/MDNSResponderOperator.h
+++ b/netwerk/dns/mdns/libmdns/MDNSResponderOperator.h
@@ -6,17 +6,17 @@
 #ifndef mozilla_netwerk_dns_mdns_libmdns_MDNSResponderOperator_h
 #define mozilla_netwerk_dns_mdns_libmdns_MDNSResponderOperator_h
 
 #include "dns_sd.h"
 #include "mozilla/Atomics.h"
 #include "nsCOMPtr.h"
 #include "nsIDNSServiceDiscovery.h"
 #include "nsIThread.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsString.h"
 
 namespace mozilla {
 namespace net {
 
 class MDNSResponderOperator
 {
 public:
--- a/netwerk/dns/mdns/libmdns/MDNSResponderReply.h
+++ b/netwerk/dns/mdns/libmdns/MDNSResponderReply.h
@@ -5,17 +5,17 @@
 
 #ifndef mozilla_netwerk_dns_mdns_libmdns_MDNSResponderReply_h
 #define mozilla_netwerk_dns_mdns_libmdns_MDNSResponderReply_h
 
 #include "dns_sd.h"
 #include "MDNSResponderOperator.h"
 #include "mozilla/UniquePtr.h"
 #include "nsIThread.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 namespace net {
 
 class BrowseReplyRunnable final : public nsRunnable
 {
 public:
--- a/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.h
+++ b/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.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 mozilla_netwerk_dns_mdns_libmdns_nsDNSServiceDiscovery_h
 #define mozilla_netwerk_dns_mdns_libmdns_nsDNSServiceDiscovery_h
 
 #include "nsIDNSServiceDiscovery.h"
 #include "nsCOMPtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsRefPtrHashtable.h"
 
 namespace mozilla {
 namespace net {
 
 class BrowseOperator;
 class RegisterOperator;
 
--- a/netwerk/protocol/http/InterceptedChannel.h
+++ b/netwerk/protocol/http/InterceptedChannel.h
@@ -3,17 +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/. */
 
 #ifndef InterceptedChannel_h
 #define InterceptedChannel_h
 
 #include "nsINetworkInterceptController.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/Maybe.h"
 
 class nsICacheEntry;
 class nsInputStreamPump;
 class nsIStreamListener;
 
 namespace mozilla {
 namespace net {
--- a/security/manager/ssl/nsProtectedAuthThread.cpp
+++ b/security/manager/ssl/nsProtectedAuthThread.cpp
@@ -1,15 +1,15 @@
 /* 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 "pk11func.h"
 #include "mozilla/DebugOnly.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsCOMPtr.h"
 #include "PSMRunnable.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsPKCS11Slot.h"
 #include "nsProtectedAuthThread.h"
 
 using namespace mozilla;
--- a/toolkit/components/url-classifier/LookupCache.h
+++ b/toolkit/components/url-classifier/LookupCache.h
@@ -7,17 +7,17 @@
 #define LookupCache_h__
 
 #include "Entries.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsCOMPtr.h"
 #include "nsIFile.h"
 #include "nsIFileStreams.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsUrlClassifierPrefixSet.h"
 #include "mozilla/Logging.h"
 
 namespace mozilla {
 namespace safebrowsing {
 
 #define MAX_HOST_COMPONENTS 5
 #define MAX_PATH_COMPONENTS 4
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -6,17 +6,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ContentCache.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/Logging.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEvents.h"
 #include "nsIWidget.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 
 using namespace widget;
 
 static const char*
 GetBoolName(bool aBool)
 {
--- a/widget/VsyncDispatcher.h
+++ b/widget/VsyncDispatcher.h
@@ -5,17 +5,17 @@
 
 #ifndef mozilla_widget_VsyncDispatcher_h
 #define mozilla_widget_VsyncDispatcher_h
 
 #include "mozilla/Mutex.h"
 #include "mozilla/TimeStamp.h"
 #include "nsISupportsImpl.h"
 #include "nsTArray.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 namespace mozilla {
 
 class VsyncObserver
 {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncObserver)
 
 public:
--- a/widget/gonk/GeckoTouchDispatcher.h
+++ b/widget/gonk/GeckoTouchDispatcher.h
@@ -17,17 +17,17 @@
 
 #ifndef GECKO_TOUCH_INPUT_DISPATCHER_h
 #define GECKO_TOUCH_INPUT_DISPATCHER_h
 
 #include "InputData.h"
 #include "Units.h"
 #include "mozilla/Mutex.h"
 #include <vector>
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 class nsIWidget;
 
 namespace mozilla {
 namespace layers {
 class CompositorVsyncScheduler;
 }
 
--- a/widget/nsPrintSettingsImpl.cpp
+++ b/widget/nsPrintSettingsImpl.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 "nsPrintSettingsImpl.h"
 #include "nsReadableUtils.h"
 #include "nsIPrintSession.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/gfx/Logging.h"
 
 #define DEFAULT_MARGIN_WIDTH 0.5
 
 NS_IMPL_ISUPPORTS(nsPrintSettings, nsIPrintSettings)
 
 /** ---------------------------------------------------
  *  See documentation in nsPrintSettingsImpl.h
--- a/xpcom/base/moz.build
+++ b/xpcom/base/moz.build
@@ -50,17 +50,16 @@ EXPORTS += [
     'nsError.h',
     'nsGZFileWriter.h',
     'nsIID.h',
     'nsInterfaceRequestorAgg.h',
     'nsISizeOf.h',
     'nsISupportsBase.h',
     'nsObjCExceptions.h',
     'nsQueryObject.h',
-    'nsRefPtr.h',
     'nsTraceRefcnt.h',
     'nsWeakPtr.h',
 ]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     EXPORTS += [
         'nsWindowsHelpers.h',
     ]
--- a/xpcom/base/nsAutoPtr.h
+++ b/xpcom/base/nsAutoPtr.h
@@ -3,17 +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/. */
 
 #ifndef nsAutoPtr_h
 #define nsAutoPtr_h
 
 #include "nsCOMPtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #include "nsCycleCollectionNoteChild.h"
 #include "mozilla/MemoryReporting.h"
 
 /*****************************************************************************/
 
 // template <class T> class nsAutoPtrGetterTransfers;
 
--- a/xpcom/base/nsQueryObject.h
+++ b/xpcom/base/nsQueryObject.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsQueryObject_h
 #define nsQueryObject_h
 
 #include "mozilla/Attributes.h"
 
 #include "nsCOMPtr.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 /*****************************************************************************/
 
 template<class T>
 class MOZ_STACK_CLASS nsQueryObject final : public nsCOMPtr_helper
 {
 public:
   explicit nsQueryObject(T* aRawPtr)
deleted file mode 100644
--- a/xpcom/base/nsRefPtr.h
+++ /dev/null
@@ -1,522 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=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/. */
-
-#ifndef nsRefPtr_h
-#define nsRefPtr_h
-
-#include "mozilla/AlreadyAddRefed.h"
-#include "mozilla/Assertions.h"
-#include "mozilla/Attributes.h"
-
-/*****************************************************************************/
-
-// template <class T> class nsRefPtrGetterAddRefs;
-
-class nsCOMPtr_helper;
-
-namespace mozilla {
-namespace dom {
-template<class T> class OwningNonNull;
-} // namespace dom
-} // namespace mozilla
-
-template <class T>
-class nsRefPtr
-{
-private:
-  void
-  assign_with_AddRef(T* aRawPtr)
-  {
-    if (aRawPtr) {
-      aRawPtr->AddRef();
-    }
-    assign_assuming_AddRef(aRawPtr);
-  }
-
-  void**
-  begin_assignment()
-  {
-    assign_assuming_AddRef(0);
-    return reinterpret_cast<void**>(&mRawPtr);
-  }
-
-  void
-  assign_assuming_AddRef(T* aNewPtr)
-  {
-    T* oldPtr = mRawPtr;
-    mRawPtr = aNewPtr;
-    if (oldPtr) {
-      oldPtr->Release();
-    }
-  }
-
-private:
-  T* MOZ_OWNING_REF mRawPtr;
-
-public:
-  typedef T element_type;
-
-  ~nsRefPtr()
-  {
-    if (mRawPtr) {
-      mRawPtr->Release();
-    }
-  }
-
-  // Constructors
-
-  nsRefPtr()
-    : mRawPtr(0)
-    // default constructor
-  {
-  }
-
-  nsRefPtr(const nsRefPtr<T>& aSmartPtr)
-    : mRawPtr(aSmartPtr.mRawPtr)
-    // copy-constructor
-  {
-    if (mRawPtr) {
-      mRawPtr->AddRef();
-    }
-  }
-
-  nsRefPtr(nsRefPtr<T>&& aRefPtr)
-    : mRawPtr(aRefPtr.mRawPtr)
-  {
-    aRefPtr.mRawPtr = nullptr;
-  }
-
-  // construct from a raw pointer (of the right type)
-
-  MOZ_IMPLICIT nsRefPtr(T* aRawPtr)
-    : mRawPtr(aRawPtr)
-  {
-    if (mRawPtr) {
-      mRawPtr->AddRef();
-    }
-  }
-
-  template <typename I>
-  nsRefPtr(already_AddRefed<I>& aSmartPtr)
-    : mRawPtr(aSmartPtr.take())
-    // construct from |already_AddRefed|
-  {
-  }
-
-  template <typename I>
-  nsRefPtr(already_AddRefed<I>&& aSmartPtr)
-    : mRawPtr(aSmartPtr.take())
-    // construct from |otherRefPtr.forget()|
-  {
-  }
-
-  template <typename I>
-  nsRefPtr(nsRefPtr<I>&& aSmartPtr)
-    : mRawPtr(aSmartPtr.forget().take())
-    // construct from |Move(nsRefPtr<SomeSubclassOfT>)|.
-  {
-  }
-
-  MOZ_IMPLICIT nsRefPtr(const nsCOMPtr_helper& aHelper);
-
-  // Defined in OwningNonNull.h
-  template<class U>
-  MOZ_IMPLICIT nsRefPtr(const mozilla::dom::OwningNonNull<U>& aOther);
-
-  // Assignment operators
-
-  nsRefPtr<T>&
-  operator=(const nsRefPtr<T>& aRhs)
-  // copy assignment operator
-  {
-    assign_with_AddRef(aRhs.mRawPtr);
-    return *this;
-  }
-
-  nsRefPtr<T>&
-  operator=(T* aRhs)
-  // assign from a raw pointer (of the right type)
-  {
-    assign_with_AddRef(aRhs);
-    return *this;
-  }
-
-  template <typename I>
-  nsRefPtr<T>&
-  operator=(already_AddRefed<I>& aRhs)
-  // assign from |already_AddRefed|
-  {
-    assign_assuming_AddRef(aRhs.take());
-    return *this;
-  }
-
-  template <typename I>
-  nsRefPtr<T>&
-  operator=(already_AddRefed<I> && aRhs)
-  // assign from |otherRefPtr.forget()|
-  {
-    assign_assuming_AddRef(aRhs.take());
-    return *this;
-  }
-
-  nsRefPtr<T>& operator=(const nsCOMPtr_helper& aHelper);
-
-  nsRefPtr<T>&
-  operator=(nsRefPtr<T> && aRefPtr)
-  {
-    assign_assuming_AddRef(aRefPtr.mRawPtr);
-    aRefPtr.mRawPtr = nullptr;
-    return *this;
-  }
-
-  // Defined in OwningNonNull.h
-  template<class U>
-  nsRefPtr<T>&
-  operator=(const mozilla::dom::OwningNonNull<U>& aOther);
-
-  // Other pointer operators
-
-  void
-  swap(nsRefPtr<T>& aRhs)
-  // ...exchange ownership with |aRhs|; can save a pair of refcount operations
-  {
-    T* temp = aRhs.mRawPtr;
-    aRhs.mRawPtr = mRawPtr;
-    mRawPtr = temp;
-  }
-
-  void
-  swap(T*& aRhs)
-  // ...exchange ownership with |aRhs|; can save a pair of refcount operations
-  {
-    T* temp = aRhs;
-    aRhs = mRawPtr;
-    mRawPtr = temp;
-  }
-
-  already_AddRefed<T>
-  forget()
-  // return the value of mRawPtr and null out mRawPtr. Useful for
-  // already_AddRefed return values.
-  {
-    T* temp = 0;
-    swap(temp);
-    return already_AddRefed<T>(temp);
-  }
-
-  template <typename I>
-  void
-  forget(I** aRhs)
-  // Set the target of aRhs to the value of mRawPtr and null out mRawPtr.
-  // Useful to avoid unnecessary AddRef/Release pairs with "out"
-  // parameters where aRhs bay be a T** or an I** where I is a base class
-  // of T.
-  {
-    MOZ_ASSERT(aRhs, "Null pointer passed to forget!");
-    *aRhs = mRawPtr;
-    mRawPtr = 0;
-  }
-
-  T*
-  get() const
-  /*
-    Prefer the implicit conversion provided automatically by |operator T*() const|.
-    Use |get()| to resolve ambiguity or to get a castable pointer.
-  */
-  {
-    return const_cast<T*>(mRawPtr);
-  }
-
-  operator T*() const
-  /*
-    ...makes an |nsRefPtr| act like its underlying raw pointer type whenever it
-    is used in a context where a raw pointer is expected.  It is this operator
-    that makes an |nsRefPtr| substitutable for a raw pointer.
-
-    Prefer the implicit use of this operator to calling |get()|, except where
-    necessary to resolve ambiguity.
-  */
-  {
-    return get();
-  }
-
-  T*
-  operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN
-  {
-    MOZ_ASSERT(mRawPtr != 0,
-               "You can't dereference a NULL nsRefPtr with operator->().");
-    return get();
-  }
-
-  // This operator is needed for gcc <= 4.0.* and for Sun Studio; it
-  // causes internal compiler errors for some MSVC versions.  (It's not
-  // clear to me whether it should be needed.)
-#ifndef _MSC_VER
-  template <class U, class V>
-  U&
-  operator->*(U V::* aMember)
-  {
-    MOZ_ASSERT(mRawPtr != 0,
-               "You can't dereference a NULL nsRefPtr with operator->*().");
-    return get()->*aMember;
-  }
-#endif
-
-  nsRefPtr<T>*
-  get_address()
-  // This is not intended to be used by clients.  See |address_of|
-  // below.
-  {
-    return this;
-  }
-
-  const nsRefPtr<T>*
-  get_address() const
-  // This is not intended to be used by clients.  See |address_of|
-  // below.
-  {
-    return this;
-  }
-
-public:
-  T&
-  operator*() const
-  {
-    MOZ_ASSERT(mRawPtr != 0,
-               "You can't dereference a NULL nsRefPtr with operator*().");
-    return *get();
-  }
-
-  T**
-  StartAssignment()
-  {
-    assign_assuming_AddRef(0);
-    return reinterpret_cast<T**>(&mRawPtr);
-  }
-};
-
-class nsCycleCollectionTraversalCallback;
-template <typename T>
-void
-CycleCollectionNoteChild(nsCycleCollectionTraversalCallback& aCallback,
-                         T* aChild, const char* aName, uint32_t aFlags);
-
-template <typename T>
-inline void
-ImplCycleCollectionUnlink(nsRefPtr<T>& aField)
-{
-  aField = nullptr;
-}
-
-template <typename T>
-inline void
-ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
-                            nsRefPtr<T>& aField,
-                            const char* aName,
-                            uint32_t aFlags = 0)
-{
-  CycleCollectionNoteChild(aCallback, aField.get(), aName, aFlags);
-}
-
-template <class T>
-inline nsRefPtr<T>*
-address_of(nsRefPtr<T>& aPtr)
-{
-  return aPtr.get_address();
-}
-
-template <class T>
-inline const nsRefPtr<T>*
-address_of(const nsRefPtr<T>& aPtr)
-{
-  return aPtr.get_address();
-}
-
-template <class T>
-class nsRefPtrGetterAddRefs
-/*
-  ...
-
-  This class is designed to be used for anonymous temporary objects in the
-  argument list of calls that return COM interface pointers, e.g.,
-
-    nsRefPtr<IFoo> fooP;
-    ...->GetAddRefedPointer(getter_AddRefs(fooP))
-
-  DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE.  Use |getter_AddRefs()| instead.
-
-  When initialized with a |nsRefPtr|, as in the example above, it returns
-  a |void**|, a |T**|, or an |nsISupports**| as needed, that the
-  outer call (|GetAddRefedPointer| in this case) can fill in.
-
-  This type should be a nested class inside |nsRefPtr<T>|.
-*/
-{
-public:
-  explicit
-  nsRefPtrGetterAddRefs(nsRefPtr<T>& aSmartPtr)
-    : mTargetSmartPtr(aSmartPtr)
-  {
-    // nothing else to do
-  }
-
-  operator void**()
-  {
-    return reinterpret_cast<void**>(mTargetSmartPtr.StartAssignment());
-  }
-
-  operator T**()
-  {
-    return mTargetSmartPtr.StartAssignment();
-  }
-
-  T*&
-  operator*()
-  {
-    return *(mTargetSmartPtr.StartAssignment());
-  }
-
-private:
-  nsRefPtr<T>& mTargetSmartPtr;
-};
-
-template <class T>
-inline nsRefPtrGetterAddRefs<T>
-getter_AddRefs(nsRefPtr<T>& aSmartPtr)
-/*
-  Used around a |nsRefPtr| when
-  ...makes the class |nsRefPtrGetterAddRefs<T>| invisible.
-*/
-{
-  return nsRefPtrGetterAddRefs<T>(aSmartPtr);
-}
-
-
-// Comparing two |nsRefPtr|s
-
-template <class T, class U>
-inline bool
-operator==(const nsRefPtr<T>& aLhs, const nsRefPtr<U>& aRhs)
-{
-  return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs.get());
-}
-
-
-template <class T, class U>
-inline bool
-operator!=(const nsRefPtr<T>& aLhs, const nsRefPtr<U>& aRhs)
-{
-  return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs.get());
-}
-
-
-// Comparing an |nsRefPtr| to a raw pointer
-
-template <class T, class U>
-inline bool
-operator==(const nsRefPtr<T>& aLhs, const U* aRhs)
-{
-  return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs);
-}
-
-template <class T, class U>
-inline bool
-operator==(const U* aLhs, const nsRefPtr<T>& aRhs)
-{
-  return static_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get());
-}
-
-template <class T, class U>
-inline bool
-operator!=(const nsRefPtr<T>& aLhs, const U* aRhs)
-{
-  return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs);
-}
-
-template <class T, class U>
-inline bool
-operator!=(const U* aLhs, const nsRefPtr<T>& aRhs)
-{
-  return static_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
-}
-
-template <class T, class U>
-inline bool
-operator==(const nsRefPtr<T>& aLhs, U* aRhs)
-{
-  return static_cast<const T*>(aLhs.get()) == const_cast<const U*>(aRhs);
-}
-
-template <class T, class U>
-inline bool
-operator==(U* aLhs, const nsRefPtr<T>& aRhs)
-{
-  return const_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get());
-}
-
-template <class T, class U>
-inline bool
-operator!=(const nsRefPtr<T>& aLhs, U* aRhs)
-{
-  return static_cast<const T*>(aLhs.get()) != const_cast<const U*>(aRhs);
-}
-
-template <class T, class U>
-inline bool
-operator!=(U* aLhs, const nsRefPtr<T>& aRhs)
-{
-  return const_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get());
-}
-
-namespace detail {
-class nsRefPtrZero;
-} // namespace detail
-
-// Comparing an |nsRefPtr| to |0|
-
-template <class T>
-inline bool
-operator==(const nsRefPtr<T>& aLhs, ::detail::nsRefPtrZero* aRhs)
-// specifically to allow |smartPtr == 0|
-{
-  return static_cast<const void*>(aLhs.get()) == reinterpret_cast<const void*>(aRhs);
-}
-
-template <class T>
-inline bool
-operator==(::detail::nsRefPtrZero* aLhs, const nsRefPtr<T>& aRhs)
-// specifically to allow |0 == smartPtr|
-{
-  return reinterpret_cast<const void*>(aLhs) == static_cast<const void*>(aRhs.get());
-}
-
-template <class T>
-inline bool
-operator!=(const nsRefPtr<T>& aLhs, ::detail::nsRefPtrZero* aRhs)
-// specifically to allow |smartPtr != 0|
-{
-  return static_cast<const void*>(aLhs.get()) != reinterpret_cast<const void*>(aRhs);
-}
-
-template <class T>
-inline bool
-operator!=(::detail::nsRefPtrZero* aLhs, const nsRefPtr<T>& aRhs)
-// specifically to allow |0 != smartPtr|
-{
-  return reinterpret_cast<const void*>(aLhs) != static_cast<const void*>(aRhs.get());
-}
-
-/*****************************************************************************/
-
-template <class T>
-inline already_AddRefed<T>
-do_AddRef(T*&& aObj)
-{
-  nsRefPtr<T> ref(aObj);
-  return ref.forget();
-}
-
-#endif // !defined(nsRefPtr_h)
--- a/xpcom/glue/nsCOMPtr.h
+++ b/xpcom/glue/nsCOMPtr.h
@@ -23,17 +23,17 @@
 #include "mozilla/AlreadyAddRefed.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Move.h"
 #include "mozilla/TypeTraits.h"
 
 #include "nsDebug.h" // for |NS_ASSERTION|
 #include "nsISupportsUtils.h" // for |nsresult|, |NS_ADDREF|, |NS_GET_TEMPLATE_IID| et al
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 
 #include "nsCycleCollectionNoteChild.h"
 
 
 /*
  * WARNING: This file defines several macros for internal use only. These
  * macros begin with the prefix |NSCAP_|. Do not use these macros in your own
  * code. They are for internal use only for cross-platform compatibility, and
--- a/xpcom/glue/nsISupportsUtils.h
+++ b/xpcom/glue/nsISupportsUtils.h
@@ -7,17 +7,17 @@
 #ifndef nsISupportsUtils_h__
 #define nsISupportsUtils_h__
 
 #include "nscore.h"
 #include "nsISupportsBase.h"
 #include "nsError.h"
 #include "nsDebug.h"
 #include "nsISupportsImpl.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "mozilla/TypeTraits.h"
 
 /**
  * Macro for adding a reference to an interface.
  * @param _ptr The interface pointer.
  */
 #define NS_ADDREF(_ptr) \
   (_ptr)->AddRef()
--- a/xpcom/io/nsPipe3.cpp
+++ b/xpcom/io/nsPipe3.cpp
@@ -6,17 +6,17 @@
 
 #include <algorithm>
 #include "mozilla/Attributes.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "nsICloneableInputStream.h"
 #include "nsIPipe.h"
 #include "nsIEventTarget.h"
 #include "nsISeekableStream.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsSegmentedBuffer.h"
 #include "nsStreamUtils.h"
 #include "nsCOMPtr.h"
 #include "nsCRT.h"
 #include "mozilla/Logging.h"
 #include "nsIClassInfoImpl.h"
 #include "nsAlgorithm.h"
 #include "nsMemory.h"
--- a/xpcom/tests/gtest/TestStrings.cpp
+++ b/xpcom/tests/gtest/TestStrings.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include "nsString.h"
 #include "nsStringBuffer.h"
 #include "nsReadableUtils.h"
 #include "nsCRTGlue.h"
-#include "nsRefPtr.h"
+#include "mozilla/nsRefPtr.h"
 #include "nsTArray.h"
 #include "gtest/gtest.h"
 
 namespace TestStrings {
 
 using mozilla::fallible;
 
 void test_assign_helper(const nsACString& in, nsACString &_retval)