2014-05-05 10:30:39 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* nsConsoleService class declaration.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __nsconsoleservice_h__
|
|
|
|
#define __nsconsoleservice_h__
|
|
|
|
|
2011-12-17 19:47:45 -08: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-03-31 21:29:02 -07:00
|
|
|
#include "mozilla/Mutex.h"
|
2011-12-17 19:47:45 -08:00
|
|
|
|
2012-01-11 08:28:21 -08:00
|
|
|
#include "nsInterfaceHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsIConsoleService.h"
|
|
|
|
|
2011-12-17 19:47:45 -08:00
|
|
|
class nsConsoleService MOZ_FINAL : public nsIConsoleService
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-05-05 10:30:39 -07:00
|
|
|
nsConsoleService();
|
|
|
|
nsresult Init();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:39 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSICONSOLESERVICE
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-13 10:41:38 -07:00
|
|
|
void SetIsDelivering()
|
|
|
|
{
|
2014-05-05 10:30:39 -07:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(!mDeliveringMessage);
|
|
|
|
mDeliveringMessage = true;
|
|
|
|
}
|
2012-01-11 08:28:21 -08:00
|
|
|
|
2014-05-13 10:41:38 -07:00
|
|
|
void SetDoneDelivering()
|
|
|
|
{
|
2014-05-05 10:30:39 -07:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(mDeliveringMessage);
|
|
|
|
mDeliveringMessage = false;
|
|
|
|
}
|
2012-01-11 08:28:21 -08:00
|
|
|
|
2014-05-05 10:30:39 -07:00
|
|
|
// This is a variant of LogMessage which allows the caller to determine
|
|
|
|
// if the message should be output to an OS-specific log. This is used on
|
|
|
|
// B2G to control whether the message is logged to the android log or not.
|
2012-11-09 09:52:09 -08:00
|
|
|
|
2014-05-05 10:30:39 -07:00
|
|
|
enum OutputMode {
|
|
|
|
SuppressLog,
|
|
|
|
OutputToLog
|
|
|
|
};
|
2014-05-13 10:41:38 -07:00
|
|
|
virtual nsresult LogMessageWithMode(nsIConsoleMessage* aMessage,
|
|
|
|
OutputMode aOutputMode);
|
2012-11-09 09:52:09 -08:00
|
|
|
|
2014-05-05 10:30:39 -07:00
|
|
|
typedef nsInterfaceHashtable<nsISupportsHashKey, nsIConsoleListener> ListenerHash;
|
|
|
|
void EnumerateListeners(ListenerHash::EnumReadFunction aFunction, void* aClosure);
|
2013-01-29 08:02:56 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2014-05-05 10:30:39 -07:00
|
|
|
~nsConsoleService();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:39 -07:00
|
|
|
// Circular buffer of saved messages
|
2014-05-13 10:41:38 -07:00
|
|
|
nsIConsoleMessage** mMessages;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:39 -07:00
|
|
|
// How big?
|
|
|
|
uint32_t mBufferSize;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:39 -07:00
|
|
|
// Index of slot in mMessages that'll be filled by *next* log message
|
|
|
|
uint32_t mCurrent;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:39 -07:00
|
|
|
// Is the buffer full? (Has mCurrent wrapped around at least once?)
|
|
|
|
bool mFull;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:39 -07: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;
|
2012-01-11 08:28:21 -08:00
|
|
|
|
2014-05-05 10:30:39 -07:00
|
|
|
// Listeners to notify whenever a new message is logged.
|
|
|
|
ListenerHash mListeners;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:39 -07:00
|
|
|
// To serialize interesting methods.
|
|
|
|
mozilla::Mutex mLock;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __nsconsoleservice_h__ */
|