2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
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"
|
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"
|
2012-11-07 10:34:33 +04:00
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
|
|
|
|
#include "mozilla/Preferences.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
|
2012-08-07 00:41:40 +04:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
2011-11-15 07:12:20 +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
|
|
|
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
|
|
|
|
2012-11-07 10:34:33 +04:00
|
|
|
static bool sLoggingEnabled = true;
|
|
|
|
|
2000-04-18 06:34:54 +04:00
|
|
|
nsConsoleService::nsConsoleService()
|
2012-07-30 18:20:58 +04:00
|
|
|
: mMessages(nullptr)
|
2012-01-11 20:28:21 +04:00
|
|
|
, mCurrent(0)
|
|
|
|
, mFull(false)
|
2012-01-11 20:28:21 +04:00
|
|
|
, mDeliveringMessage(false)
|
2012-01-11 20:28:21 +04:00
|
|
|
, 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()
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t i = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
while (i < mBufferSize && mMessages[i] != nullptr) {
|
2000-04-18 06:34:54 +04:00
|
|
|
NS_RELEASE(mMessages[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2005-03-02 19:37:53 +03:00
|
|
|
if (mMessages)
|
|
|
|
nsMemory::Free(mMessages);
|
2000-04-18 06:34:54 +04:00
|
|
|
}
|
|
|
|
|
2012-11-07 10:34:33 +04:00
|
|
|
class AddConsoleEnabledPrefWatcher : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
Preferences::AddBoolVarCache(&sLoggingEnabled, "consoleservice.enabled", true);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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 *));
|
|
|
|
|
2012-01-11 20:28:21 +04:00
|
|
|
mListeners.Init();
|
2012-11-07 10:34:33 +04:00
|
|
|
NS_DispatchToMainThread(new AddConsoleEnabledPrefWatcher);
|
2012-01-11 20:28:21 +04:00
|
|
|
|
2005-03-02 19:37:53 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-11 20:28:21 +04:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
class LogMessageRunnable : public nsRunnable
|
2001-10-26 08:51:08 +04:00
|
|
|
{
|
2012-01-11 20:28:21 +04:00
|
|
|
public:
|
2012-01-11 20:28:21 +04:00
|
|
|
LogMessageRunnable(nsIConsoleMessage* message, nsConsoleService* service)
|
|
|
|
: mMessage(message)
|
|
|
|
, mService(service)
|
2012-01-11 20:28:21 +04:00
|
|
|
{ }
|
|
|
|
|
|
|
|
void AddListener(nsIConsoleListener* listener) {
|
|
|
|
mListeners.AppendObject(listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIConsoleMessage> mMessage;
|
2012-01-11 20:28:21 +04:00
|
|
|
nsRefPtr<nsConsoleService> mService;
|
2012-01-11 20:28:21 +04:00
|
|
|
nsCOMArray<nsIConsoleListener> mListeners;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LogMessageRunnable::Run()
|
|
|
|
{
|
2012-01-11 20:28:21 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
mService->SetIsDelivering();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = 0; i < mListeners.Count(); ++i)
|
2012-01-11 20:28:21 +04:00
|
|
|
mListeners[i]->Observe(mMessage);
|
|
|
|
|
2012-01-11 20:28:21 +04:00
|
|
|
mService->SetDoneDelivering();
|
|
|
|
|
2012-01-11 20:28:21 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-10-26 08:51:08 +04:00
|
|
|
|
2012-01-11 20:28:21 +04:00
|
|
|
PLDHashOperator
|
|
|
|
CollectCurrentListeners(nsISupports* aKey, nsIConsoleListener* aValue,
|
|
|
|
void* closure)
|
|
|
|
{
|
|
|
|
LogMessageRunnable* r = static_cast<LogMessageRunnable*>(closure);
|
|
|
|
r->AddListener(aValue);
|
|
|
|
return PL_DHASH_NEXT;
|
2001-10-26 08:51:08 +04:00
|
|
|
}
|
|
|
|
|
2012-01-11 20:28:21 +04:00
|
|
|
} // anonymous namespace
|
|
|
|
|
2000-04-18 06:34:54 +04:00
|
|
|
// nsIConsoleService methods
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsConsoleService::LogMessage(nsIConsoleMessage *message)
|
2012-11-09 21:52:09 +04:00
|
|
|
{
|
|
|
|
return LogMessageWithMode(message, OutputToLog);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsConsoleService::LogMessageWithMode(nsIConsoleMessage *message, nsConsoleService::OutputMode outputMode)
|
2000-04-18 06:34:54 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
if (message == nullptr)
|
2000-04-18 06:34:54 +04:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2012-11-07 10:34:33 +04:00
|
|
|
if (!sLoggingEnabled) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-11 20:28:21 +04:00
|
|
|
if (NS_IsMainThread() && mDeliveringMessage) {
|
|
|
|
NS_WARNING("Some console listener threw an error while inside itself. Discarding this message");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-09-28 20:54:36 +04:00
|
|
|
nsRefPtr<LogMessageRunnable> r;
|
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)
|
2012-11-09 21:52:09 +04:00
|
|
|
if (outputMode == OutputToLog)
|
2011-11-15 07:12:20 +04:00
|
|
|
{
|
|
|
|
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
|
2012-08-07 00:41:40 +04:00
|
|
|
#ifdef XP_WIN
|
|
|
|
if (IsDebuggerPresent()) {
|
|
|
|
nsString msg;
|
|
|
|
message->GetMessageMoz(getter_Copies(msg));
|
|
|
|
msg.AppendLiteral("\n");
|
|
|
|
OutputDebugStringW(msg.get());
|
|
|
|
}
|
|
|
|
#endif
|
2011-11-15 07:12:20 +04:00
|
|
|
|
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
|
2012-09-28 20:54:36 +04:00
|
|
|
* is removed during an Observe(...) notification. If there are no
|
|
|
|
* listeners, don't bother to create the Runnable, since we don't
|
|
|
|
* need to run it and it will hold onto the memory for the message
|
|
|
|
* unnecessarily.
|
2001-10-26 08:51:08 +04:00
|
|
|
*/
|
2012-09-28 20:54:36 +04:00
|
|
|
if (mListeners.Count() > 0) {
|
|
|
|
r = new LogMessageRunnable(message, this);
|
|
|
|
mListeners.EnumerateRead(CollectCurrentListeners, r);
|
|
|
|
}
|
2000-04-18 06:34:54 +04:00
|
|
|
}
|
2012-09-28 20:54:36 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
if (retiredMessage != nullptr)
|
2000-04-18 06:34:54 +04:00
|
|
|
NS_RELEASE(retiredMessage);
|
|
|
|
|
2012-09-28 20:54:36 +04:00
|
|
|
if (r)
|
|
|
|
NS_DispatchToMainThread(r);
|
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)
|
|
|
|
{
|
2012-11-07 10:34:33 +04:00
|
|
|
if (!sLoggingEnabled) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<nsConsoleMessage> msg(new nsConsoleMessage(message));
|
2000-04-18 06:34:54 +04:00
|
|
|
return this->LogMessage(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-11-03 14:59:29 +04:00
|
|
|
nsConsoleService::GetMessageArray(uint32_t *count, nsIConsoleMessage ***messages)
|
2000-04-18 06:34:54 +04:00
|
|
|
{
|
|
|
|
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 *));
|
2012-07-30 18:20:58 +04:00
|
|
|
*messageArray = nullptr;
|
2000-04-18 06:34:54 +04:00
|
|
|
*messages = messageArray;
|
|
|
|
*count = 0;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t resultSize = mFull ? mBufferSize : mCurrent;
|
2000-04-18 06:34:54 +04:00
|
|
|
messageArray =
|
2000-06-03 13:46:12 +04:00
|
|
|
(nsIConsoleMessage **)nsMemory::Alloc((sizeof (nsIConsoleMessage *))
|
|
|
|
* resultSize);
|
2000-04-18 06:34:54 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
if (messageArray == nullptr) {
|
|
|
|
*messages = nullptr;
|
2000-04-18 06:34:54 +04:00
|
|
|
*count = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t i;
|
2000-04-18 06:34:54 +04:00
|
|
|
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
|
2012-01-11 20:28:21 +04:00
|
|
|
nsConsoleService::RegisterListener(nsIConsoleListener *listener)
|
|
|
|
{
|
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NS_ERROR("nsConsoleService::RegisterListener is main thread only.");
|
|
|
|
return NS_ERROR_NOT_SAME_THREAD;
|
|
|
|
}
|
2000-04-18 06:34:54 +04:00
|
|
|
|
2012-01-11 20:28:21 +04:00
|
|
|
nsCOMPtr<nsISupports> canonical = do_QueryInterface(listener);
|
2001-10-26 08:51:08 +04:00
|
|
|
|
2012-01-11 20:28:21 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
|
|
|
if (mListeners.GetWeak(canonical)) {
|
|
|
|
// Reregistering a listener isn't good
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-04-18 06:34:54 +04:00
|
|
|
}
|
2012-01-11 20:28:21 +04:00
|
|
|
mListeners.Put(canonical, listener);
|
2000-04-18 06:34:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-01-11 20:28:21 +04:00
|
|
|
nsConsoleService::UnregisterListener(nsIConsoleListener *listener)
|
|
|
|
{
|
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NS_ERROR("nsConsoleService::UnregisterListener is main thread only.");
|
|
|
|
return NS_ERROR_NOT_SAME_THREAD;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> canonical = do_QueryInterface(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
|
|
|
|
2012-01-11 20:28:21 +04:00
|
|
|
if (!mListeners.GetWeak(canonical)) {
|
|
|
|
// Unregistering a listener that was never registered?
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
mListeners.Remove(canonical);
|
2000-04-18 06:34:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
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)
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mBufferSize && mMessages[i] != nullptr; i++)
|
2006-07-19 16:49:33 +04:00
|
|
|
NS_RELEASE(mMessages[i]);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|