bug 1301157 - remove nsPSMBackgroundThread (dead code) r=jcj
authorDavid Keeler <dkeeler@mozilla.com>
Wed, 07 Sep 2016 12:43:27 -0700
changeset 313089 bc76c6abe3dfb20b2cc566706441e6d8e56499f7
parent 313088 55ad430c18f011d7d8612e44f2955631b6e1cc3c
child 313090 9377cc9dc164dcadcd76c881484617310a461161
push id30671
push usercbook@mozilla.com
push dateThu, 08 Sep 2016 09:59:51 +0000
treeherdermozilla-central@bd28be90aed8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjcj
bugs1301157, 1284946
milestone51.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 1301157 - remove nsPSMBackgroundThread (dead code) r=jcj As of bug 1284946, nothing uses nsPSMBackgroundThread, so it's just dead code that is removed by this patch. MozReview-Commit-ID: 24HWFHIeCX9
security/manager/ssl/moz.build
security/manager/ssl/nsPSMBackgroundThread.cpp
security/manager/ssl/nsPSMBackgroundThread.h
--- a/security/manager/ssl/moz.build
+++ b/security/manager/ssl/moz.build
@@ -117,17 +117,16 @@ UNIFIED_SOURCES += [
     'nsNSSShutDown.cpp',
     'nsNSSU2FToken.cpp',
     'nsNSSVersion.cpp',
     'nsNTLMAuthModule.cpp',
     'nsPK11TokenDB.cpp',
     'nsPKCS11Slot.cpp',
     'nsPKCS12Blob.cpp',
     'nsProtectedAuthThread.cpp',
-    'nsPSMBackgroundThread.cpp',
     'nsRandomGenerator.cpp',
     'nsSecureBrowserUIImpl.cpp',
     'nsSecurityHeaderParser.cpp',
     'NSSErrorsService.cpp',
     'nsSiteSecurityService.cpp',
     'nsSSLSocketProvider.cpp',
     'nsSSLStatus.cpp',
     'nsTLSSocketProvider.cpp',
deleted file mode 100644
--- a/security/manager/ssl/nsPSMBackgroundThread.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsPSMBackgroundThread.h"
-#include "nsThreadUtils.h"
-
-using namespace mozilla;
-
-void nsPSMBackgroundThread::nsThreadRunner(void *arg)
-{
-  nsPSMBackgroundThread *self = static_cast<nsPSMBackgroundThread *>(arg);
-  PR_SetCurrentThreadName(self->mName.BeginReading());
-  self->Run();
-}
-
-nsPSMBackgroundThread::nsPSMBackgroundThread()
-: mThreadHandle(nullptr),
-  mMutex("nsPSMBackgroundThread.mMutex"),
-  mCond(mMutex, "nsPSMBackgroundThread.mCond"),
-  mExitState(ePSMThreadRunning)
-{
-}
-
-nsresult nsPSMBackgroundThread::startThread(const nsCSubstring & name)
-{
-  mName = name;
-
-  mThreadHandle = PR_CreateThread(PR_USER_THREAD, nsThreadRunner, static_cast<void*>(this), 
-    PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
-
-  NS_ASSERTION(mThreadHandle, "Could not create nsPSMBackgroundThread\n");
-  
-  if (!mThreadHandle)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  return NS_OK;
-}
-
-nsPSMBackgroundThread::~nsPSMBackgroundThread()
-{
-}
-
-bool
-nsPSMBackgroundThread::exitRequested(const MutexAutoLock & /*proofOfLock*/) const
-{
-  return exitRequestedNoLock();
-}
-
-nsresult
-nsPSMBackgroundThread::postStoppedEventToMainThread(
-    MutexAutoLock const & /*proofOfLock*/)
-{
-  NS_ASSERTION(PR_GetCurrentThread() == mThreadHandle,
-               "Background thread stopped from another thread");
-
-  mExitState = ePSMThreadStopped;
-  // requestExit is waiting for an event, so give it one.
-  return NS_DispatchToMainThread(new Runnable());
-}
-
-void nsPSMBackgroundThread::requestExit()
-{
-  NS_ASSERTION(NS_IsMainThread(),
-               "nsPSMBackgroundThread::requestExit called off main thread.");
-
-  if (!mThreadHandle)
-    return;
-
-  {
-    MutexAutoLock threadLock(mMutex);
-    if (mExitState < ePSMThreadStopRequested) {
-      mExitState = ePSMThreadStopRequested;
-      mCond.NotifyAll();
-    }
-  }
-  
-  nsCOMPtr<nsIThread> mainThread = do_GetCurrentThread();
-  for (;;) {
-    {
-      MutexAutoLock threadLock(mMutex);
-      if (mExitState == ePSMThreadStopped)
-        break;
-    }
-    NS_ProcessPendingEvents(mainThread, PR_MillisecondsToInterval(50));
-  }
-
-  PR_JoinThread(mThreadHandle);
-  mThreadHandle = nullptr;
-}
deleted file mode 100644
--- a/security/manager/ssl/nsPSMBackgroundThread.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef _NSPSMBACKGROUNDTHREAD_H_
-#define _NSPSMBACKGROUNDTHREAD_H_
-
-#include "nspr.h"
-#include "nscore.h"
-#include "mozilla/CondVar.h"
-#include "mozilla/Mutex.h"
-#include "nsNSSComponent.h"
-
-class nsPSMBackgroundThread
-{
-protected:
-  static void nsThreadRunner(void *arg);
-  virtual void Run(void) = 0;
-
-  // used to join the thread
-  PRThread *mThreadHandle;
-
-  // Shared mutex used for condition variables,
-  // and to protect access to mExitState.
-  // Derived classes may use it to protect additional
-  // resources.
-  mozilla::Mutex mMutex;
-
-  // Used to signal the thread's Run loop when a job is added 
-  // and/or exit is requested.
-  mozilla::CondVar mCond;
-
-  bool exitRequested(::mozilla::MutexAutoLock const & proofOfLock) const;
-  bool exitRequestedNoLock() const { return mExitState != ePSMThreadRunning; }
-  nsresult postStoppedEventToMainThread(::mozilla::MutexAutoLock const & proofOfLock);
-
-private:
-  enum {
-    ePSMThreadRunning = 0,
-    ePSMThreadStopRequested = 1,
-    ePSMThreadStopped = 2
-  } mExitState;
-
-  // The thread's name.
-  nsCString mName;
-
-public:
-  nsPSMBackgroundThread();
-  virtual ~nsPSMBackgroundThread();
-
-  nsresult startThread(const nsCSubstring & name);
-  void requestExit();
-};
-
-
-#endif