Bug 915937 - Cleanup #defines in nsNSSComponent.cpp and change them to static consts. r=bsmith
authorCykesiopka <cykesiopka.bmo@gmail.com>
Tue, 03 Dec 2013 15:23:27 -0500
changeset 173321 65a57bce96ef0fcaa914b4114e16e92afb667731
parent 173320 ad6fa6ac9d1124d1b7fa9fe63d4999dfc3cd469b
child 173322 2572592c326dc2c632351877fa517f3f67c2ffcb
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmith
bugs915937
milestone28.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 915937 - Cleanup #defines in nsNSSComponent.cpp and change them to static consts. r=bsmith
security/manager/ssl/src/nsNSSComponent.cpp
--- a/security/manager/ssl/src/nsNSSComponent.cpp
+++ b/security/manager/ssl/src/nsNSSComponent.cpp
@@ -79,19 +79,16 @@ int nsNSSComponent::mInstanceCount = 0;
 
 #ifndef NSS_NO_LIBPKIX
 bool nsNSSComponent::globalConstFlagUsePKIXVerification = false;
 #endif
 
 // XXX tmp callback for slot password
 extern char* pk11PasswordPrompt(PK11SlotInfo *slot, PRBool retry, void *arg);
 
-#define PIPNSS_STRBUNDLE_URL "chrome://pipnss/locale/pipnss.properties"
-#define NSSERR_STRBUNDLE_URL "chrome://pipnss/locale/nsserrors.properties"
-
 #ifndef MOZ_DISABLE_CRYPTOLEGACY
 //This class is used to run the callback code
 //passed to the event handlers for smart card notification
 class nsTokenEventRunnable : public nsIRunnable {
 public:
   nsTokenEventRunnable(const nsAString &aType, const nsAString &aTokenName);
   virtual ~nsTokenEventRunnable();
 
@@ -805,23 +802,23 @@ nsresult
 nsNSSComponent::InitializePIPNSSBundle()
 {
   // Called during init only, no mutex required.
 
   nsresult rv;
   nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
   if (NS_FAILED(rv) || !bundleService) 
     return NS_ERROR_FAILURE;
-  
-  bundleService->CreateBundle(PIPNSS_STRBUNDLE_URL,
+
+  bundleService->CreateBundle("chrome://pipnss/locale/pipnss.properties",
                               getter_AddRefs(mPIPNSSBundle));
   if (!mPIPNSSBundle)
     rv = NS_ERROR_FAILURE;
 
-  bundleService->CreateBundle(NSSERR_STRBUNDLE_URL,
+  bundleService->CreateBundle("chrome://pipnss/locale/nsserrors.properties",
                               getter_AddRefs(mNSSErrorsBundle));
   if (!mNSSErrorsBundle)
     rv = NS_ERROR_FAILURE;
 
   return rv;
 }
 
 /* Table of pref names and SSL cipher ID */
@@ -916,30 +913,20 @@ setNonPkixOcspEnabled(int32_t ocspEnable
     CERT_DisableOCSPChecking(CERT_GetDefaultCertDB());
     CERT_DisableOCSPDefaultResponder(CERT_GetDefaultCertDB());
   } else {
     CERT_EnableOCSPChecking(CERT_GetDefaultCertDB());
     CERT_DisableOCSPDefaultResponder(CERT_GetDefaultCertDB());
   }
 }
 
-#define CRL_DOWNLOAD_DEFAULT false
-#define OCSP_ENABLED_DEFAULT 1
-#define OCSP_REQUIRED_DEFAULT false
-#define FRESH_REVOCATION_REQUIRED_DEFAULT false
-#define MISSING_CERT_DOWNLOAD_DEFAULT false
-#define FIRST_REVO_METHOD_DEFAULT "ocsp"
-#define USE_NSS_LIBPKIX_DEFAULT false
-#define OCSP_STAPLING_ENABLED_DEFAULT true
-
-static const bool SUPPRESS_WARNING_PREF_DEFAULT = false;
+static const int32_t OCSP_ENABLED_DEFAULT = 1;
 static const bool REQUIRE_SAFE_NEGOTIATION_DEFAULT = false;
 static const bool ALLOW_UNRESTRICTED_RENEGO_DEFAULT = false;
 static const bool FALSE_START_ENABLED_DEFAULT = true;
-static const bool CIPHER_ENABLED_DEFAULT = false;
 
 namespace {
 
 class CipherSuiteChangeObserver : public nsIObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
@@ -1015,36 +1002,35 @@ CipherSuiteChangeObserver::Observe(nsISu
 } // anonymous namespace
 
 // Caller must hold a lock on nsNSSComponent::mutex when calling this function
 void nsNSSComponent::setValidationOptions()
 {
   nsNSSShutDownPreventionLock locker;
 
   bool crlDownloading = Preferences::GetBool("security.CRL_download.enabled",
-                                             CRL_DOWNLOAD_DEFAULT);
+                                             false);
   // 0 = disabled, 1 = enabled
   int32_t ocspEnabled = Preferences::GetInt("security.OCSP.enabled",
                                             OCSP_ENABLED_DEFAULT);
 
-  bool ocspRequired = Preferences::GetBool("security.OCSP.require",
-                                           OCSP_REQUIRED_DEFAULT);
+  bool ocspRequired = Preferences::GetBool("security.OCSP.require", false);
   bool anyFreshRequired = Preferences::GetBool("security.fresh_revocation_info.require",
-                                               FRESH_REVOCATION_REQUIRED_DEFAULT);
+                                               false);
   bool aiaDownloadEnabled = Preferences::GetBool("security.missing_cert_download.enabled",
-                                                 MISSING_CERT_DOWNLOAD_DEFAULT);
+                                                 false);
 
   nsCString firstNetworkRevo =
     Preferences::GetCString("security.first_network_revocation_method");
   if (firstNetworkRevo.IsEmpty()) {
-    firstNetworkRevo = FIRST_REVO_METHOD_DEFAULT;
+    firstNetworkRevo = "ocsp";
   }
 
   bool ocspStaplingEnabled = Preferences::GetBool("security.ssl.enable_ocsp_stapling",
-                                                  OCSP_STAPLING_ENABLED_DEFAULT);
+                                                  true);
   if (!ocspEnabled) {
     ocspStaplingEnabled = false;
   }
   PublicSSLState()->SetOCSPStaplingEnabled(ocspStaplingEnabled);
   PrivateSSLState()->SetOCSPStaplingEnabled(ocspStaplingEnabled);
 
   setNonPkixOcspEnabled(ocspEnabled);
 
@@ -1210,22 +1196,21 @@ nsNSSComponent::InitializeNSS(bool showW
       if (NS_FAILED(rv)) {
         nsPSMInitPanic::SetPanic();
         return rv;
       }
     }
 
 #ifndef NSS_NO_LIBPKIX
     globalConstFlagUsePKIXVerification =
-      Preferences::GetBool("security.use_libpkix_verification", USE_NSS_LIBPKIX_DEFAULT);
+      Preferences::GetBool("security.use_libpkix_verification", false);
 #endif
 
     bool suppressWarningPref =
-      Preferences::GetBool("security.suppress_nss_rw_impossible_warning",
-                           SUPPRESS_WARNING_PREF_DEFAULT);
+      Preferences::GetBool("security.suppress_nss_rw_impossible_warning", false);
 
     // init phase 2, init calls to NSS library
 
     PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("NSS Initialization beginning\n"));
 
     // The call to ConfigureInternalPKCS11Token needs to be done before NSS is initialized, 
     // but affects only static data.
     // If we could assume i18n will not change between profiles, one call per application
@@ -1623,21 +1608,24 @@ nsNSSComponent::RandomUpdate(void *entro
 
   if (!mNSSInitialized)
       return NS_ERROR_NOT_INITIALIZED;
 
   PK11_RandomUpdate(entropy, bufLen);
   return NS_OK;
 }
 
-#define PROFILE_CHANGE_NET_TEARDOWN_TOPIC "profile-change-net-teardown"
-#define PROFILE_CHANGE_NET_RESTORE_TOPIC "profile-change-net-restore"
-#define PROFILE_CHANGE_TEARDOWN_TOPIC "profile-change-teardown"
-#define PROFILE_BEFORE_CHANGE_TOPIC "profile-before-change"
-#define PROFILE_DO_CHANGE_TOPIC "profile-do-change"
+static const char* const PROFILE_CHANGE_NET_TEARDOWN_TOPIC
+  = "profile-change-net-teardown";
+static const char* const PROFILE_CHANGE_NET_RESTORE_TOPIC
+  = "profile-change-net-restore";
+static const char* const PROFILE_CHANGE_TEARDOWN_TOPIC
+  = "profile-change-teardown";
+static const char* const PROFILE_BEFORE_CHANGE_TOPIC = "profile-before-change";
+static const char* const PROFILE_DO_CHANGE_TOPIC = "profile-do-change";
 
 NS_IMETHODIMP
 nsNSSComponent::Observe(nsISupports *aSubject, const char *aTopic, 
                         const PRUnichar *someData)
 {
   if (nsCRT::strcmp(aTopic, PROFILE_CHANGE_TEARDOWN_TOPIC) == 0) {
     PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("in PSM code, receiving change-teardown\n"));
     DoProfileChangeTeardown(aSubject);