Bug 1048280 - Fix more bad implicit constructors in XPCOM; r=froydnj
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 05 Aug 2014 09:36:59 -0400
changeset 197940 64249d8c98148a2bc993e2c9fd1a160582b0a7ad
parent 197939 b81d755b1b376ea2b23b38fd0de5ac1d92c31239
child 197941 3d47686129ae90bde3b655f042be3d6e1be84cc2
push id27256
push userkwierso@gmail.com
push dateWed, 06 Aug 2014 00:06:20 +0000
treeherdermozilla-central@6cbdd4d523a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1048280
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 1048280 - Fix more bad implicit constructors in XPCOM; r=froydnj
xpcom/build/IOInterposer.cpp
xpcom/build/IOInterposerPrivate.h
xpcom/build/LateWriteChecks.cpp
xpcom/build/NSPRInterposer.cpp
xpcom/io/nsPipe3.cpp
xpcom/io/nsUnicharInputStream.cpp
xpcom/tests/TestCOMArray.cpp
xpcom/tests/TestHarness.h
xpcom/tests/TestHashtables.cpp
xpcom/tests/TestObserverService.cpp
xpcom/tests/TestRacingServiceManager.cpp
xpcom/tests/TestThreadPoolListener.cpp
xpcom/threads/TimerThread.cpp
xpcom/threads/nsThread.cpp
--- a/xpcom/build/IOInterposer.cpp
+++ b/xpcom/build/IOInterposer.cpp
@@ -74,17 +74,17 @@ public:
   std::vector<IOInterposeObserver*>  mStatObservers;
   std::vector<IOInterposeObserver*>  mCloseObservers;
   std::vector<IOInterposeObserver*>  mStageObservers;
 };
 
 class PerThreadData
 {
 public:
-  PerThreadData(bool aIsMainThread = false)
+  explicit PerThreadData(bool aIsMainThread = false)
     : mIsMainThread(aIsMainThread)
     , mIsHandlingObservation(false)
     , mCurrentGeneration(0)
   {
     MOZ_COUNT_CTOR(PerThreadData);
   }
 
   ~PerThreadData()
--- a/xpcom/build/IOInterposerPrivate.h
+++ b/xpcom/build/IOInterposerPrivate.h
@@ -66,17 +66,17 @@ public:
 private:
   PRLock*    mLock;
   PRCondVar* mCondVar;
 };
 
 class MonitorAutoLock
 {
 public:
-  MonitorAutoLock(Monitor &aMonitor)
+  explicit MonitorAutoLock(Monitor &aMonitor)
     : mMonitor(aMonitor)
   {
     mMonitor.Lock();
   }
 
   ~MonitorAutoLock()
   {
     mMonitor.Unlock();
@@ -94,17 +94,17 @@ public:
 
 private:
   Monitor&  mMonitor;
 };
 
 class MonitorAutoUnlock
 {
 public:
-  MonitorAutoUnlock(Monitor &aMonitor)
+  explicit MonitorAutoUnlock(Monitor &aMonitor)
     : mMonitor(aMonitor)
   {
     mMonitor.Unlock();
   }
 
   ~MonitorAutoUnlock()
   {
     mMonitor.Lock();
@@ -140,17 +140,17 @@ public:
 
 private:
   PRLock*   mPRLock;
 };
 
 class AutoLock
 {
 public:
-  AutoLock(Mutex& aLock)
+  explicit AutoLock(Mutex& aLock)
     : mLock(aLock)
   {
     mLock.Lock();
   }
 
   ~AutoLock()
   {
     mLock.Unlock();
--- a/xpcom/build/LateWriteChecks.cpp
+++ b/xpcom/build/LateWriteChecks.cpp
@@ -89,17 +89,17 @@ static void RecordStackWalker(void *aPC,
 
 /**
  * An implementation of IOInterposeObserver to be registered with IOInterposer.
  * This observer logs all writes as late writes.
  */
 class LateWriteObserver MOZ_FINAL : public IOInterposeObserver
 {
 public:
-  LateWriteObserver(const char* aProfileDirectory)
+  explicit LateWriteObserver(const char* aProfileDirectory)
     : mProfileDirectory(PL_strdup(aProfileDirectory))
   {
   }
   ~LateWriteObserver() {
     PL_strfree(mProfileDirectory);
     mProfileDirectory = nullptr;
   }
 
--- a/xpcom/build/NSPRInterposer.cpp
+++ b/xpcom/build/NSPRInterposer.cpp
@@ -22,17 +22,17 @@ PRFileInfo64FN sFileInfo64Fn = nullptr;
 
 /**
  * RAII class for timing the duration of an NSPR I/O call and reporting the
  * result to the IOInterposeObserver API.
  */
 class NSPRIOAutoObservation : public IOInterposeObserver::Observation
 {
 public:
-  NSPRIOAutoObservation(IOInterposeObserver::Operation aOp)
+  explicit NSPRIOAutoObservation(IOInterposeObserver::Operation aOp)
     : IOInterposeObserver::Observation(aOp, "NSPRIOInterposer")
   {
   }
 
   ~NSPRIOAutoObservation()
   {
     Report();
   }
--- a/xpcom/io/nsPipe3.cpp
+++ b/xpcom/io/nsPipe3.cpp
@@ -104,17 +104,17 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIINPUTSTREAM
   NS_DECL_NSIASYNCINPUTSTREAM
   NS_DECL_NSISEEKABLESTREAM
   NS_DECL_NSISEARCHABLEINPUTSTREAM
   NS_DECL_NSICLASSINFO
 
-  nsPipeInputStream(nsPipe* aPipe)
+  explicit nsPipeInputStream(nsPipe* aPipe)
     : mPipe(aPipe)
     , mReaderRefCnt(0)
     , mLogicalOffset(0)
     , mBlocking(true)
     , mBlocked(false)
     , mAvailable(0)
     , mCallbackFlags(0)
   { }
@@ -171,17 +171,17 @@ public:
   // declare a mRefCount variable; however, don't let the name fool you...
   // we are not inheriting from nsPipe ;-)
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIOUTPUTSTREAM
   NS_DECL_NSIASYNCOUTPUTSTREAM
   NS_DECL_NSICLASSINFO
 
-  nsPipeOutputStream(nsPipe* aPipe)
+  explicit nsPipeOutputStream(nsPipe* aPipe)
     : mPipe(aPipe)
     , mWriterRefCnt(0)
     , mLogicalOffset(0)
     , mBlocking(true)
     , mBlocked(false)
     , mWritable(true)
     , mCallbackFlags(0)
   { }
--- a/xpcom/io/nsUnicharInputStream.cpp
+++ b/xpcom/io/nsUnicharInputStream.cpp
@@ -21,17 +21,17 @@
 #include <unistd.h>
 #endif
 
 #define STRING_BUFFER_SIZE 8192
 
 class StringUnicharInputStream MOZ_FINAL : public nsIUnicharInputStream
 {
 public:
-  StringUnicharInputStream(const nsAString& aString) :
+  explicit StringUnicharInputStream(const nsAString& aString) :
     mString(aString), mPos(0), mLen(aString.Length()) { }
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIUNICHARINPUTSTREAM
 
   nsString mString;
   uint32_t mPos;
   uint32_t mLen;
--- a/xpcom/tests/TestCOMArray.cpp
+++ b/xpcom/tests/TestCOMArray.cpp
@@ -24,17 +24,17 @@ public:
 
 NS_DEFINE_STATIC_IID_ACCESSOR(IFoo, NS_IFOO_IID)
 
 class Foo MOZ_FINAL : public IFoo {
   ~Foo();
 
 public:
 
-  Foo(int32_t aID);
+  explicit Foo(int32_t aID);
 
   // nsISupports implementation
   NS_DECL_ISUPPORTS
 
   // IFoo implementation
   NS_IMETHOD_(MozExternalRefCountType) RefCnt() { return mRefCnt; }
   NS_IMETHOD_(int32_t) ID() { return mID; }
 
--- a/xpcom/tests/TestHarness.h
+++ b/xpcom/tests/TestHarness.h
@@ -95,18 +95,18 @@ public:
     }
 };
 
 class ScopedXPCOM : public nsIDirectoryServiceProvider2
 {
   public:
     NS_DECL_ISUPPORTS
 
-    ScopedXPCOM(const char* testName,
-                nsIDirectoryServiceProvider *dirSvcProvider = nullptr)
+    explicit ScopedXPCOM(const char* testName,
+                         nsIDirectoryServiceProvider *dirSvcProvider = nullptr)
     : mDirSvcProvider(dirSvcProvider)
     {
       mTestName = testName;
       printf("Running %s tests...\n", mTestName);
 
       nsresult rv = NS_InitXPCOM2(&mServMgr, nullptr, this);
       if (NS_FAILED(rv))
       {
--- a/xpcom/tests/TestHashtables.cpp
+++ b/xpcom/tests/TestHashtables.cpp
@@ -16,17 +16,17 @@
 
 #include <stdio.h>
 
 namespace TestHashtables {
 
 class TestUniChar // for nsClassHashtable
 {
 public:
-  TestUniChar(uint32_t aWord)
+  explicit TestUniChar(uint32_t aWord)
   {
     printf("    TestUniChar::TestUniChar() %u\n", aWord);
     mWord = aWord;
   }
 
   ~TestUniChar()
   {
     printf("    TestUniChar::~TestUniChar() %u\n", mWord);
@@ -65,17 +65,17 @@ EntityNode gEntities[] = {
 #define ENTITY_COUNT (unsigned(sizeof(gEntities)/sizeof(EntityNode)))
 
 class EntityToUnicodeEntry : public PLDHashEntryHdr
 {
 public:
   typedef const char* KeyType;
   typedef const char* KeyTypePointer;
 
-  EntityToUnicodeEntry(const char* aKey) { mNode = nullptr; }
+  explicit EntityToUnicodeEntry(const char* aKey) { mNode = nullptr; }
   EntityToUnicodeEntry(const EntityToUnicodeEntry& aEntry) { mNode = aEntry.mNode; }
   ~EntityToUnicodeEntry() { }
 
   bool KeyEquals(const char* aEntity) const { return !strcmp(mNode->mStr, aEntity); }
   static const char* KeyToPointer(const char* aEntity) { return aEntity; }
   static PLDHashNumber HashKey(const char* aEntity) { return mozilla::HashString(aEntity); }
   enum { ALLOW_MEMMOVE = true };
 
--- a/xpcom/tests/TestObserverService.cpp
+++ b/xpcom/tests/TestObserverService.cpp
@@ -29,17 +29,17 @@ static void testResult( nsresult rv ) {
 void printString(nsString &str) {
     printf("%s", NS_ConvertUTF16toUTF8(str).get());
 }
 
 class TestObserver MOZ_FINAL : public nsIObserver,
                                public nsSupportsWeakReference
 {
 public:
-    TestObserver( const nsAString &name )
+    explicit TestObserver( const nsAString &name )
         : mName( name ) {
     }
     NS_DECL_ISUPPORTS
     NS_DECL_NSIOBSERVER
 
     nsString mName;
 
 private:
--- a/xpcom/tests/TestRacingServiceManager.cpp
+++ b/xpcom/tests/TestRacingServiceManager.cpp
@@ -62,17 +62,17 @@ int32_t gComponent2Count = 0;
 ReentrantMonitor* gReentrantMonitor = nullptr;
 
 bool gCreateInstanceCalled = false;
 bool gMainThreadWaiting = false;
 
 class AutoCreateAndDestroyReentrantMonitor
 {
 public:
-  AutoCreateAndDestroyReentrantMonitor(ReentrantMonitor** aReentrantMonitorPtr)
+  explicit AutoCreateAndDestroyReentrantMonitor(ReentrantMonitor** aReentrantMonitorPtr)
   : mReentrantMonitorPtr(aReentrantMonitorPtr) {
     *aReentrantMonitorPtr =
       new ReentrantMonitor("TestRacingServiceManager::AutoMon");
     TEST_ASSERTION(*aReentrantMonitorPtr, "Out of memory!");
   }
 
   ~AutoCreateAndDestroyReentrantMonitor() {
     if (*mReentrantMonitorPtr) {
--- a/xpcom/tests/TestThreadPoolListener.cpp
+++ b/xpcom/tests/TestThreadPoolListener.cpp
@@ -110,17 +110,17 @@ Listener::OnThreadShuttingDown()
 
   TEST_ASSERTION(false, "Too many threads!");
   return NS_ERROR_FAILURE;
 }
 
 class AutoCreateAndDestroyReentrantMonitor
 {
 public:
-  AutoCreateAndDestroyReentrantMonitor(ReentrantMonitor** aReentrantMonitorPtr)
+  explicit AutoCreateAndDestroyReentrantMonitor(ReentrantMonitor** aReentrantMonitorPtr)
   : mReentrantMonitorPtr(aReentrantMonitorPtr) {
     *aReentrantMonitorPtr = new ReentrantMonitor("TestThreadPoolListener::AutoMon");
     TEST_ASSERTION(*aReentrantMonitorPtr, "Out of memory!");
   }
 
   ~AutoCreateAndDestroyReentrantMonitor() {
     if (*mReentrantMonitorPtr) {
       delete *mReentrantMonitorPtr;
--- a/xpcom/threads/TimerThread.cpp
+++ b/xpcom/threads/TimerThread.cpp
@@ -46,17 +46,17 @@ TimerThread::InitLocks()
   return NS_OK;
 }
 
 namespace {
 
 class TimerObserverRunnable : public nsRunnable
 {
 public:
-  TimerObserverRunnable(nsIObserver* aObserver)
+  explicit TimerObserverRunnable(nsIObserver* aObserver)
     : mObserver(aObserver)
   {
   }
 
   NS_DECL_NSIRUNNABLE
 
 private:
   nsCOMPtr<nsIObserver> mObserver;
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -238,17 +238,17 @@ struct nsThreadShutdownContext
   bool      shutdownAck;
 };
 
 // This event is responsible for notifying nsThread::Shutdown that it is time
 // to call PR_JoinThread.
 class nsThreadShutdownAckEvent : public nsRunnable
 {
 public:
-  nsThreadShutdownAckEvent(nsThreadShutdownContext* aCtx)
+  explicit nsThreadShutdownAckEvent(nsThreadShutdownContext* aCtx)
     : mShutdownContext(aCtx)
   {
   }
   NS_IMETHOD Run()
   {
     mShutdownContext->shutdownAck = true;
     return NS_OK;
   }