Bug 1045436 - Fix more bad implicit constructors in XPCOM; r=froydnj
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 29 Jul 2014 20:43:56 -0400
changeset 196688 f55d33cb0e7f0f215411b55d826e9ac2faaaa2b3
parent 196687 858c7a6a138025cb8c393d6298458d68fc2699b9
child 196689 b07c3d5ec540016dd609169d76ab5637886a9122
push id46940
push usereakhgari@mozilla.com
push dateWed, 30 Jul 2014 00:44:17 +0000
treeherdermozilla-inbound@f55d33cb0e7f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1045436
milestone34.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 1045436 - Fix more bad implicit constructors in XPCOM; r=froydnj
dom/plugins/base/nsNPAPIPluginInstance.cpp
dom/promise/Promise.cpp
dom/workers/DataStore.cpp
dom/workers/Navigator.cpp
dom/workers/ServiceWorkerManager.cpp
security/manager/ssl/src/PSMRunnable.h
xpcom/base/nsAutoRef.h
xpcom/components/ModuleUtils.h
xpcom/glue/AppData.h
xpcom/glue/FileUtils.cpp
xpcom/glue/GenericFactory.h
xpcom/glue/ReentrantMonitor.h
xpcom/glue/nsArrayEnumerator.cpp
xpcom/glue/nsCategoryCache.h
xpcom/glue/nsEnumeratorUtils.cpp
xpcom/glue/nsINIParser.cpp
xpcom/glue/nsProxyRelease.cpp
xpcom/glue/nsProxyRelease.h
xpcom/glue/nsStringAPI.h
xpcom/glue/nsTObserverArray.h
xpcom/glue/nsTWeakRef.h
xpcom/glue/nsThreadUtils.cpp
xpcom/glue/nsVersionComparator.h
xpcom/glue/nsVoidArray.h
xpcom/glue/nsWeakReference.cpp
xpcom/reflect/xptinfo/xptinfo.h
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -1807,17 +1807,17 @@ nsNPAPIPluginInstance::CheckJavaC2PJSObj
 
   // Due to the Java version being specified inconsistently across platforms
   // check the version via the mimetype for choosing specific Java versions
   nsCString javaVersion;
   if (!GetJavaVersionFromMimetype(pluginTag, javaVersion)) {
     return;
   }
 
-  mozilla::Version version = javaVersion.get();
+  mozilla::Version version(javaVersion.get());
 
   if (version >= "1.7.0.4") {
     return;
   }
 
   if (!haveCodeParam && version >= "1.6.0.34" && version < "1.7") {
     return;
   }
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -1383,18 +1383,18 @@ PromiseWorkerProxy::GetWorkerPromise() c
   return mWorkerPromise;
 }
 
 void
 PromiseWorkerProxy::StoreISupports(nsISupports* aSupports)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  nsMainThreadPtrHandle<nsISupports> supports =
-    new nsMainThreadPtrHolder<nsISupports>(aSupports);
+  nsMainThreadPtrHandle<nsISupports> supports(
+    new nsMainThreadPtrHolder<nsISupports>(aSupports));
   mSupportsArray.AppendElement(supports);
 }
 
 void
 PromiseWorkerProxy::RunCallback(JSContext* aCx,
                                 JS::Handle<JS::Value> aValue,
                                 RunCallbackFunc aFunc)
 {
--- a/dom/workers/DataStore.cpp
+++ b/dom/workers/DataStore.cpp
@@ -411,18 +411,18 @@ public:
 protected:
   virtual bool
   MainThreadRun() MOZ_OVERRIDE
   {
     AssertIsOnMainThread();
 
     // Point WorkerDataStoreCursor to DataStoreCursor.
     nsRefPtr<DataStoreCursor> cursor = mBackingStore->Sync(mRevisionId, mRv);
-    nsMainThreadPtrHandle<DataStoreCursor> backingCursor =
-      new nsMainThreadPtrHolder<DataStoreCursor>(cursor);
+    nsMainThreadPtrHandle<DataStoreCursor> backingCursor(
+      new nsMainThreadPtrHolder<DataStoreCursor>(cursor));
     mWorkerCursor->SetBackingDataStoreCursor(backingCursor);
 
     return true;
   }
 };
 
 void
 WorkerDataStore::GetName(JSContext* aCx, nsAString& aName, ErrorResult& aRv)
--- a/dom/workers/Navigator.cpp
+++ b/dom/workers/Navigator.cpp
@@ -117,17 +117,17 @@ GetDataStoresStructuredCloneCallbacksRea
     return nullptr;
   }
 
   // Protect workerStoreObj from moving GC during ~nsRefPtr.
   JS::Rooted<JSObject*> workerStoreObj(aCx, nullptr);
   {
     nsRefPtr<WorkerDataStore> workerStore =
       new WorkerDataStore(workerPrivate->GlobalScope());
-    nsMainThreadPtrHandle<DataStore> backingStore = dataStoreholder;
+    nsMainThreadPtrHandle<DataStore> backingStore(dataStoreholder);
 
     // When we're on the worker thread, prepare a DataStoreChangeEventProxy.
     nsRefPtr<DataStoreChangeEventProxy> eventProxy =
       new DataStoreChangeEventProxy(workerPrivate, workerStore);
 
     // Add the DataStoreChangeEventProxy as an event listener on the main thread.
     nsRefPtr<DataStoreAddEventListenerRunnable> runnable =
       new DataStoreAddEventListenerRunnable(workerPrivate,
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -256,18 +256,18 @@ public:
                                                     mScriptSpec,
                                                     mRegistration->mScope,
                                                     getter_AddRefs(serviceWorker));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       swm->RejectUpdatePromiseObservers(mRegistration, rv);
       return;
     }
 
-    nsMainThreadPtrHandle<ServiceWorkerUpdateInstance> handle =
-      new nsMainThreadPtrHolder<ServiceWorkerUpdateInstance>(this);
+    nsMainThreadPtrHandle<ServiceWorkerUpdateInstance> handle(
+      new nsMainThreadPtrHolder<ServiceWorkerUpdateInstance>(this));
     // FIXME(nsm): Deal with error case (worker failed to download, redirect,
     // parse) in error handler patch.
     nsRefPtr<FinishSuccessfulFetchWorkerRunnable> r =
       new FinishSuccessfulFetchWorkerRunnable(serviceWorker->GetWorkerPrivate(), handle);
 
     AutoSafeJSContext cx;
     if (!r->Dispatch(cx)) {
       swm->RejectUpdatePromiseObservers(mRegistration, NS_ERROR_FAILURE);
@@ -1004,18 +1004,18 @@ ServiceWorkerManager::Install(ServiceWor
                               ServiceWorkerInfo* aServiceWorkerInfo)
 {
   AssertIsOnMainThread();
   aRegistration->mInstallingWorker = aServiceWorkerInfo;
   MOZ_ASSERT(aRegistration->mInstallingWorker);
   InvalidateServiceWorkerContainerWorker(aRegistration,
                                          WhichServiceWorker::INSTALLING_WORKER);
 
-  nsMainThreadPtrHandle<ServiceWorkerRegistration> handle =
-    new nsMainThreadPtrHolder<ServiceWorkerRegistration>(aRegistration);
+  nsMainThreadPtrHandle<ServiceWorkerRegistration> handle(
+    new nsMainThreadPtrHolder<ServiceWorkerRegistration>(aRegistration));
 
   nsRefPtr<ServiceWorker> serviceWorker;
   nsresult rv =
     CreateServiceWorker(aServiceWorkerInfo->GetScriptSpec(),
                         aRegistration->mScope,
                         getter_AddRefs(serviceWorker));
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -1080,18 +1080,18 @@ public:
     nsresult rv =
       swm->CreateServiceWorker(mRegistration->mCurrentWorker->GetScriptSpec(),
                                mRegistration->mScope,
                                getter_AddRefs(serviceWorker));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    nsMainThreadPtrHandle<ServiceWorkerRegistration> handle =
-      new nsMainThreadPtrHolder<ServiceWorkerRegistration>(mRegistration);
+    nsMainThreadPtrHandle<ServiceWorkerRegistration> handle(
+      new nsMainThreadPtrHolder<ServiceWorkerRegistration>(mRegistration));
 
     nsRefPtr<ActivateEventRunnable> r =
       new ActivateEventRunnable(serviceWorker->GetWorkerPrivate(), handle);
 
     AutoSafeJSContext cx;
     if (!r->Dispatch(cx)) {
       return NS_ERROR_FAILURE;
     }
--- a/security/manager/ssl/src/PSMRunnable.h
+++ b/security/manager/ssl/src/PSMRunnable.h
@@ -27,18 +27,18 @@ private:
   mozilla::Monitor monitor;
 };
 
 class NotifyObserverRunnable : public nsRunnable
 {
 public:
   NotifyObserverRunnable(nsIObserver * observer,
                          const char * topicStringLiteral)
-    : mObserver(), mTopic(topicStringLiteral) {
-    mObserver = new nsMainThreadPtrHolder<nsIObserver>(observer);
+    : mObserver(new nsMainThreadPtrHolder<nsIObserver>(observer)),
+      mTopic(topicStringLiteral) {
   }
   NS_DECL_NSIRUNNABLE
 private:
   nsMainThreadPtrHandle<nsIObserver> mObserver;
   const char * const mTopic;
 };
 
 } } // namespace mozilla::psm
--- a/xpcom/base/nsAutoRef.h
+++ b/xpcom/base/nsAutoRef.h
@@ -316,28 +316,28 @@ public:
   // For constructing a return value with no resource
   nsReturnRef()
   {
   }
 
   // For returning a smart reference from a raw reference that must be
   // released.  Explicit construction is required so as not to risk
   // unintentionally releasing the resource associated with a raw ref.
-  explicit nsReturnRef(RawRefOnly aRefToRelease)
+  MOZ_IMPLICIT nsReturnRef(RawRefOnly aRefToRelease)
     : BaseClass(aRefToRelease)
   {
   }
 
   // Copy construction transfers ownership
   nsReturnRef(nsReturnRef<T>& aRefToSteal)
     : BaseClass(aRefToSteal)
   {
   }
 
-  nsReturnRef(const nsReturningRef<T>& aReturning)
+  MOZ_IMPLICIT nsReturnRef(const nsReturningRef<T>& aReturning)
     : BaseClass(aReturning)
   {
   }
 
   // Conversion to a temporary (const) object referring to this object so
   // that the reference may be passed from a function return value
   // (temporary) to another smart reference.  There is no need to use this
   // explicitly.  Simply assign a nsReturnRef<T> function return value to a
@@ -508,17 +508,17 @@ protected:
   // functionality will still be available, but the default constructor,
   // |reset|, and most transfer of ownership methods will not be available.
   nsSimpleRef()
     : mRawRef(Traits::Void())
   {
   }
   // Construct with a handle to a resource.
   // A specialization must provide this.
-  nsSimpleRef(RawRef aRawRef)
+  explicit nsSimpleRef(RawRef aRawRef)
     : mRawRef(aRawRef)
   {
   }
 
   // Test whether there is an associated resource.  A specialization must
   // provide this.  The function is permitted to always return true if the
   // default constructor is not accessible, or if Release (and AddRef) can
   // deal with void handles.
@@ -562,17 +562,17 @@ protected:
 
   // A type for parameters that should be passed a raw ref but should not
   // accept implicit conversions (from another smart ref).  (The only
   // conversion to this type is from a raw ref so only raw refs will be
   // accepted.)
   class RawRefOnly
   {
   public:
-    RawRefOnly(RawRef aRawRef)
+    MOZ_IMPLICIT RawRefOnly(RawRef aRawRef)
       : mRawRef(aRawRef)
     {
     }
     operator RawRef() const
     {
       return mRawRef;
     }
   private:
--- a/xpcom/components/ModuleUtils.h
+++ b/xpcom/components/ModuleUtils.h
@@ -102,17 +102,17 @@ static nsresult                         
 
 namespace mozilla {
 
 class GenericModule MOZ_FINAL : public nsIModule
 {
     ~GenericModule() {}
 
 public:
-    GenericModule(const mozilla::Module* aData)
+    explicit GenericModule(const mozilla::Module* aData)
         : mData(aData)
     {
     }
 
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIMODULE
 
 private:
--- a/xpcom/glue/AppData.h
+++ b/xpcom/glue/AppData.h
@@ -20,17 +20,17 @@ class NS_COM_GLUE ScopedAppData : public
 {
 public:
   ScopedAppData()
   {
     Zero();
     this->size = sizeof(*this);
   }
 
-  ScopedAppData(const nsXREAppData* aAppData);
+  explicit ScopedAppData(const nsXREAppData* aAppData);
 
   void Zero() { memset(this, 0, sizeof(*this)); }
 
   ~ScopedAppData();
 };
 
 /**
  * Given |aStr| is holding a string allocated with NS_Alloc, or null:
--- a/xpcom/glue/FileUtils.cpp
+++ b/xpcom/glue/FileUtils.cpp
@@ -266,17 +266,17 @@ static const uint32_t CPU_TYPE = CPU_TYP
 #define segment_command segment_command_64
 #else
 #define cpu_mach_header mach_header
 #endif
 
 class ScopedMMap
 {
 public:
-  ScopedMMap(const char* aFilePath)
+  explicit ScopedMMap(const char* aFilePath)
     : buf(nullptr)
   {
     fd = open(aFilePath, O_RDONLY);
     if (fd < 0) {
       return;
     }
     struct stat st;
     if (fstat(fd, &st) < 0) {
--- a/xpcom/glue/GenericFactory.h
+++ b/xpcom/glue/GenericFactory.h
@@ -23,17 +23,17 @@ class GenericFactory MOZ_FINAL : public 
   ~GenericFactory() {}
 
 public:
   typedef Module::ConstructorProcPtr ConstructorProcPtr;
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIFACTORY
 
-  GenericFactory(ConstructorProcPtr aCtor)
+  explicit GenericFactory(ConstructorProcPtr aCtor)
     : mCtor(aCtor)
   {
     NS_ASSERTION(mCtor, "GenericFactory with no constructor");
   }
 
 private:
   ConstructorProcPtr mCtor;
 };
--- a/xpcom/glue/ReentrantMonitor.h
+++ b/xpcom/glue/ReentrantMonitor.h
@@ -36,17 +36,17 @@ namespace mozilla {
  **/
 class NS_COM_GLUE ReentrantMonitor : BlockingResourceBase
 {
 public:
   /**
    * ReentrantMonitor
    * @param aName A name which can reference this monitor
    */
-  ReentrantMonitor(const char* aName)
+  explicit ReentrantMonitor(const char* aName)
     : BlockingResourceBase(aName, eReentrantMonitor)
 #ifdef DEBUG
     , mEntryCount(0)
 #endif
   {
     MOZ_COUNT_CTOR(ReentrantMonitor);
     mReentrantMonitor = PR_NewMonitor();
     if (!mReentrantMonitor) {
@@ -168,17 +168,17 @@ class NS_COM_GLUE MOZ_STACK_CLASS Reentr
 public:
   /**
    * Constructor
    * The constructor aquires the given lock.  The destructor
    * releases the lock.
    *
    * @param aReentrantMonitor A valid mozilla::ReentrantMonitor*.
    **/
-  ReentrantMonitorAutoEnter(mozilla::ReentrantMonitor& aReentrantMonitor)
+  explicit ReentrantMonitorAutoEnter(mozilla::ReentrantMonitor& aReentrantMonitor)
     : mReentrantMonitor(&aReentrantMonitor)
   {
     NS_ASSERTION(mReentrantMonitor, "null monitor");
     mReentrantMonitor->Enter();
   }
 
   ~ReentrantMonitorAutoEnter(void)
   {
@@ -217,17 +217,17 @@ public:
    * Constructor
    * The constructor releases the given lock.  The destructor
    * acquires the lock. The lock must be held before constructing
    * this object!
    *
    * @param aReentrantMonitor A valid mozilla::ReentrantMonitor*. It
    *                 must be already locked.
    **/
-  ReentrantMonitorAutoExit(ReentrantMonitor& aReentrantMonitor)
+  explicit ReentrantMonitorAutoExit(ReentrantMonitor& aReentrantMonitor)
     : mReentrantMonitor(&aReentrantMonitor)
   {
     NS_ASSERTION(mReentrantMonitor, "null monitor");
     mReentrantMonitor->AssertCurrentThreadIn();
     mReentrantMonitor->Exit();
   }
 
   ~ReentrantMonitorAutoExit(void)
--- a/xpcom/glue/nsArrayEnumerator.cpp
+++ b/xpcom/glue/nsArrayEnumerator.cpp
@@ -19,17 +19,17 @@ class nsSimpleArrayEnumerator MOZ_FINAL 
 public:
   // nsISupports interface
   NS_DECL_ISUPPORTS
 
   // nsISimpleEnumerator interface
   NS_DECL_NSISIMPLEENUMERATOR
 
   // nsSimpleArrayEnumerator methods
-  nsSimpleArrayEnumerator(nsIArray* aValueArray)
+  explicit nsSimpleArrayEnumerator(nsIArray* aValueArray)
     : mValueArray(aValueArray)
     , mIndex(0)
   {
   }
 
 private:
   ~nsSimpleArrayEnumerator() {}
 
--- a/xpcom/glue/nsCategoryCache.h
+++ b/xpcom/glue/nsCategoryCache.h
@@ -22,17 +22,17 @@
 
 #include "nsXPCOM.h"
 
 class NS_COM_GLUE nsCategoryObserver MOZ_FINAL : public nsIObserver
 {
   ~nsCategoryObserver();
 
 public:
-  nsCategoryObserver(const char* aCategory);
+  explicit nsCategoryObserver(const char* aCategory);
 
   void ListenerDied();
   nsInterfaceHashtable<nsCStringHashKey, nsISupports>& GetHash()
   {
     return mHash;
   }
 
   NS_DECL_ISUPPORTS
--- a/xpcom/glue/nsEnumeratorUtils.cpp
+++ b/xpcom/glue/nsEnumeratorUtils.cpp
@@ -100,17 +100,17 @@ class nsSingletonEnumerator MOZ_FINAL : 
 {
 public:
   NS_DECL_ISUPPORTS
 
   // nsISimpleEnumerator methods
   NS_IMETHOD HasMoreElements(bool* aResult);
   NS_IMETHOD GetNext(nsISupports** aResult);
 
-  nsSingletonEnumerator(nsISupports* aValue);
+  explicit nsSingletonEnumerator(nsISupports* aValue);
 
 private:
   ~nsSingletonEnumerator();
 
 protected:
   nsISupports* mValue;
   bool mConsumed;
 };
--- a/xpcom/glue/nsINIParser.cpp
+++ b/xpcom/glue/nsINIParser.cpp
@@ -41,17 +41,17 @@ TS_tfopen(const char* aPath, const char*
 #endif
 
 // Stack based FILE wrapper to ensure that fclose is called, copied from
 // toolkit/mozapps/update/updater/readstrings.cpp
 
 class AutoFILE
 {
 public:
-  AutoFILE(FILE* aFp = nullptr) : fp_(aFp) {}
+  explicit AutoFILE(FILE* aFp = nullptr) : fp_(aFp) {}
   ~AutoFILE()
   {
     if (fp_) {
       fclose(fp_);
     }
   }
   operator FILE*() { return fp_; }
   FILE** operator&() { return &fp_; }
@@ -90,17 +90,17 @@ nsINIParser::Init(nsIFile* aFile)
 
   return InitFromFILE(fd);
 }
 
 nsresult
 nsINIParser::Init(const char* aPath)
 {
   /* open the file */
-  AutoFILE fd = TS_tfopen(aPath, READ_BINARYMODE);
+  AutoFILE fd(TS_tfopen(aPath, READ_BINARYMODE));
   if (!fd) {
     return NS_ERROR_FAILURE;
   }
 
   return InitFromFILE(fd);
 }
 
 static const char kNL[] = "\r\n";
--- a/xpcom/glue/nsProxyRelease.cpp
+++ b/xpcom/glue/nsProxyRelease.cpp
@@ -6,17 +6,17 @@
 
 #include "nsProxyRelease.h"
 #include "nsThreadUtils.h"
 #include "nsAutoPtr.h"
 
 class nsProxyReleaseEvent : public nsRunnable
 {
 public:
-  nsProxyReleaseEvent(nsISupports* aDoomed) : mDoomed(aDoomed) {}
+  explicit nsProxyReleaseEvent(nsISupports* aDoomed) : mDoomed(aDoomed) {}
 
   NS_IMETHOD Run()
   {
     mDoomed->Release();
     return NS_OK;
   }
 
 private:
--- a/xpcom/glue/nsProxyRelease.h
+++ b/xpcom/glue/nsProxyRelease.h
@@ -172,26 +172,31 @@ private:
 
 template<class T>
 class nsMainThreadPtrHandle
 {
   nsRefPtr<nsMainThreadPtrHolder<T>> mPtr;
 
 public:
   nsMainThreadPtrHandle() : mPtr(nullptr) {}
-  nsMainThreadPtrHandle(nsMainThreadPtrHolder<T>* aHolder) : mPtr(aHolder) {}
+  explicit nsMainThreadPtrHandle(nsMainThreadPtrHolder<T>* aHolder) : mPtr(aHolder) {}
   nsMainThreadPtrHandle(const nsMainThreadPtrHandle& aOther)
     : mPtr(aOther.mPtr)
   {
   }
   nsMainThreadPtrHandle& operator=(const nsMainThreadPtrHandle& aOther)
   {
     mPtr = aOther.mPtr;
     return *this;
   }
+  nsMainThreadPtrHandle& operator=(nsMainThreadPtrHolder<T>* aHolder)
+  {
+    mPtr = aHolder;
+    return *this;
+  }
 
   // These all call through to nsMainThreadPtrHolder, and thus implicitly
   // assert that we're on the main thread. Off-main-thread consumers must treat
   // these handles as opaque.
   T* get()
   {
     if (mPtr) {
       return mPtr.get()->get();
--- a/xpcom/glue/nsStringAPI.h
+++ b/xpcom/glue/nsStringAPI.h
@@ -1302,17 +1302,17 @@ typedef nsDependentCString nsLiteralCStr
  *    }
  */
 
 class nsGetterCopies
 {
 public:
   typedef char16_t char_type;
 
-  nsGetterCopies(nsString& aStr)
+  explicit nsGetterCopies(nsString& aStr)
     : mString(aStr)
     , mData(nullptr)
   {
   }
 
   ~nsGetterCopies() { mString.Adopt(mData); }
 
   operator char_type**() { return &mData; }
@@ -1328,17 +1328,17 @@ getter_Copies(nsString& aString)
   return nsGetterCopies(aString);
 }
 
 class nsCGetterCopies
 {
 public:
   typedef char char_type;
 
-  nsCGetterCopies(nsCString& aStr)
+  explicit nsCGetterCopies(nsCString& aStr)
     : mString(aStr)
     , mData(nullptr)
   {
   }
 
   ~nsCGetterCopies() { mString.Adopt(mData); }
 
   operator char_type**() { return &mData; }
--- a/xpcom/glue/nsTObserverArray.h
+++ b/xpcom/glue/nsTObserverArray.h
@@ -306,17 +306,17 @@ public:
   // - removed during iteration *will not* be traversed.
   // @see EndLimitedIterator
   class ForwardIterator : protected Iterator
   {
   public:
     typedef nsAutoTObserverArray<T, N> array_type;
     typedef Iterator                   base_type;
 
-    ForwardIterator(const array_type& aArray)
+    explicit ForwardIterator(const array_type& aArray)
       : Iterator(0, aArray)
     {
     }
 
     ForwardIterator(const array_type& aArray, index_type aPos)
       : Iterator(aPos, aArray)
     {
     }
@@ -349,17 +349,17 @@ public:
   // EndLimitedIterator works like ForwardIterator, but will not iterate new
   // observers appended to the array after the iterator was created.
   class EndLimitedIterator : protected ForwardIterator
   {
   public:
     typedef nsAutoTObserverArray<T, N> array_type;
     typedef Iterator                   base_type;
 
-    EndLimitedIterator(const array_type& aArray)
+    explicit EndLimitedIterator(const array_type& aArray)
       : ForwardIterator(aArray)
       , mEnd(aArray, aArray.Length())
     {
     }
 
     // Returns true if there are more elements to iterate.
     // This must precede a call to GetNext(). If false is
     // returned, GetNext() must not be called.
@@ -386,17 +386,17 @@ public:
   // - appended during iteration *will not* be traversed
   // - removed during iteration *will not* be traversed.
   class BackwardIterator : protected Iterator
   {
   public:
     typedef nsAutoTObserverArray<T, N> array_type;
     typedef Iterator                   base_type;
 
-    BackwardIterator(const array_type& aArray)
+    explicit BackwardIterator(const array_type& aArray)
       : Iterator(aArray.Length(), aArray)
     {
     }
 
     // Returns true if there are more elements to iterate.
     // This must precede a call to GetNext(). If false is
     // returned, GetNext() must not be called.
     bool HasMore() const { return base_type::mPosition > 0; }
--- a/xpcom/glue/nsTWeakRef.h
+++ b/xpcom/glue/nsTWeakRef.h
@@ -166,17 +166,17 @@ public:
 
 private:
 
   struct Inner
   {
     int     mCnt;
     Type*   mObj;
 
-    Inner(Type* aObj)
+    explicit Inner(Type* aObj)
       : mCnt(1)
       , mObj(aObj)
     {
     }
     void AddRef()
     {
       ++mCnt;
     }
--- a/xpcom/glue/nsThreadUtils.cpp
+++ b/xpcom/glue/nsThreadUtils.cpp
@@ -269,17 +269,17 @@ NS_ProcessNextEvent(nsIThread* aThread, 
 
 namespace {
 
 class nsNameThreadRunnable MOZ_FINAL : public nsIRunnable
 {
   ~nsNameThreadRunnable() {}
 
 public:
-  nsNameThreadRunnable(const nsACString& aName) : mName(aName) {}
+  explicit nsNameThreadRunnable(const nsACString& aName) : mName(aName) {}
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIRUNNABLE
 
 protected:
   const nsCString mName;
 };
 
--- a/xpcom/glue/nsVersionComparator.h
+++ b/xpcom/glue/nsVersionComparator.h
@@ -46,17 +46,17 @@ namespace mozilla {
 int32_t NS_COM_GLUE CompareVersions(const char* aStrA, const char* aStrB);
 
 #ifdef XP_WIN
 int32_t NS_COM_GLUE CompareVersions(const char16_t* aStrA, const char16_t* aStrB);
 #endif
 
 struct NS_COM_GLUE Version
 {
-  Version(const char* aVersionString)
+  explicit Version(const char* aVersionString)
   {
     versionContent = strdup(aVersionString);
   }
 
   const char* ReadContent() const
   {
     return versionContent;
   }
@@ -85,16 +85,40 @@ struct NS_COM_GLUE Version
   bool operator==(const Version& aRhs) const
   {
     return CompareVersions(versionContent, aRhs.ReadContent()) == 0;
   }
   bool operator!=(const Version& aRhs) const
   {
     return CompareVersions(versionContent, aRhs.ReadContent()) != 0;
   }
+  bool operator<(const char* aRhs) const
+  {
+    return CompareVersions(versionContent, aRhs) == -1;
+  }
+  bool operator<=(const char* aRhs) const
+  {
+    return CompareVersions(versionContent, aRhs) < 1;
+  }
+  bool operator>(const char* aRhs) const
+  {
+    return CompareVersions(versionContent, aRhs) == 1;
+  }
+  bool operator>=(const char* aRhs) const
+  {
+    return CompareVersions(versionContent, aRhs) > -1;
+  }
+  bool operator==(const char* aRhs) const
+  {
+    return CompareVersions(versionContent, aRhs) == 0;
+  }
+  bool operator!=(const char* aRhs) const
+  {
+    return CompareVersions(versionContent, aRhs) != 0;
+  }
 
 private:
   char* versionContent;
 };
 
 #ifdef XP_WIN
 struct NS_COM_GLUE VersionW
 {
--- a/xpcom/glue/nsVoidArray.h
+++ b/xpcom/glue/nsVoidArray.h
@@ -25,17 +25,17 @@ typedef bool (*nsVoidArrayEnumFuncConst)
 typedef size_t (*nsVoidArraySizeOfElementIncludingThisFunc)(
   const void* aElement, mozilla::MallocSizeOf aMallocSizeOf, void* aData);
 
 /// A basic zero-based array of void*'s that manages its own memory
 class NS_COM_GLUE nsVoidArray
 {
 public:
   nsVoidArray();
-  nsVoidArray(int32_t aCount);  // initial count of aCount elements set to nullptr
+  explicit nsVoidArray(int32_t aCount);  // initial count of aCount elements set to nullptr
   ~nsVoidArray();
 
   nsVoidArray& operator=(const nsVoidArray& aOther);
 
   inline int32_t Count() const { return mImpl ? mImpl->mCount : 0; }
   // If the array grows, the newly created entries will all be null
   bool SetCount(int32_t aNewCount);
   // returns the max number that can be held without allocating
--- a/xpcom/glue/nsWeakReference.cpp
+++ b/xpcom/glue/nsWeakReference.cpp
@@ -19,17 +19,17 @@ public:
 
   // nsIWeakReference...
   NS_DECL_NSIWEAKREFERENCE
   virtual size_t SizeOfOnlyThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
 private:
   friend class nsSupportsWeakReference;
 
-  nsWeakReference(nsSupportsWeakReference* aReferent)
+  explicit nsWeakReference(nsSupportsWeakReference* aReferent)
     : mReferent(aReferent)
     // ...I can only be constructed by an |nsSupportsWeakReference|
   {
   }
 
   ~nsWeakReference()
   // ...I will only be destroyed by calling |delete| myself.
   {
--- a/xpcom/reflect/xptinfo/xptinfo.h
+++ b/xpcom/reflect/xptinfo/xptinfo.h
@@ -18,20 +18,20 @@ class nsIInterfaceInfoManager;
 // xpcom/typelib/xpt/xpt_struct.h!
 
 class nsXPTType : public XPTTypeDescriptorPrefix
 {
 // NO DATA - this a flyweight wrapper
 public:
     nsXPTType()
         {}    // random contents
-    nsXPTType(const XPTTypeDescriptorPrefix& prefix)
+    MOZ_IMPLICIT nsXPTType(const XPTTypeDescriptorPrefix& prefix)
         {*(XPTTypeDescriptorPrefix*)this = prefix;}
 
-    nsXPTType(const uint8_t& prefix)
+    MOZ_IMPLICIT nsXPTType(const uint8_t& prefix)
         {*(uint8_t*)this = prefix;}
 
     nsXPTType& operator=(uint8_t val)
         {flags = val; return *this;}
 
     nsXPTType& operator=(const nsXPTType& other)
         {flags = other.flags; return *this;}
 
@@ -119,17 +119,17 @@ public:
     };
 // NO DATA - this a flyweight wrapper
 };
 
 class nsXPTParamInfo : public XPTParamDescriptor
 {
 // NO DATA - this a flyweight wrapper
 public:
-    nsXPTParamInfo(const XPTParamDescriptor& desc)
+    MOZ_IMPLICIT nsXPTParamInfo(const XPTParamDescriptor& desc)
         {*(XPTParamDescriptor*)this = desc;}
 
 
     bool IsIn()  const    {return 0 != (XPT_PD_IS_IN(flags));}
     bool IsOut() const    {return 0 != (XPT_PD_IS_OUT(flags));}
     bool IsRetval() const {return 0 != (XPT_PD_IS_RETVAL(flags));}
     bool IsShared() const {return 0 != (XPT_PD_IS_SHARED(flags));}
 
@@ -178,17 +178,17 @@ private:
     nsXPTParamInfo();   // no implementation
 // NO DATA - this a flyweight wrapper
 };
 
 class nsXPTMethodInfo : public XPTMethodDescriptor
 {
 // NO DATA - this a flyweight wrapper
 public:
-    nsXPTMethodInfo(const XPTMethodDescriptor& desc)
+    MOZ_IMPLICIT nsXPTMethodInfo(const XPTMethodDescriptor& desc)
         {*(XPTMethodDescriptor*)this = desc;}
 
     bool IsGetter()      const {return 0 != (XPT_MD_IS_GETTER(flags) );}
     bool IsSetter()      const {return 0 != (XPT_MD_IS_SETTER(flags) );}
     bool IsNotXPCOM()    const {return 0 != (XPT_MD_IS_NOTXPCOM(flags));}
     bool IsConstructor() const {return 0 != (XPT_MD_IS_CTOR(flags)   );}
     bool IsHidden()      const {return 0 != (XPT_MD_IS_HIDDEN(flags) );}
     bool WantsOptArgc()  const {return 0 != (XPT_MD_WANTS_OPT_ARGC(flags));}
@@ -211,17 +211,17 @@ private:
 
 // forward declaration
 struct nsXPTCMiniVariant;
 
 class nsXPTConstant : public XPTConstDescriptor
 {
 // NO DATA - this a flyweight wrapper
 public:
-    nsXPTConstant(const XPTConstDescriptor& desc)
+    MOZ_IMPLICIT nsXPTConstant(const XPTConstDescriptor& desc)
         {*(XPTConstDescriptor*)this = desc;}
 
     const char* GetName() const
         {return name;}
 
     const nsXPTType GetType() const
         {return type.prefix;}