/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* ActiveState Tool Corp..
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mark Hammond <MarkH@ActiveState.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.h"
#include "nsExceptionService.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "prthread.h"
#include "prlock.h"
#define CHECK_MANAGER_USE_OK() if (!mService || !nsExceptionService::lock) return NS_ERROR_NOT_INITIALIZED
// A key for our registered module providers hashtable
protected:
public:
return mKey;
}
}
return new nsProviderKey(mKey);
}
};
/** Exception Manager definition **/
{
public:
/* additional members */
#ifdef NS_DEBUG
#endif
#ifdef NS_DEBUG
// shut up NS_ASSERT_OWNINGTHREAD (see explaination below)
if (ref != 0)
return ref;
}
#else
#endif
private:
};
#ifdef NS_DEBUG
#endif
// Note: the nsExceptionManager object is single threaded - the exception
// service itself ensures one per thread. However, there are two methods that
// may be called on foreign threads: DropAllThreads (called on the thread
// shutting down xpcom) and ThreadDestruct (called after xpcom destroyed the
// internal thread struct, so that PR_GetCurrentThread() will create a new one
// from scratch which will obviously not match the old one stored in the
// instance on creation). In both cases, there should be no other threads
// holding objects (i.e. it's thread-safe to call them), but
// NS_CheckThreadSafe() assertions will still happen and yell in the debug
// build. Since it is quite annoying, we use a special ReleaseQuiet() mehtod
// in DoDropThread() to shut them up.
{
/* member initializers and constructor code */
#ifdef NS_DEBUG
#endif
}
{
/* destructor code */
#ifdef NS_DEBUG
#endif // NS_DEBUG
}
/* void setCurrentException (in nsIException error); */
{
return NS_OK;
}
/* nsIException getCurrentException (); */
{
return NS_OK;
}
/* nsIException getExceptionFromProvider( in nsresult rc, in nsIException defaultException); */
NS_IMETHODIMP nsExceptionManager::GetExceptionFromProvider(nsresult rc, nsIException * defaultException, nsIException **_retval)
{
// Just delegate back to the service with the provider map.
}
/* The Exception Service */
#ifdef NS_DEBUG
#endif
{
#ifdef NS_DEBUG
NS_ERROR("The nsExceptionService is a singleton!");
}
#endif
/* member initializers and constructor code */
if (tlsIndex == BAD_TLS_INDEX) {
}
lock = PR_NewLock();
// observe XPCOM shutdown.
if (observerService)
}
{
Shutdown();
/* destructor code */
#ifdef NS_DEBUG
#endif
}
/*static*/
{
if (!lock) {
// a typical situation is when IPC worker threads that have instantiated
// exception managers are stopped after nsExceptionService is shut down,
// which will result into this warning. disable it.
#if 0
NS_WARNING("nsExceptionService ignoring thread destruction after shutdown");
#endif
return;
}
}
{
mProviders.Reset();
if (lock) {
}
}
/* void setCurrentException (in nsIException error); */
{
return nr;
}
/* nsIException getCurrentException (); */
{
return nr;
}
/* nsIException getExceptionFromProvider( in nsresult rc, in nsIException defaultException); */
{
}
/* readonly attribute nsIExceptionManager currentExceptionManager; */
NS_IMETHODIMP nsExceptionService::GetCurrentExceptionManager(nsIExceptionManager * *aCurrentScriptManager)
{
// Stick the new exception object in with no reference count.
mgr = new nsExceptionManager(this);
return NS_ERROR_OUT_OF_MEMORY;
// The reference count is held in the thread-list
}
return NS_OK;
}
/* void registerErrorProvider (in nsIExceptionProvider provider, in PRUint32 moduleCode); */
NS_IMETHODIMP nsExceptionService::RegisterExceptionProvider(nsIExceptionProvider *provider, PRUint32 errorModule)
{
NS_WARNING("Registration of exception provider overwrote another provider with the same module code!");
}
return NS_OK;
}
/* void unregisterErrorProvider (in nsIExceptionProvider provider, in PRUint32 errorModule); */
NS_IMETHODIMP nsExceptionService::UnregisterExceptionProvider(nsIExceptionProvider *provider, PRUint32 errorModule)
{
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;
}
nsIException **_exc)
{
// Check for an existing exception
// If it matches our result then use it
return NS_OK;
NS_RELEASE(*_exc);
}
// No provider so we'll return the default exception
if (!provider) {
*_exc = defaultException;
NS_IF_ADDREF(*_exc);
return NS_OK;
}
}
// thread management
{
}
{
}
thread->ReleaseQuiet();
thread = 0;
}
{
}
{
while (firstThread)
}