2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-17 19:47:45 -08:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-01-10 00:39:40 -08:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2011-12-17 19:47:45 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsExceptionService.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2013-07-11 13:21:45 -07:00
|
|
|
#include "pratom.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "prthread.h"
|
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
2010-04-29 09:59:13 -07:00
|
|
|
#include "mozilla/Services.h"
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static const unsigned BAD_TLS_INDEX = (unsigned) -1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
#define CHECK_SERVICE_USE_OK() if (!sLock) return NS_ERROR_NOT_INITIALIZED
|
|
|
|
#define CHECK_MANAGER_USE_OK() if (!mService || !nsExceptionService::sLock) return NS_ERROR_NOT_INITIALIZED
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// A key for our registered module providers hashtable
|
|
|
|
class nsProviderKey : public nsHashKey {
|
|
|
|
protected:
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mKey;
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsProviderKey(uint32_t key) : mKey(key) {}
|
|
|
|
uint32_t HashCode(void) const {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mKey;
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
bool Equals(const nsHashKey *aKey) const {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mKey == ((const nsProviderKey *) aKey)->mKey;
|
|
|
|
}
|
|
|
|
nsHashKey *Clone() const {
|
|
|
|
return new nsProviderKey(mKey);
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetValue() { return mKey; }
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Exception Manager definition **/
|
2011-12-17 19:47:45 -08:00
|
|
|
class nsExceptionManager MOZ_FINAL : public nsIExceptionManager
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 19:31:26 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIEXCEPTIONMANAGER
|
|
|
|
|
|
|
|
nsExceptionManager(nsExceptionService *svc);
|
|
|
|
/* additional members */
|
|
|
|
nsCOMPtr<nsIException> mCurrentException;
|
|
|
|
nsExceptionManager *mNextThread; // not ref-counted.
|
|
|
|
nsExceptionService *mService; // not ref-counted
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t totalInstances;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
|
|
|
~nsExceptionManager();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t nsExceptionManager::totalInstances = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Note this object is single threaded - the service itself ensures
|
|
|
|
// one per thread.
|
|
|
|
// An exception if the destructor, which may be called on
|
|
|
|
// the thread shutting down xpcom
|
2013-07-18 19:31:26 -07:00
|
|
|
NS_IMPL_ISUPPORTS1(nsExceptionManager, nsIExceptionManager)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsExceptionManager::nsExceptionManager(nsExceptionService *svc) :
|
2012-07-30 07:20:58 -07:00
|
|
|
mNextThread(nullptr),
|
2007-03-22 10:30:00 -07:00
|
|
|
mService(svc)
|
|
|
|
{
|
|
|
|
/* member initializers and constructor code */
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2011-03-28 12:58:49 -07:00
|
|
|
PR_ATOMIC_INCREMENT(&totalInstances);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nsExceptionManager::~nsExceptionManager()
|
|
|
|
{
|
|
|
|
/* destructor code */
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2011-03-28 12:58:49 -07:00
|
|
|
PR_ATOMIC_DECREMENT(&totalInstances);
|
2012-06-25 12:59:42 -07:00
|
|
|
#endif // DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* void setCurrentException (in nsIException error); */
|
|
|
|
NS_IMETHODIMP nsExceptionManager::SetCurrentException(nsIException *error)
|
|
|
|
{
|
|
|
|
CHECK_MANAGER_USE_OK();
|
|
|
|
mCurrentException = error;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* nsIException getCurrentException (); */
|
|
|
|
NS_IMETHODIMP nsExceptionManager::GetCurrentException(nsIException **_retval)
|
|
|
|
{
|
|
|
|
CHECK_MANAGER_USE_OK();
|
|
|
|
*_retval = mCurrentException;
|
|
|
|
NS_IF_ADDREF(*_retval);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* nsIException getExceptionFromProvider( in nsresult rc, in nsIException defaultException); */
|
|
|
|
NS_IMETHODIMP nsExceptionManager::GetExceptionFromProvider(nsresult rc, nsIException * defaultException, nsIException **_retval)
|
|
|
|
{
|
|
|
|
CHECK_MANAGER_USE_OK();
|
|
|
|
// Just delegate back to the service with the provider map.
|
|
|
|
return mService->GetExceptionFromProvider(rc, defaultException, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The Exception Service */
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
unsigned nsExceptionService::tlsIndex = BAD_TLS_INDEX;
|
2012-07-30 07:20:58 -07:00
|
|
|
Mutex *nsExceptionService::sLock = nullptr;
|
|
|
|
nsExceptionManager *nsExceptionService::firstThread = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t nsExceptionService::totalInstances = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2013-07-18 19:31:26 -07:00
|
|
|
NS_IMPL_ISUPPORTS3(nsExceptionService,
|
|
|
|
nsIExceptionService,
|
|
|
|
nsIExceptionManager,
|
|
|
|
nsIObserver)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsExceptionService::nsExceptionService()
|
2011-10-17 07:59:28 -07:00
|
|
|
: mProviders(4, true) /* small, thread-safe hashtable */
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2011-03-28 12:58:49 -07:00
|
|
|
if (PR_ATOMIC_INCREMENT(&totalInstances)!=1) {
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ERROR("The nsExceptionService is a singleton!");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* member initializers and constructor code */
|
|
|
|
if (tlsIndex == BAD_TLS_INDEX) {
|
2013-01-10 00:39:40 -08:00
|
|
|
DebugOnly<PRStatus> status;
|
2007-03-22 10:30:00 -07:00
|
|
|
status = PR_NewThreadPrivateIndex( &tlsIndex, ThreadDestruct );
|
|
|
|
NS_ASSERTION(status==0, "ScriptErrorService could not allocate TLS storage.");
|
|
|
|
}
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
sLock = new Mutex("nsExceptionService.sLock");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// observe XPCOM shutdown.
|
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
2010-04-29 09:59:13 -07:00
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
mozilla::services::GetObserverService();
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(observerService, "Could not get observer service!");
|
|
|
|
if (observerService)
|
2011-10-17 07:59:28 -07:00
|
|
|
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsExceptionService::~nsExceptionService()
|
|
|
|
{
|
|
|
|
Shutdown();
|
|
|
|
/* destructor code */
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2011-03-28 12:58:49 -07:00
|
|
|
PR_ATOMIC_DECREMENT(&totalInstances);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/
|
|
|
|
void nsExceptionService::ThreadDestruct( void *data )
|
|
|
|
{
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
if (!sLock) {
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_WARNING("nsExceptionService ignoring thread destruction after shutdown");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DropThread( (nsExceptionManager *)data );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nsExceptionService::Shutdown()
|
|
|
|
{
|
|
|
|
mProviders.Reset();
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
if (sLock) {
|
2007-03-22 10:30:00 -07:00
|
|
|
DropAllThreads();
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
delete sLock;
|
2012-07-30 07:20:58 -07:00
|
|
|
sLock = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
PR_SetThreadPrivate(tlsIndex, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* void setCurrentException (in nsIException error); */
|
|
|
|
NS_IMETHODIMP nsExceptionService::SetCurrentException(nsIException *error)
|
|
|
|
{
|
|
|
|
CHECK_SERVICE_USE_OK();
|
|
|
|
nsCOMPtr<nsIExceptionManager> sm;
|
|
|
|
nsresult nr = GetCurrentExceptionManager(getter_AddRefs(sm));
|
|
|
|
if (NS_FAILED(nr))
|
|
|
|
return nr;
|
|
|
|
return sm->SetCurrentException(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* nsIException getCurrentException (); */
|
|
|
|
NS_IMETHODIMP nsExceptionService::GetCurrentException(nsIException **_retval)
|
|
|
|
{
|
|
|
|
CHECK_SERVICE_USE_OK();
|
|
|
|
nsCOMPtr<nsIExceptionManager> sm;
|
|
|
|
nsresult nr = GetCurrentExceptionManager(getter_AddRefs(sm));
|
|
|
|
if (NS_FAILED(nr))
|
|
|
|
return nr;
|
|
|
|
return sm->GetCurrentException(_retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* nsIException getExceptionFromProvider( in nsresult rc, in nsIException defaultException); */
|
|
|
|
NS_IMETHODIMP nsExceptionService::GetExceptionFromProvider(nsresult rc,
|
|
|
|
nsIException * defaultException, nsIException **_retval)
|
|
|
|
{
|
|
|
|
CHECK_SERVICE_USE_OK();
|
|
|
|
return DoGetExceptionFromProvider(rc, defaultException, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute nsIExceptionManager currentExceptionManager; */
|
|
|
|
NS_IMETHODIMP nsExceptionService::GetCurrentExceptionManager(nsIExceptionManager * *aCurrentScriptManager)
|
|
|
|
{
|
|
|
|
CHECK_SERVICE_USE_OK();
|
|
|
|
nsExceptionManager *mgr = (nsExceptionManager *)PR_GetThreadPrivate(tlsIndex);
|
2012-07-30 07:20:58 -07:00
|
|
|
if (mgr == nullptr) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Stick the new exception object in with no reference count.
|
|
|
|
mgr = new nsExceptionManager(this);
|
|
|
|
PR_SetThreadPrivate(tlsIndex, mgr);
|
|
|
|
// The reference count is held in the thread-list
|
|
|
|
AddThread(mgr);
|
|
|
|
}
|
|
|
|
*aCurrentScriptManager = mgr;
|
|
|
|
NS_ADDREF(*aCurrentScriptManager);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
/* void registerErrorProvider (in nsIExceptionProvider provider, in uint32_t moduleCode); */
|
|
|
|
NS_IMETHODIMP nsExceptionService::RegisterExceptionProvider(nsIExceptionProvider *provider, uint32_t errorModule)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
CHECK_SERVICE_USE_OK();
|
|
|
|
|
|
|
|
nsProviderKey key(errorModule);
|
|
|
|
if (mProviders.Put(&key, provider)) {
|
|
|
|
NS_WARNING("Registration of exception provider overwrote another provider with the same module code!");
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
/* void unregisterErrorProvider (in nsIExceptionProvider provider, in uint32_t errorModule); */
|
|
|
|
NS_IMETHODIMP nsExceptionService::UnregisterExceptionProvider(nsIExceptionProvider *provider, uint32_t errorModule)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
CHECK_SERVICE_USE_OK();
|
|
|
|
nsProviderKey key(errorModule);
|
|
|
|
if (!mProviders.Remove(&key)) {
|
|
|
|
NS_WARNING("Attempt to unregister an unregistered exception provider!");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIObserver
|
|
|
|
NS_IMETHODIMP nsExceptionService::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
|
|
|
|
{
|
|
|
|
Shutdown();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsExceptionService::DoGetExceptionFromProvider(nsresult errCode,
|
|
|
|
nsIException * defaultException,
|
|
|
|
nsIException **_exc)
|
|
|
|
{
|
|
|
|
// Check for an existing exception
|
|
|
|
nsresult nr = GetCurrentException(_exc);
|
|
|
|
if (NS_SUCCEEDED(nr) && *_exc) {
|
|
|
|
(*_exc)->GetResult(&nr);
|
|
|
|
// If it matches our result then use it
|
|
|
|
if (nr == errCode)
|
|
|
|
return NS_OK;
|
|
|
|
NS_RELEASE(*_exc);
|
|
|
|
}
|
|
|
|
nsProviderKey key(NS_ERROR_GET_MODULE(errCode));
|
|
|
|
nsCOMPtr<nsIExceptionProvider> provider =
|
|
|
|
dont_AddRef((nsIExceptionProvider *)mProviders.Get(&key));
|
|
|
|
|
|
|
|
// No provider so we'll return the default exception
|
|
|
|
if (!provider) {
|
|
|
|
*_exc = defaultException;
|
|
|
|
NS_IF_ADDREF(*_exc);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return provider->GetException(errCode, defaultException, _exc);
|
|
|
|
}
|
|
|
|
|
|
|
|
// thread management
|
|
|
|
/*static*/ void nsExceptionService::AddThread(nsExceptionManager *thread)
|
|
|
|
{
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
MutexAutoLock lock(*sLock);
|
2007-03-22 10:30:00 -07:00
|
|
|
thread->mNextThread = firstThread;
|
|
|
|
firstThread = thread;
|
|
|
|
NS_ADDREF(thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void nsExceptionService::DoDropThread(nsExceptionManager *thread)
|
|
|
|
{
|
|
|
|
nsExceptionManager **emp = &firstThread;
|
|
|
|
while (*emp != thread) {
|
|
|
|
NS_ABORT_IF_FALSE(*emp, "Could not find the thread to drop!");
|
|
|
|
emp = &(*emp)->mNextThread;
|
|
|
|
}
|
|
|
|
*emp = thread->mNextThread;
|
|
|
|
NS_RELEASE(thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void nsExceptionService::DropThread(nsExceptionManager *thread)
|
|
|
|
{
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
MutexAutoLock lock(*sLock);
|
2007-03-22 10:30:00 -07:00
|
|
|
DoDropThread(thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void nsExceptionService::DropAllThreads()
|
|
|
|
{
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
MutexAutoLock lock(*sLock);
|
2007-03-22 10:30:00 -07:00
|
|
|
while (firstThread)
|
|
|
|
DoDropThread(firstThread);
|
|
|
|
}
|