1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * nsConsoleService class declaration.
11 #ifndef __nsconsoleservice_h__
12 #define __nsconsoleservice_h__
14 #include "mozilla/Attributes.h"
15 #include "mozilla/Mutex.h"
17 #include "nsInterfaceHashtable.h"
18 #include "nsHashKeys.h"
20 #include "nsIConsoleService.h"
22 class nsConsoleService MOZ_FINAL
: public nsIConsoleService
28 NS_DECL_THREADSAFE_ISUPPORTS
29 NS_DECL_NSICONSOLESERVICE
31 void SetIsDelivering()
33 MOZ_ASSERT(NS_IsMainThread());
34 MOZ_ASSERT(!mDeliveringMessage
);
35 mDeliveringMessage
= true;
38 void SetDoneDelivering()
40 MOZ_ASSERT(NS_IsMainThread());
41 MOZ_ASSERT(mDeliveringMessage
);
42 mDeliveringMessage
= false;
45 // This is a variant of LogMessage which allows the caller to determine
46 // if the message should be output to an OS-specific log. This is used on
47 // B2G to control whether the message is logged to the android log or not.
53 virtual nsresult
LogMessageWithMode(nsIConsoleMessage
* aMessage
,
54 OutputMode aOutputMode
);
56 typedef nsInterfaceHashtable
<nsISupportsHashKey
,
57 nsIConsoleListener
> ListenerHash
;
58 void EnumerateListeners(ListenerHash::EnumReadFunction aFunction
,
64 // Circular buffer of saved messages
65 nsIConsoleMessage
** mMessages
;
70 // Index of slot in mMessages that'll be filled by *next* log message
73 // Is the buffer full? (Has mCurrent wrapped around at least once?)
76 // Are we currently delivering a console message on the main thread? If
77 // so, we suppress incoming messages on the main thread only, to avoid
78 // infinite repitition.
79 bool mDeliveringMessage
;
81 // Listeners to notify whenever a new message is logged.
82 ListenerHash mListeners
;
84 // To serialize interesting methods.
88 #endif /* __nsconsoleservice_h__ */