Bug 1215763 - part 2 - s/nsAutoPtr/UniquePtr/ in image/; r=seth
authorNathan Froyd <froydnj@mozilla.com>
Sat, 17 Oct 2015 06:53:28 -0400
changeset 302893 f97147507b76dcd793e1404d0bd53e0e68d43d60
parent 302892 5196440d55874384952812fceeed711406082082
child 302894 929ab834e415e984a0b71ad0decd7177852b634d
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth
bugs1215763
milestone44.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 1215763 - part 2 - s/nsAutoPtr/UniquePtr/ in image/; r=seth These conversions should be straightforward, but we have to add a .get for nsExpirationTracker::Iterator.
image/ClippedImage.cpp
image/ClippedImage.h
image/imgLoader.cpp
image/imgLoader.h
image/imgRequestProxy.cpp
image/imgRequestProxy.h
--- a/image/ClippedImage.cpp
+++ b/image/ClippedImage.cpp
@@ -291,19 +291,19 @@ ClippedImage::GetFrameInternal(const nsI
     gfxUtils::DrawPixelSnapped(ctx, drawable, aSize,
                                ImageRegion::Create(aSize),
                                SurfaceFormat::B8G8R8A8,
                                Filter::LINEAR,
                                imgIContainer::FLAG_CLAMP);
 
     // Cache the resulting surface.
     mCachedSurface =
-      new ClippedImageCachedSurface(target->Snapshot(), aSize, aSVGContext,
-                                    frameToDraw, aFlags,
-                                    drawTileCallback->GetDrawResult());
+      MakeUnique<ClippedImageCachedSurface>(target->Snapshot(), aSize, aSVGContext,
+                                            frameToDraw, aFlags,
+                                            drawTileCallback->GetDrawResult());
   }
 
   MOZ_ASSERT(mCachedSurface, "Should have a cached surface now");
   RefPtr<SourceSurface> surface = mCachedSurface->Surface();
   return MakePair(mCachedSurface->GetDrawResult(), Move(surface));
 }
 
 NS_IMETHODIMP_(bool)
--- a/image/ClippedImage.h
+++ b/image/ClippedImage.h
@@ -5,16 +5,17 @@
 
 #ifndef mozilla_image_ClippedImage_h
 #define mozilla_image_ClippedImage_h
 
 #include "ImageWrapper.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/RefPtr.h"
+#include "mozilla/UniquePtr.h"
 
 namespace mozilla {
 namespace image {
 
 class ClippedImageCachedSurface;
 class DrawSingleTileCallback;
 
 /**
@@ -78,17 +79,17 @@ private:
                             const nsIntSize& aSize,
                             const ImageRegion& aRegion,
                             uint32_t aWhichFrame,
                             gfx::Filter aFilter,
                             const Maybe<SVGImageContext>& aSVGContext,
                             uint32_t aFlags);
 
   // If we are forced to draw a temporary surface, we cache it here.
-  nsAutoPtr<ClippedImageCachedSurface> mCachedSurface;
+  UniquePtr<ClippedImageCachedSurface> mCachedSurface;
 
   nsIntRect   mClip;              // The region to clip to.
   Maybe<bool> mShouldClip;        // Memoized ShouldClip() if present.
 
   friend class DrawSingleTileCallback;
   friend class ImageOps;
 };
 
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -1185,17 +1185,17 @@ imgLoader::VerifyCacheSizes()
   if (!mCacheTracker) {
     return;
   }
 
   uint32_t cachesize = mCache.Count() + mChromeCache.Count();
   uint32_t queuesize =
     mCacheQueue.GetNumElements() + mChromeCacheQueue.GetNumElements();
   uint32_t trackersize = 0;
-  for (nsExpirationTracker<imgCacheEntry, 3>::Iterator it(mCacheTracker);
+  for (nsExpirationTracker<imgCacheEntry, 3>::Iterator it(mCacheTracker.get());
        it.Next(); ){
     trackersize++;
   }
   MOZ_ASSERT(queuesize == trackersize, "Queue and tracker sizes out of sync!");
   MOZ_ASSERT(queuesize <= cachesize, "Queue has more elements than cache!");
 #endif
 }
 
@@ -1248,17 +1248,17 @@ imgLoader::InitCache()
   os->AddObserver(this, "memory-pressure", false);
   os->AddObserver(this, "app-theme-changed", false);
   os->AddObserver(this, "chrome-flush-skin-caches", false);
   os->AddObserver(this, "chrome-flush-caches", false);
   os->AddObserver(this, "last-pb-context-exited", false);
   os->AddObserver(this, "profile-before-change", false);
   os->AddObserver(this, "xpcom-shutdown", false);
 
-  mCacheTracker = new imgCacheExpirationTracker();
+  mCacheTracker = MakeUnique<imgCacheExpirationTracker>();
 
   return NS_OK;
 }
 
 nsresult
 imgLoader::Init()
 {
   InitCache();
--- a/image/imgLoader.h
+++ b/image/imgLoader.h
@@ -4,24 +4,24 @@
  * 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_image_imgLoader_h
 #define mozilla_image_imgLoader_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/Mutex.h"
+#include "mozilla/UniquePtr.h"
 
 #include "imgILoader.h"
 #include "imgICache.h"
 #include "nsWeakReference.h"
 #include "nsIContentSniffer.h"
 #include "nsRefPtrHashtable.h"
 #include "nsExpirationTracker.h"
-#include "nsAutoPtr.h"
 #include "ImageCacheKey.h"
 #include "imgRequest.h"
 #include "nsIProgressEventSink.h"
 #include "nsIChannel.h"
 #include "nsIThreadRetargetableStreamListener.h"
 #include "imgIRequest.h"
 #include "mozilla/net/ReferrerPolicy.h"
 
@@ -435,17 +435,17 @@ private: // data
   Mutex mUncachedImagesMutex;
 
   static double sCacheTimeWeight;
   static uint32_t sCacheMaxSize;
   static imgMemoryReporter* sMemReporter;
 
   nsCString mAcceptHeader;
 
-  nsAutoPtr<imgCacheExpirationTracker> mCacheTracker;
+  mozilla::UniquePtr<imgCacheExpirationTracker> mCacheTracker;
   bool mRespectPrivacy;
 };
 
 
 
 /**
  * proxy stream listener class used to handle multipart/x-mixed-replace
  */
--- a/image/imgRequestProxy.cpp
+++ b/image/imgRequestProxy.cpp
@@ -1085,17 +1085,17 @@ private:
   // the job of the underlying request.
   RefPtr<mozilla::image::Image> mImage;
 };
 
 imgRequestProxyStatic::imgRequestProxyStatic(mozilla::image::Image* aImage,
                                              nsIPrincipal* aPrincipal)
 : mPrincipal(aPrincipal)
 {
-  mBehaviour = new StaticBehaviour(aImage);
+  mBehaviour = mozilla::MakeUnique<StaticBehaviour>(aImage);
 }
 
 NS_IMETHODIMP
 imgRequestProxyStatic::GetImagePrincipal(nsIPrincipal** aPrincipal)
 {
   if (!mPrincipal) {
     return NS_ERROR_FAILURE;
   }
--- a/image/imgRequestProxy.h
+++ b/image/imgRequestProxy.h
@@ -9,19 +9,19 @@
 
 #include "imgIRequest.h"
 #include "nsISecurityInfoProvider.h"
 
 #include "nsILoadGroup.h"
 #include "nsISupportsPriority.h"
 #include "nsITimedChannel.h"
 #include "nsCOMPtr.h"
-#include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "mozilla/TimeStamp.h"
+#include "mozilla/UniquePtr.h"
 #include "mozilla/gfx/Rect.h"
 
 #include "imgRequest.h"
 #include "IProgressObserver.h"
 
 #define NS_IMGREQUESTPROXY_CID \
 { /* 20557898-1dd2-11b2-8f65-9c462ee2bc95 */         \
      0x20557898,                                     \
@@ -186,17 +186,17 @@ protected:
   nsresult PerformClone(imgINotificationObserver* aObserver,
                         imgRequestProxy* (aAllocFn)(imgRequestProxy*),
                         imgRequestProxy** aClone);
 
 public:
   NS_FORWARD_SAFE_NSITIMEDCHANNEL(TimedChannel())
 
 protected:
-  nsAutoPtr<ProxyBehaviour> mBehaviour;
+  mozilla::UniquePtr<ProxyBehaviour> mBehaviour;
 
 private:
   friend class imgCacheValidator;
   friend imgRequestProxy* NewStaticProxy(imgRequestProxy* aThis);
 
   // The URI of our request.
   RefPtr<ImageURL> mURI;