Bug 1421541 - Tweak some comments. r=glandium draft
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 29 Nov 2017 18:47:19 +1100
changeset 704979 707a68baebc71af572974943702b57246b080533
parent 704978 6d4198ff2785e1377b718477e3fb29d2dd2fa4f5
child 704980 fefb67f6e48ec83368b6170aba050883d512eb22
push id91299
push usernnethercote@mozilla.com
push dateWed, 29 Nov 2017 08:10:36 +0000
reviewersglandium
bugs1421541
milestone59.0a1
Bug 1421541 - Tweak some comments. r=glandium This includes removing a bunch of low-value ones. MozReview-Commit-ID: LGS9M9TCL4e
modules/libpref/Preferences.cpp
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -106,17 +106,17 @@ using namespace mozilla;
 #define ENSURE_PARENT_PROCESS(func, pref)                                      \
   if (MOZ_UNLIKELY(!XRE_IsParentProcess())) {                                  \
     return NS_ERROR_NOT_AVAILABLE;                                             \
   }
 
 #endif // DEBUG
 
 //===========================================================================
-// The old low-level prefs API
+// Low-level types and operations
 //===========================================================================
 
 typedef nsTArray<nsCString> PrefSaveData;
 
 // 1 MB should be enough for everyone.
 static const uint32_t MAX_PREF_LENGTH = 1 * 1024 * 1024;
 // Actually, 4kb should be enough for everyone.
 static const uint32_t MAX_ADVISABLE_PREF_LENGTH = 4 * 1024;
@@ -694,18 +694,16 @@ static bool gShouldCleanupDeadNodes = fa
 static PLDHashTableOps pref_HashTableOps = {
   PLDHashTable::HashStringKey,
   Pref::MatchEntry,
   PLDHashTable::MoveEntryStub,
   Pref::ClearEntry,
   nullptr,
 };
 
-//---------------------------------------------------------------------------
-
 static Pref*
 pref_HashTableLookup(const char* aPrefName);
 
 static void
 NotifyCallbacks(const char* aPrefName);
 
 #define PREF_HASHTABLE_INITIAL_LENGTH 1024
 
@@ -729,20 +727,16 @@ pref_savePrefs()
       "user_pref(%s, %s);", prefNameStr.get(), prefValueStr.get());
 
     savedPrefs.AppendElement(str);
   }
 
   return savedPrefs;
 }
 
-  //
-  // Hash table functions
-  //
-
 #ifdef DEBUG
 
 static pref_initPhase gPhase = START;
 
 struct StringComparator
 {
   const char* mPrefName;
 
@@ -2710,20 +2704,16 @@ nsPrefBranch::GetPrefName(const char* aP
 //----------------------------------------------------------------------------
 // nsPrefLocalizedString
 //----------------------------------------------------------------------------
 
 nsPrefLocalizedString::nsPrefLocalizedString() = default;
 
 nsPrefLocalizedString::~nsPrefLocalizedString() = default;
 
-//
-// nsISupports Implementation
-//
-
 NS_IMPL_ADDREF(nsPrefLocalizedString)
 NS_IMPL_RELEASE(nsPrefLocalizedString)
 
 NS_INTERFACE_MAP_BEGIN(nsPrefLocalizedString)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrefLocalizedString)
   NS_INTERFACE_MAP_ENTRY(nsIPrefLocalizedString)
   NS_INTERFACE_MAP_ENTRY(nsISupportsString)
 NS_INTERFACE_MAP_END
@@ -2773,17 +2763,17 @@ nsRelativeFilePref::GetRelativeToKey(nsA
 NS_IMETHODIMP
 nsRelativeFilePref::SetRelativeToKey(const nsACString& aRelativeToKey)
 {
   mRelativeToKey.Assign(aRelativeToKey);
   return NS_OK;
 }
 
 //===========================================================================
-// Core prefs code
+// class Preferences and related things
 //===========================================================================
 
 namespace mozilla {
 
 #define INITIAL_PREF_FILES 10
 
 static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
 
@@ -3402,22 +3392,16 @@ Preferences::InitStaticMembers()
 Preferences::Shutdown()
 {
   if (!sShutdown) {
     sShutdown = true; // Don't create the singleton instance after here.
     sPreferences = nullptr;
   }
 }
 
-//-----------------------------------------------------------------------------
-
-//
-// Constructor/Destructor
-//
-
 Preferences::Preferences()
   : mRootBranch(new nsPrefBranch("", PrefValueKind::User))
   , mDefaultRootBranch(new nsPrefBranch("", PrefValueKind::Default))
 {
 }
 
 Preferences::~Preferences()
 {
@@ -3437,35 +3421,27 @@ Preferences::~Preferences()
   }
   gLastPriorityNode = gFirstCallback = nullptr;
 
   delete gHashTable;
   gHashTable = nullptr;
   gPrefNameArena.Clear();
 }
 
-//
-// nsISupports Implementation
-//
-
 NS_IMPL_ADDREF(Preferences)
 NS_IMPL_RELEASE(Preferences)
 
 NS_INTERFACE_MAP_BEGIN(Preferences)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrefService)
   NS_INTERFACE_MAP_ENTRY(nsIPrefService)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
   NS_INTERFACE_MAP_ENTRY(nsIPrefBranch)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_END
 
-//
-// nsIPrefService Implementation
-//
-
 /* static */ void
 Preferences::SetInitPreferences(nsTArray<dom::Pref>* aDomPrefs)
 {
   gInitDomPrefs = new InfallibleTArray<dom::Pref>(mozilla::Move(*aDomPrefs));
 }
 
 /* static */ void
 Preferences::InitializeUserPrefs()
@@ -3967,20 +3943,16 @@ openPrefFile(nsIFile* aFile)
   Parser parser;
   if (!parser.Parse(data.get(), data.Length())) {
     return NS_ERROR_FILE_CORRUPTED;
   }
 
   return NS_OK;
 }
 
-//
-// Some stuff that gets called from Pref_Init()
-//
-
 static int
 pref_CompareFileNames(nsIFile* aFile1, nsIFile* aFile2, void* /* unused */)
 {
   nsAutoCString filename1, filename2;
   aFile1->GetNativeLeafName(filename1);
   aFile2->GetNativeLeafName(filename2);
 
   return Compare(filename2, filename1);
@@ -4337,20 +4309,16 @@ Preferences::InitInitialObjects()
   NS_ENSURE_SUCCESS(rv, Err("GetObserverService() failed (2)"));
 
   observerService->NotifyObservers(
     nullptr, NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID, nullptr);
 
   return Ok();
 }
 
-//----------------------------------------------------------------------------
-// Static utilities
-//----------------------------------------------------------------------------
-
 /* static */ nsresult
 Preferences::GetBool(const char* aPrefName, bool* aResult, PrefValueKind aKind)
 {
   NS_PRECONDITION(aResult, "aResult must not be NULL");
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
 
   Pref* pref = pref_HashTableLookup(aPrefName);
   return pref ? pref->GetBoolValue(aKind, aResult) : NS_ERROR_UNEXPECTED;