2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:21:17 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2000-04-18 06:34:54 +04:00
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* 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
|
|
|
|
* http://www.mozilla.org/MPL/
|
2000-04-18 06:34:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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.
|
2000-04-18 06:34:54 +04:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2000-04-18 06:34:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2006-07-19 16:49:33 +04:00
|
|
|
* Simon Bünzli <zeniko@gmail.com>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:21:17 +04:00
|
|
|
* 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"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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
|
2004-04-18 18:21:17 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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
|
2004-04-18 18:21:17 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2000-04-18 06:34:54 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Maintains a circular buffer of recent messages, and notifies
|
|
|
|
* listeners when new messages are logged.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Threadsafe. */
|
|
|
|
|
2000-06-03 13:46:12 +04:00
|
|
|
#include "nsMemory.h"
|
2000-04-18 06:34:54 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2000-06-24 04:03:10 +04:00
|
|
|
#include "nsIProxyObjectManager.h"
|
2009-04-14 12:02:58 +04:00
|
|
|
#include "nsCOMArray.h"
|
2006-05-10 21:30:15 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2000-04-18 06:34:54 +04:00
|
|
|
|
|
|
|
#include "nsConsoleService.h"
|
|
|
|
#include "nsConsoleMessage.h"
|
2006-03-15 07:59:42 +03:00
|
|
|
#include "nsIClassInfoImpl.h"
|
2000-04-18 06:34:54 +04:00
|
|
|
|
2011-11-15 07:12:20 +04:00
|
|
|
#if defined(ANDROID)
|
|
|
|
#include <android/log.h>
|
|
|
|
#endif
|
|
|
|
|
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-04-01 08:29:02 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2004-10-28 11:34:41 +04:00
|
|
|
NS_IMPL_THREADSAFE_ADDREF(nsConsoleService)
|
|
|
|
NS_IMPL_THREADSAFE_RELEASE(nsConsoleService)
|
2010-06-22 20:59:57 +04:00
|
|
|
NS_IMPL_CLASSINFO(nsConsoleService, NULL, nsIClassInfo::THREADSAFE | nsIClassInfo::SINGLETON, NS_CONSOLESERVICE_CID)
|
2004-10-28 11:34:41 +04:00
|
|
|
NS_IMPL_QUERY_INTERFACE1_CI(nsConsoleService, nsIConsoleService)
|
|
|
|
NS_IMPL_CI_INTERFACE_GETTER1(nsConsoleService, nsIConsoleService)
|
2000-04-18 06:34:54 +04:00
|
|
|
|
|
|
|
nsConsoleService::nsConsoleService()
|
2011-10-17 18:59:28 +04:00
|
|
|
: mMessages(nsnull), mCurrent(0), mFull(false), mListening(false), mLock("nsConsoleService.mLock")
|
2000-04-18 06:34:54 +04:00
|
|
|
{
|
|
|
|
// XXX grab this from a pref!
|
|
|
|
// hm, but worry about circularity, bc we want to be able to report
|
|
|
|
// prefs errs...
|
|
|
|
mBufferSize = 250;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsConsoleService::~nsConsoleService()
|
|
|
|
{
|
|
|
|
PRUint32 i = 0;
|
|
|
|
while (i < mBufferSize && mMessages[i] != nsnull) {
|
|
|
|
NS_RELEASE(mMessages[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_mccabe
|
2001-10-26 08:51:08 +04:00
|
|
|
if (mListeners.Count() != 0) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"WARNING - %d console error listeners still registered!\n"
|
|
|
|
"More calls to nsIConsoleService::UnregisterListener needed.\n",
|
|
|
|
mListeners.Count());
|
2000-04-18 06:34:54 +04:00
|
|
|
}
|
2001-10-26 08:51:08 +04:00
|
|
|
|
2000-04-18 06:34:54 +04:00
|
|
|
#endif
|
|
|
|
|
2005-03-02 19:37:53 +03:00
|
|
|
if (mMessages)
|
|
|
|
nsMemory::Free(mMessages);
|
2000-04-18 06:34:54 +04:00
|
|
|
}
|
|
|
|
|
2005-03-02 19:37:53 +03:00
|
|
|
nsresult
|
|
|
|
nsConsoleService::Init()
|
|
|
|
{
|
|
|
|
mMessages = (nsIConsoleMessage **)
|
|
|
|
nsMemory::Alloc(mBufferSize * sizeof(nsIConsoleMessage *));
|
|
|
|
if (!mMessages)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
// Array elements should be 0 initially for circular buffer algorithm.
|
|
|
|
memset(mMessages, 0, mBufferSize * sizeof(nsIConsoleMessage *));
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool snapshot_enum_func(nsHashKey *key, void *data, void* closure)
|
2001-10-26 08:51:08 +04:00
|
|
|
{
|
2009-04-14 12:02:58 +04:00
|
|
|
nsCOMArray<nsIConsoleListener> *array =
|
|
|
|
reinterpret_cast<nsCOMArray<nsIConsoleListener> *>(closure);
|
2001-10-26 08:51:08 +04:00
|
|
|
|
2009-04-14 12:02:58 +04:00
|
|
|
// Copy each element into the temporary nsCOMArray...
|
|
|
|
array->AppendObject((nsIConsoleListener*)data);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-10-26 08:51:08 +04:00
|
|
|
}
|
|
|
|
|
2000-04-18 06:34:54 +04:00
|
|
|
// nsIConsoleService methods
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsConsoleService::LogMessage(nsIConsoleMessage *message)
|
|
|
|
{
|
|
|
|
if (message == nsnull)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2009-04-14 12:02:58 +04:00
|
|
|
nsCOMArray<nsIConsoleListener> listenersSnapshot;
|
2000-04-18 06:34:54 +04:00
|
|
|
nsIConsoleMessage *retiredMessage;
|
|
|
|
|
|
|
|
NS_ADDREF(message); // early, in case it's same as replaced below.
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lock while updating buffer, and while taking snapshot of
|
|
|
|
* listeners array.
|
|
|
|
*/
|
|
|
|
{
|
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-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2000-04-18 06:34:54 +04:00
|
|
|
|
2011-11-15 07:12:20 +04:00
|
|
|
#if defined(ANDROID)
|
|
|
|
{
|
|
|
|
nsXPIDLString msg;
|
|
|
|
message->GetMessageMoz(getter_Copies(msg));
|
2011-11-18 08:07:06 +04:00
|
|
|
__android_log_print(ANDROID_LOG_ERROR, "GeckoConsole",
|
2011-11-15 07:12:20 +04:00
|
|
|
"%s",
|
|
|
|
NS_LossyConvertUTF16toASCII(msg).get());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-04-18 06:34:54 +04:00
|
|
|
/*
|
|
|
|
* If there's already a message in the slot we're about to replace,
|
|
|
|
* we've wrapped around, and we need to release the old message. We
|
|
|
|
* save a pointer to it, so we can release below outside the lock.
|
|
|
|
*/
|
|
|
|
retiredMessage = mMessages[mCurrent];
|
|
|
|
|
|
|
|
mMessages[mCurrent++] = message;
|
|
|
|
if (mCurrent == mBufferSize) {
|
|
|
|
mCurrent = 0; // wrap around.
|
2011-10-17 18:59:28 +04:00
|
|
|
mFull = true;
|
2000-04-18 06:34:54 +04:00
|
|
|
}
|
|
|
|
|
2001-10-26 08:51:08 +04:00
|
|
|
/*
|
|
|
|
* Copy the listeners into the snapshot array - in case a listener
|
|
|
|
* is removed during an Observe(...) notification...
|
|
|
|
*/
|
|
|
|
mListeners.Enumerate(snapshot_enum_func, &listenersSnapshot);
|
2000-04-18 06:34:54 +04:00
|
|
|
}
|
|
|
|
if (retiredMessage != nsnull)
|
|
|
|
NS_RELEASE(retiredMessage);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterate through any registered listeners and tell them about
|
|
|
|
* the message. We use the mListening flag to guard against
|
|
|
|
* recursive message logs. This could sometimes result in
|
|
|
|
* listeners being skipped because of activity on other threads,
|
|
|
|
* when we only care about the recursive case.
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIConsoleListener> listener;
|
2009-04-14 12:02:58 +04:00
|
|
|
PRInt32 snapshotCount = listenersSnapshot.Count();
|
2000-04-18 06:34:54 +04: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-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2000-04-18 06:34:54 +04:00
|
|
|
if (mListening)
|
|
|
|
return NS_OK;
|
2011-10-17 18:59:28 +04:00
|
|
|
mListening = true;
|
2000-04-18 06:34:54 +04:00
|
|
|
}
|
|
|
|
|
2009-04-14 12:02:58 +04:00
|
|
|
for (PRInt32 i = 0; i < snapshotCount; i++) {
|
|
|
|
listenersSnapshot[i]->Observe(message);
|
2000-04-18 06:34:54 +04: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-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2011-10-17 18:59:28 +04:00
|
|
|
mListening = false;
|
2000-04-18 06:34:54 +04:00
|
|
|
}
|
|
|
|
|
2009-04-14 12:02:58 +04:00
|
|
|
return NS_OK;
|
2000-04-18 06:34:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsConsoleService::LogStringMessage(const PRUnichar *message)
|
|
|
|
{
|
|
|
|
nsConsoleMessage *msg = new nsConsoleMessage(message);
|
|
|
|
return this->LogMessage(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsConsoleService::GetMessageArray(nsIConsoleMessage ***messages, PRUint32 *count)
|
|
|
|
{
|
|
|
|
nsIConsoleMessage **messageArray;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lock the whole method, as we don't want anyone mucking with mCurrent or
|
|
|
|
* mFull while we're copying out the buffer.
|
|
|
|
*/
|
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-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2000-04-18 06:34:54 +04:00
|
|
|
|
|
|
|
if (mCurrent == 0 && !mFull) {
|
|
|
|
/*
|
|
|
|
* Make a 1-length output array so that nobody gets confused,
|
|
|
|
* and return a count of 0. This should result in a 0-length
|
|
|
|
* array object when called from script.
|
|
|
|
*/
|
|
|
|
messageArray = (nsIConsoleMessage **)
|
2000-06-03 13:46:12 +04:00
|
|
|
nsMemory::Alloc(sizeof (nsIConsoleMessage *));
|
2000-04-18 06:34:54 +04:00
|
|
|
*messageArray = nsnull;
|
|
|
|
*messages = messageArray;
|
|
|
|
*count = 0;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 resultSize = mFull ? mBufferSize : mCurrent;
|
|
|
|
messageArray =
|
2000-06-03 13:46:12 +04:00
|
|
|
(nsIConsoleMessage **)nsMemory::Alloc((sizeof (nsIConsoleMessage *))
|
|
|
|
* resultSize);
|
2000-04-18 06:34:54 +04:00
|
|
|
|
|
|
|
if (messageArray == nsnull) {
|
|
|
|
*messages = nsnull;
|
|
|
|
*count = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 i;
|
|
|
|
if (mFull) {
|
|
|
|
for (i = 0; i < mBufferSize; i++) {
|
|
|
|
// if full, fill the buffer starting from mCurrent (which'll be
|
|
|
|
// oldest) wrapping around the buffer to the most recent.
|
|
|
|
messageArray[i] = mMessages[(mCurrent + i) % mBufferSize];
|
|
|
|
NS_ADDREF(messageArray[i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < mCurrent; i++) {
|
|
|
|
messageArray[i] = mMessages[i];
|
|
|
|
NS_ADDREF(messageArray[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*count = resultSize;
|
|
|
|
*messages = messageArray;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsConsoleService::RegisterListener(nsIConsoleListener *listener) {
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Store a threadsafe proxy to the listener rather than the
|
|
|
|
* listener itself; we want the console service to be callable
|
|
|
|
* from any thread, but listeners can be implemented in
|
|
|
|
* thread-specific ways, and we always want to call them on their
|
|
|
|
* originating thread. JavaScript is the motivating example.
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIConsoleListener> proxiedListener;
|
|
|
|
|
2000-10-10 03:45:59 +04:00
|
|
|
rv = GetProxyForListener(listener, getter_AddRefs(proxiedListener));
|
2000-04-18 06:34:54 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
{
|
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-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2001-10-26 08:51:08 +04:00
|
|
|
nsISupportsKey key(listener);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Put the proxy event listener into a hashtable using the *real*
|
|
|
|
* listener as the key.
|
|
|
|
*
|
|
|
|
* This is necessary because proxy objects do *not* maintain
|
|
|
|
* nsISupports identity. Therefore, since GetProxyForListener(...)
|
|
|
|
* can return different proxies for the same object (see bug #85831)
|
|
|
|
* we need to use the real object as the unique key...
|
|
|
|
*/
|
|
|
|
mListeners.Put(&key, proxiedListener);
|
2000-04-18 06:34:54 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsConsoleService::UnregisterListener(nsIConsoleListener *listener) {
|
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-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2000-04-18 06:34:54 +04:00
|
|
|
|
2001-10-26 08:51:08 +04:00
|
|
|
nsISupportsKey key(listener);
|
|
|
|
mListeners.Remove(&key);
|
2000-04-18 06:34:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-10-10 03:45:59 +04:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsConsoleService::GetProxyForListener(nsIConsoleListener* aListener,
|
|
|
|
nsIConsoleListener** aProxy)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Would it be better to catch that case and leave the listener unproxied?
|
|
|
|
*/
|
2006-05-10 21:30:15 +04:00
|
|
|
return NS_GetProxyForObject(NS_PROXY_TO_CURRENT_THREAD,
|
|
|
|
NS_GET_IID(nsIConsoleListener),
|
|
|
|
aListener,
|
|
|
|
NS_PROXY_ASYNC | NS_PROXY_ALWAYS,
|
|
|
|
(void**) aProxy);
|
2000-10-10 03:45:59 +04:00
|
|
|
}
|
2006-07-19 16:49:33 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsConsoleService::Reset()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Make sure nobody trips into the buffer while it's being 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-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2006-07-19 16:49:33 +04:00
|
|
|
|
|
|
|
mCurrent = 0;
|
2011-10-17 18:59:28 +04:00
|
|
|
mFull = false;
|
2006-07-19 16:49:33 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Free all messages stored so far (cf. destructor)
|
|
|
|
*/
|
|
|
|
for (PRUint32 i = 0; i < mBufferSize && mMessages[i] != nsnull; i++)
|
|
|
|
NS_RELEASE(mMessages[i]);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|