Bug 1470420: Change an nsAutoPtr to UniquePtr in the Loader. r?xidorn draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 22 Jun 2018 14:54:08 +0200
changeset 809585 fdcdfafb787e92c6543f3c40aa65785d2ce8274b
parent 809584 4771711f6d6287a0830b1ef04dcdb9941b574214
child 809586 e76cb483492f8a7cd5bf3dc00b8a88fc1e1bf623
push id113714
push userbmo:emilio@crisal.io
push dateFri, 22 Jun 2018 13:03:48 +0000
reviewersxidorn
bugs1470420
milestone62.0a1
Bug 1470420: Change an nsAutoPtr to UniquePtr in the Loader. r?xidorn MozReview-Commit-ID: 4KnjxHOybmG
layout/style/Loader.cpp
layout/style/Loader.h
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -927,17 +927,17 @@ Loader::CreateSheet(nsIURI* aURI,
                     bool aSyncLoad,
                     StyleSheetState& aSheetState,
                     RefPtr<StyleSheet>* aSheet)
 {
   LOG(("css::Loader::CreateSheet"));
   MOZ_ASSERT(aSheet, "Null out param!");
 
   if (!mSheets) {
-    mSheets = new Sheets();
+    mSheets = MakeUnique<Sheets>();
   }
 
   *aSheet = nullptr;
   aSheetState = eSheetStateUnknown;
 
   if (aURI) {
     aSheetState = eSheetComplete;
     RefPtr<StyleSheet> sheet;
--- a/layout/style/Loader.h
+++ b/layout/style/Loader.h
@@ -5,32 +5,32 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* loading of CSS style sheets using the network APIs */
 
 #ifndef mozilla_css_Loader_h
 #define mozilla_css_Loader_h
 
 #include "nsIPrincipal.h"
-#include "nsAutoPtr.h"
 #include "nsCompatibility.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsDataHashtable.h"
 #include "nsRefPtrHashtable.h"
 #include "nsStringFwd.h"
 #include "nsTArray.h"
 #include "nsTObserverArray.h"
 #include "nsURIHashKey.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/CORSMode.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/StyleSheet.h"
+#include "mozilla/UniquePtr.h"
 #include "mozilla/net/ReferrerPolicy.h"
 
 class nsICSSLoaderObserver;
 class nsIConsoleReportCollector;
 class nsIContent;
 class nsIDocument;
 
 namespace mozilla {
@@ -584,17 +584,17 @@ private:
     nsBaseHashtable<URIPrincipalReferrerPolicyAndCORSModeHashKey,
                     RefPtr<StyleSheet>,
                     StyleSheet*> mCompleteSheets;
     nsDataHashtable<URIPrincipalReferrerPolicyAndCORSModeHashKey, SheetLoadData*>
                       mLoadingDatas; // weak refs
     nsDataHashtable<URIPrincipalReferrerPolicyAndCORSModeHashKey, SheetLoadData*>
                       mPendingDatas; // weak refs
   };
-  nsAutoPtr<Sheets> mSheets;
+  UniquePtr<Sheets> mSheets;
 
   // The array of posted stylesheet loaded events (SheetLoadDatas) we have.
   // Note that these are rare.
   LoadDataArray mPostedEvents;
 
   // Our array of "global" observers
   nsTObserverArray<nsCOMPtr<nsICSSLoaderObserver> > mObservers;