2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 11:12:37 +00: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 02:34:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* nsConsoleService class declaration.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __nsconsoleservice_h__
|
|
|
|
#define __nsconsoleservice_h__
|
|
|
|
|
2011-12-18 03:47:45 +00:00
|
|
|
#include "mozilla/Attributes.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-04-01 04:29:02 +00:00
|
|
|
#include "mozilla/Mutex.h"
|
2011-12-18 03:47:45 +00:00
|
|
|
|
2000-04-18 02:34:54 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2012-01-11 16:28:21 +00:00
|
|
|
#include "nsInterfaceHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
2000-04-18 02:34:54 +00:00
|
|
|
|
|
|
|
#include "nsIConsoleService.h"
|
|
|
|
|
2011-12-18 03:47:45 +00:00
|
|
|
class nsConsoleService MOZ_FINAL : public nsIConsoleService
|
2000-04-18 02:34:54 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsConsoleService();
|
2005-03-02 16:37:53 +00:00
|
|
|
nsresult Init();
|
2000-04-18 02:34:54 +00:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICONSOLESERVICE
|
|
|
|
|
2012-01-11 16:28:21 +00:00
|
|
|
void SetIsDelivering() {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(!mDeliveringMessage);
|
|
|
|
mDeliveringMessage = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDoneDelivering() {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(mDeliveringMessage);
|
|
|
|
mDeliveringMessage = false;
|
|
|
|
}
|
|
|
|
|
2000-04-18 02:34:54 +00:00
|
|
|
private:
|
2004-01-15 06:14:18 +00:00
|
|
|
~nsConsoleService();
|
|
|
|
|
2000-04-18 02:34:54 +00:00
|
|
|
// Circular buffer of saved messages
|
|
|
|
nsIConsoleMessage **mMessages;
|
|
|
|
|
|
|
|
// How big?
|
|
|
|
PRUint32 mBufferSize;
|
|
|
|
|
|
|
|
// Index of slot in mMessages that'll be filled by *next* log message
|
|
|
|
PRUint32 mCurrent;
|
|
|
|
|
|
|
|
// Is the buffer full? (Has mCurrent wrapped around at least once?)
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mFull;
|
2000-04-18 02:34:54 +00:00
|
|
|
|
2012-01-11 16:28:21 +00:00
|
|
|
// Are we currently delivering a console message on the main thread? If
|
|
|
|
// so, we suppress incoming messages on the main thread only, to avoid
|
|
|
|
// infinite repitition.
|
|
|
|
bool mDeliveringMessage;
|
|
|
|
|
2000-04-18 02:34:54 +00:00
|
|
|
// Listeners to notify whenever a new message is logged.
|
2012-01-11 16:28:21 +00:00
|
|
|
nsInterfaceHashtable<nsISupportsHashKey, nsIConsoleListener> mListeners;
|
2000-04-18 02:34:54 +00:00
|
|
|
|
|
|
|
// To serialize interesting methods.
|
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 04:29:02 +00:00
|
|
|
mozilla::Mutex mLock;
|
2000-04-18 02:34:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __nsconsoleservice_h__ */
|