Bug 806618 - rewrite PR_NewLogModule calls to not generate static initializers; r=ehsan

This commit is contained in:
Nathan Froyd 2012-10-29 19:32:10 -04:00
parent 9593cebee0
commit 4c61ef9ec5
64 changed files with 646 additions and 319 deletions

View File

@ -12,10 +12,10 @@
#include "prlog.h"
#ifdef PR_LOGGING
extern PRLogModuleInfo* dataChannelLog;
extern PRLogModuleInfo* GetDataChannelLog();
#endif
#undef LOG
#define LOG(args) PR_LOG(dataChannelLog, PR_LOG_DEBUG, args)
#define LOG(args) PR_LOG(GetDataChannelLog(), PR_LOG_DEBUG, args)
#include "nsDOMDataChannel.h"

View File

@ -75,11 +75,18 @@
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#ifdef PR_LOGGING
static PRLogModuleInfo* gObjectLog = PR_NewLogModule("objlc");
static PRLogModuleInfo*
GetObjectLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("objlc");
return sLog;
}
#endif
#define LOG(args) PR_LOG(gObjectLog, PR_LOG_DEBUG, args)
#define LOG_ENABLED() PR_LOG_TEST(gObjectLog, PR_LOG_DEBUG)
#define LOG(args) PR_LOG(GetObjectLog(), PR_LOG_DEBUG, args)
#define LOG_ENABLED() PR_LOG_TEST(GetObjectLog(), PR_LOG_DEBUG)
static bool
InActiveDocument(nsIContent *aContent)

View File

@ -13,11 +13,18 @@
#include "prlog.h"
#ifdef PR_LOGGING
PRLogModuleInfo* GetUserMediaLog = PR_NewLogModule("GetUserMedia");
static PRLogModuleInfo*
GetUserMediaLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("GetUserMedia");
return sLog;
}
#endif
#undef LOG
#define LOG(args) PR_LOG(GetUserMediaLog, PR_LOG_DEBUG, args)
#define LOG(args) PR_LOG(GetUserMediaLog(), PR_LOG_DEBUG, args)
#include "MediaEngineWebRTC.h"
#include "ImageContainer.h"

View File

@ -15,8 +15,8 @@
namespace mozilla {
#ifdef PR_LOGGING
extern PRLogModuleInfo* gMediaManagerLog;
#define LOG(msg) PR_LOG(gMediaManagerLog, PR_LOG_DEBUG, msg)
extern PRLogModuleInfo* GetMediaManagerLog();
#define LOG(msg) PR_LOG(GetMediaManagerLog(), PR_LOG_DEBUG, msg)
#else
#define LOG(msg)
#endif

View File

@ -10,8 +10,8 @@
namespace mozilla {
#ifdef PR_LOGGING
extern PRLogModuleInfo* gMediaManagerLog;
#define LOG(msg) PR_LOG(gMediaManagerLog, PR_LOG_DEBUG, msg)
extern PRLogModuleInfo* GetMediaManagerLog();
#define LOG(msg) PR_LOG(GetMediaManagerLog(), PR_LOG_DEBUG, msg)
#else
#define LOG(msg)
#endif

View File

@ -60,8 +60,15 @@ int32_t nsSHistory::sHistoryMaxTotalViewers = -1;
// entries were touched, so that we can evict older entries first.
static uint32_t gTouchCounter = 0;
static PRLogModuleInfo* gLogModule = PR_NewLogModule("nsSHistory");
#define LOG(format) PR_LOG(gLogModule, PR_LOG_DEBUG, format)
static PRLogModuleInfo*
GetSHistoryLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsSHistory");
return sLog;
}
#define LOG(format) PR_LOG(GetSHistoryLog(), PR_LOG_DEBUG, format)
// This macro makes it easier to print a log message which includes a URI's
// spec. Example use:
@ -71,7 +78,7 @@ static PRLogModuleInfo* gLogModule = PR_NewLogModule("nsSHistory");
//
#define LOG_SPEC(format, uri) \
PR_BEGIN_MACRO \
if (PR_LOG_TEST(gLogModule, PR_LOG_DEBUG)) { \
if (PR_LOG_TEST(GetSHistoryLog(), PR_LOG_DEBUG)) { \
nsAutoCString _specStr(NS_LITERAL_CSTRING("(null)"));\
if (uri) { \
uri->GetSpec(_specStr); \
@ -89,7 +96,7 @@ static PRLogModuleInfo* gLogModule = PR_NewLogModule("nsSHistory");
//
#define LOG_SHENTRY_SPEC(format, shentry) \
PR_BEGIN_MACRO \
if (PR_LOG_TEST(gLogModule, PR_LOG_DEBUG)) { \
if (PR_LOG_TEST(GetSHistoryLog(), PR_LOG_DEBUG)) { \
nsCOMPtr<nsIURI> uri; \
shentry->GetURI(getter_AddRefs(uri)); \
LOG_SPEC(format, uri); \

View File

@ -24,8 +24,8 @@
#include "prlog.h"
#ifdef PR_LOGGING
extern PRLogModuleInfo* gCameraLog;
#define DOM_CAMERA_LOG( type, ... ) PR_LOG(gCameraLog, (PRLogModuleLevel)type, ( __VA_ARGS__ ))
extern PRLogModuleInfo* GetCameraLog();
#define DOM_CAMERA_LOG( type, ... ) PR_LOG(GetCameraLog(), (PRLogModuleLevel)type, ( __VA_ARGS__ ))
#else
#define DOM_CAMERA_LOG( type, ... )
#endif
@ -51,7 +51,7 @@ enum {
#ifdef PR_LOGGING
#define DOM_CAMERA_LOGR( ... ) \
do { \
if (gCameraLog) { \
if (GetCameraLog()) { \
DOM_CAMERA_LOG( DOM_CAMERA_LOG_REFERENCES, __VA_ARGS__ ); \
} \
} while (0)

View File

@ -44,7 +44,14 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCameraManager)
* Set the NSPR_LOG_MODULES environment variable to enable logging
* in a debug build, e.g. NSPR_LOG_MODULES=Camera:5
*/
PRLogModuleInfo* gCameraLog = PR_NewLogModule("Camera");
PRLogModuleInfo*
GetCameraLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("Camera");
return sLog;
}
/**
* nsDOMCameraManager::GetListOfCameras

View File

@ -53,9 +53,16 @@ static bool sInitialized = false;
// in your environment.
#ifdef PR_LOGGING
static PRLogModuleInfo* logModule = PR_NewLogModule("ProcessPriorityManager");
static PRLogModuleInfo*
GetPPMLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("ProcessPriorityManager");
return sLog;
}
#define LOG(fmt, ...) \
PR_LOG(logModule, PR_LOG_DEBUG, \
PR_LOG(GetPPMLog(), PR_LOG_DEBUG, \
("[%d] ProcessPriorityManager - " fmt, getpid(), ##__VA_ARGS__))
#else
#define LOG(fmt, ...)

View File

@ -29,8 +29,15 @@
namespace mozilla {
#ifdef PR_LOGGING
PRLogModuleInfo* gMediaManagerLog = PR_NewLogModule("MediaManager");
#define LOG(msg) PR_LOG(gMediaManagerLog, PR_LOG_DEBUG, msg)
PRLogModuleInfo*
GetMediaManagerLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("MediaManager");
return sLog;
}
#define LOG(msg) PR_LOG(GetMediaManagerLog(), PR_LOG_DEBUG, msg)
#else
#define LOG(msg)
#endif

View File

@ -19,8 +19,8 @@
namespace mozilla {
#ifdef PR_LOGGING
extern PRLogModuleInfo* gMediaManagerLog;
#define MM_LOG(msg) PR_LOG(gMediaManagerLog, PR_LOG_DEBUG, msg)
extern PRLogModuleInfo* GetMediaManagerLog();
#define MM_LOG(msg) PR_LOG(GetMediaManagerLog(), PR_LOG_DEBUG, msg)
#else
#define MM_LOG(msg)
#endif

View File

@ -454,7 +454,7 @@ PluginInstanceChild::NPN_GetValue(NPNVariable aVar,
#endif
default:
PR_LOG(gPluginLog, PR_LOG_WARNING,
PR_LOG(GetPluginLog(), PR_LOG_WARNING,
("In PluginInstanceChild::NPN_GetValue: Unhandled NPNVariable %i (%s)",
(int) aVar, NPNVariableToString(aVar)));
return NPERR_GENERIC_ERROR;
@ -483,7 +483,7 @@ PluginInstanceChild::Invalidate()
NPError
PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
{
PR_LOG(gPluginLog, PR_LOG_DEBUG, ("%s (aVar=%i, aValue=%p)",
PR_LOG(GetPluginLog(), PR_LOG_DEBUG, ("%s (aVar=%i, aValue=%p)",
FULLFUNCTION, (int) aVar, aValue));
AssertPluginThread();
@ -587,7 +587,7 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
#endif
default:
PR_LOG(gPluginLog, PR_LOG_WARNING,
PR_LOG(GetPluginLog(), PR_LOG_WARNING,
("In PluginInstanceChild::NPN_SetValue: Unhandled NPPVariable %i (%s)",
(int) aVar, NPPVariableToString(aVar)));
return NPERR_GENERIC_ERROR;
@ -2175,7 +2175,7 @@ PluginInstanceChild::FlashThrottleMessage(HWND aWnd,
bool
PluginInstanceChild::AnswerSetPluginFocus()
{
PR_LOG(gPluginLog, PR_LOG_DEBUG, ("%s", FULLFUNCTION));
PR_LOG(GetPluginLog(), PR_LOG_DEBUG, ("%s", FULLFUNCTION));
#if defined(OS_WIN)
// Parent is letting us know the dom set focus to the plugin. Note,
@ -2198,7 +2198,7 @@ PluginInstanceChild::AnswerSetPluginFocus()
bool
PluginInstanceChild::AnswerUpdateWindow()
{
PR_LOG(gPluginLog, PR_LOG_DEBUG, ("%s", FULLFUNCTION));
PR_LOG(GetPluginLog(), PR_LOG_DEBUG, ("%s", FULLFUNCTION));
#if defined(OS_WIN)
if (mPluginWindowHWND) {

View File

@ -1147,7 +1147,7 @@ PluginInstanceParent::NPP_GetValue(NPPVariable aVariable,
#endif
default:
PR_LOG(gPluginLog, PR_LOG_WARNING,
PR_LOG(GetPluginLog(), PR_LOG_WARNING,
("In PluginInstanceParent::NPP_GetValue: Unhandled NPPVariable %i (%s)",
(int) aVariable, NPPVariableToString(aVariable)));
return NPERR_GENERIC_ERROR;
@ -1168,7 +1168,7 @@ PluginInstanceParent::NPP_SetValue(NPNVariable variable, void* value)
default:
NS_ERROR("Unhandled NPNVariable in NPP_SetValue");
PR_LOG(gPluginLog, PR_LOG_WARNING,
PR_LOG(GetPluginLog(), PR_LOG_WARNING,
("In PluginInstanceParent::NPP_SetValue: Unhandled NPNVariable %i (%s)",
(int) variable, NPNVariableToString(variable)));
return NPERR_GENERIC_ERROR;

View File

@ -123,7 +123,14 @@ UnmungePluginDsoPath(const string& munged)
}
PRLogModuleInfo* gPluginLog = PR_NewLogModule("IPCPlugins");
PRLogModuleInfo*
GetPluginLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("IPCPlugins");
return sLog;
}
void
DeferNPObjectLastRelease(const NPNetscapeFuncs* f, NPObject* o)

View File

@ -53,7 +53,7 @@ MungePluginDsoPath(const std::string& path);
std::string
UnmungePluginDsoPath(const std::string& munged);
extern PRLogModuleInfo* gPluginLog;
extern PRLogModuleInfo* GetPluginLog();
const uint32_t kAllowAsyncDrawing = 0x1;
@ -73,9 +73,9 @@ inline bool IsDrawingModelAsync(int16_t aModel) {
#define FULLFUNCTION __FUNCTION__
#endif
#define PLUGIN_LOG_DEBUG(args) PR_LOG(gPluginLog, PR_LOG_DEBUG, args)
#define PLUGIN_LOG_DEBUG_FUNCTION PR_LOG(gPluginLog, PR_LOG_DEBUG, ("%s", FULLFUNCTION))
#define PLUGIN_LOG_DEBUG_METHOD PR_LOG(gPluginLog, PR_LOG_DEBUG, ("%s [%p]", FULLFUNCTION, (void*) this))
#define PLUGIN_LOG_DEBUG(args) PR_LOG(GetPluginLog(), PR_LOG_DEBUG, args)
#define PLUGIN_LOG_DEBUG_FUNCTION PR_LOG(GetPluginLog(), PR_LOG_DEBUG, ("%s", FULLFUNCTION))
#define PLUGIN_LOG_DEBUG_METHOD PR_LOG(GetPluginLog(), PR_LOG_DEBUG, ("%s [%p]", FULLFUNCTION, (void*) this))
/**
* This is NPByteRange without the linked list.

View File

@ -1054,7 +1054,7 @@ nsresult
PluginModuleParent::NP_GetValue(void *future, NPPVariable aVariable,
void *aValue, NPError* error)
{
PR_LOG(gPluginLog, PR_LOG_WARNING, ("%s Not implemented, requested variable %i", __FUNCTION__,
PR_LOG(GetPluginLog(), PR_LOG_WARNING, ("%s Not implemented, requested variable %i", __FUNCTION__,
(int) aVariable));
//TODO: implement this correctly

View File

@ -47,7 +47,14 @@
#include "Logging.h"
#ifdef PR_LOGGING
PRLogModuleInfo *sGFX2DLog = PR_NewLogModule("gfx2d");
PRLogModuleInfo *
GetGFX2DLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("gfx2d");
return sLog;
}
#endif
// The following code was largely taken from xpcom/glue/SSE.cpp and

View File

@ -20,7 +20,7 @@
#ifdef PR_LOGGING
#include <prlog.h>
extern PRLogModuleInfo *sGFX2DLog;
extern PRLogModuleInfo *GetGFX2DLog();
#endif
namespace mozilla {
@ -51,7 +51,7 @@ static inline void OutputMessage(const std::string &aString, int aLevel) {
::OutputDebugStringA(aString.c_str());
}
#elif defined(PR_LOGGING)
if (PR_LOG_TEST(sGFX2DLog, PRLogLevelForLevel(aLevel))) {
if (PR_LOG_TEST(GetGFX2DLog(), PRLogLevelForLevel(aLevel))) {
PR_LogPrint(aString.c_str());
}
#else

View File

@ -62,12 +62,19 @@
using namespace mozilla;
#ifdef PR_LOGGING
static PRLogModuleInfo *gFontInfoLog = PR_NewLogModule("fontInfoLog");
static PRLogModuleInfo *
GetFontInfoLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("fontInfoLog");
return sLog;
}
#endif /* PR_LOGGING */
#undef LOG
#define LOG(args) PR_LOG(gFontInfoLog, PR_LOG_DEBUG, args)
#define LOG_ENABLED() PR_LOG_TEST(gFontInfoLog, PR_LOG_DEBUG)
#define LOG(args) PR_LOG(GetFontInfoLog(), PR_LOG_DEBUG, args)
#define LOG_ENABLED() PR_LOG_TEST(GetFontInfoLog(), PR_LOG_DEBUG)
static __inline void
BuildKeyNameFromFontName(nsAString &aName)

View File

@ -39,7 +39,14 @@
#include "mozilla/Preferences.h"
static PRLogModuleInfo *gFontLog = PR_NewLogModule("ft2fonts");
static PRLogModuleInfo *
GetFontLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("ft2fonts");
return sLog;
}
// rounding and truncation functions for a Freetype floating point number
// (FT26Dot6) stored in a 32bit integer with high 26 bits for the integer
@ -339,8 +346,8 @@ gfxFT2FontGroup::WhichPrefFontSupportsChar(uint32_t aCh)
/* special case CJK */
if (unicodeRange == kRangeSetCJK) {
if (PR_LOG_TEST(gFontLog, PR_LOG_DEBUG)) {
PR_LOG(gFontLog, PR_LOG_DEBUG, (" - Trying to find fonts for: CJK"));
if (PR_LOG_TEST(GetFontLog(), PR_LOG_DEBUG)) {
PR_LOG(GetFontLog(), PR_LOG_DEBUG, (" - Trying to find fonts for: CJK"));
}
nsAutoTArray<nsRefPtr<gfxFontEntry>, 15> fonts;
@ -349,7 +356,7 @@ gfxFT2FontGroup::WhichPrefFontSupportsChar(uint32_t aCh)
} else {
nsIAtom *langGroup = LangGroupFromUnicodeRange(unicodeRange);
if (langGroup) {
PR_LOG(gFontLog, PR_LOG_DEBUG, (" - Trying to find fonts for: %s", nsAtomCString(langGroup).get()));
PR_LOG(GetFontLog(), PR_LOG_DEBUG, (" - Trying to find fonts for: %s", nsAtomCString(langGroup).get()));
nsAutoTArray<nsRefPtr<gfxFontEntry>, 5> fonts;
GetPrefFonts(langGroup, fonts);

View File

@ -24,11 +24,18 @@
using namespace mozilla;
#ifdef PR_LOGGING
PRLogModuleInfo *gfxUserFontSet::sUserFontsLog = PR_NewLogModule("userfonts");
PRLogModuleInfo *
gfxUserFontSet::GetUserFontsLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("userfonts");
return sLog;
}
#endif /* PR_LOGGING */
#define LOG(args) PR_LOG(sUserFontsLog, PR_LOG_DEBUG, args)
#define LOG_ENABLED() PR_LOG_TEST(sUserFontsLog, PR_LOG_DEBUG)
#define LOG(args) PR_LOG(GetUserFontsLog(), PR_LOG_DEBUG, args)
#define LOG_ENABLED() PR_LOG_TEST(GetUserFontsLog(), PR_LOG_DEBUG)
static uint64_t sFontSetGeneration = LL_INIT(0, 0);

View File

@ -276,7 +276,7 @@ protected:
uint64_t mGeneration;
static PRLogModuleInfo *sUserFontsLog;
static PRLogModuleInfo* GetUserFontsLog();
private:
static void CopyWOFFMetadata(const uint8_t* aFontData,

View File

@ -55,7 +55,15 @@ using namespace mozilla::services;
namespace mozilla {
namespace hal {
PRLogModuleInfo *sHalLog = PR_NewLogModule("hal");
PRLogModuleInfo *
GetHalLog()
{
static PRLogModuleInfo *sHalLog;
if (!sHalLog) {
sHalLog = PR_NewLogModule("hal");
}
return sHalLog;
}
namespace {

View File

@ -47,8 +47,8 @@ typedef Observer<ScreenConfiguration> ScreenConfigurationObserver;
class WindowIdentifier;
extern PRLogModuleInfo *sHalLog;
#define HAL_LOG(msg) PR_LOG(mozilla::hal::sHalLog, PR_LOG_DEBUG, msg)
extern PRLogModuleInfo *GetHalLog();
#define HAL_LOG(msg) PR_LOG(mozilla::hal::GetHalLog(), PR_LOG_DEBUG, msg)
typedef Observer<int64_t> SystemClockChangeObserver;
typedef Observer<SystemTimezoneChangeInformation> SystemTimezoneChangeObserver;

View File

@ -21,7 +21,14 @@ namespace mozilla {
namespace image {
#ifdef PR_LOGGING
PRLogModuleInfo *gBMPLog = PR_NewLogModule("BMPDecoder");
static PRLogModuleInfo *
GetBMPLog()
{
static PRLogModuleInfo *sBMPLog;
if (!sBMPLog)
sBMPLog = PR_NewLogModule("BMPDecoder");
return sBMPLog;
}
#endif
// Convert from row (1..height) to absolute line (0..height-1)
@ -221,7 +228,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
// we won't enter this condition again.
if (mPos == mLOH && GetFrameCount() == 0) {
ProcessInfoHeader();
PR_LOG(gBMPLog, PR_LOG_DEBUG, ("BMP is %lix%lix%lu. compression=%lu\n",
PR_LOG(GetBMPLog(), PR_LOG_DEBUG, ("BMP is %lix%lix%lu. compression=%lu\n",
mBIH.width, mBIH.height, mBIH.bpp, mBIH.compression));
// Verify we support this bit depth
if (mBIH.bpp != 1 && mBIH.bpp != 4 && mBIH.bpp != 8 &&
@ -283,20 +290,20 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
// If we have RLE4 or RLE8 or BI_ALPHABITFIELDS, then ensure we
// have valid BPP values before adding the frame
if (mBIH.compression == BI_RLE8 && mBIH.bpp != 8) {
PR_LOG(gBMPLog, PR_LOG_DEBUG,
PR_LOG(GetBMPLog(), PR_LOG_DEBUG,
("BMP RLE8 compression only supports 8 bits per pixel\n"));
PostDataError();
return;
}
if (mBIH.compression == BI_RLE4 && mBIH.bpp != 4 && mBIH.bpp != 1) {
PR_LOG(gBMPLog, PR_LOG_DEBUG,
PR_LOG(GetBMPLog(), PR_LOG_DEBUG,
("BMP RLE4 compression only supports 4 bits per pixel\n"));
PostDataError();
return;
}
if (mBIH.compression == BI_ALPHABITFIELDS &&
mBIH.bpp != 16 && mBIH.bpp != 32) {
PR_LOG(gBMPLog, PR_LOG_DEBUG,
PR_LOG(GetBMPLog(), PR_LOG_DEBUG,
("BMP ALPHABITFIELDS only supports 16 or 32 bits per pixel\n"));
PostDataError();
return;
@ -511,7 +518,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
else if ((mBIH.compression == BI_RLE8) || (mBIH.compression == BI_RLE4)) {
if (((mBIH.compression == BI_RLE8) && (mBIH.bpp != 8)) ||
((mBIH.compression == BI_RLE4) && (mBIH.bpp != 4) && (mBIH.bpp != 1))) {
PR_LOG(gBMPLog, PR_LOG_DEBUG, ("BMP RLE8/RLE4 compression only supports 8/4 bits per pixel\n"));
PR_LOG(GetBMPLog(), PR_LOG_DEBUG, ("BMP RLE8/RLE4 compression only supports 8/4 bits per pixel\n"));
PostDataError();
return;
}

View File

@ -35,11 +35,26 @@ namespace mozilla {
namespace image {
#if defined(PR_LOGGING)
PRLogModuleInfo *gJPEGlog = PR_NewLogModule("JPEGDecoder");
static PRLogModuleInfo *gJPEGDecoderAccountingLog = PR_NewLogModule("JPEGDecoderAccounting");
static PRLogModuleInfo *
GetJPEGLog()
{
static PRLogModuleInfo *sJPEGLog;
if (!sJPEGLog)
sJPEGLog = PR_NewLogModule("JPEGDecoder");
return sJPEGLog;
}
static PRLogModuleInfo *
GetJPEGDecoderAccountingLog()
{
static PRLogModuleInfo *sJPEGDecoderAccountingLog;
if (!sJPEGDecoderAccountingLog)
sJPEGDecoderAccountingLog = PR_NewLogModule("JPEGDecoderAccounting");
return sJPEGDecoderAccountingLog;
}
#else
#define gJPEGlog
#define gJPEGDecoderAccountingLog
#define GetJPEGLog()
#define GetJPEGDecoderAccountingLog()
#endif
static qcms_profile*
@ -90,7 +105,7 @@ nsJPEGDecoder::nsJPEGDecoder(RasterImage &aImage, imgIDecoderObserver* aObserver
mCMSMode = 0;
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("nsJPEGDecoder::nsJPEGDecoder: Creating JPEG decoder %p",
this));
}
@ -107,7 +122,7 @@ nsJPEGDecoder::~nsJPEGDecoder()
if (mInProfile)
qcms_profile_release(mInProfile);
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("nsJPEGDecoder::~nsJPEGDecoder: Destroying JPEG decoder %p",
this));
}
@ -190,7 +205,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
/* Error due to corrupt stream - return NS_OK and consume silently
so that libpr0n doesn't throw away a partial image load */
mState = JPEG_SINK_NON_JPEG_TRAILER;
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (setjmp returned NS_ERROR_FAILURE)"));
return;
} else {
@ -199,23 +214,23 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
mozilla is seconds away from falling flat on its face. */
PostDecoderError(error_code);
mState = JPEG_ERROR;
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (setjmp returned an error)"));
return;
}
}
PR_LOG(gJPEGlog, PR_LOG_DEBUG,
PR_LOG(GetJPEGLog(), PR_LOG_DEBUG,
("[this=%p] nsJPEGDecoder::Write -- processing JPEG data\n", this));
switch (mState) {
case JPEG_HEADER:
{
LOG_SCOPE(gJPEGlog, "nsJPEGDecoder::Write -- entering JPEG_HEADER case");
LOG_SCOPE(GetJPEGLog(), "nsJPEGDecoder::Write -- entering JPEG_HEADER case");
/* Step 3: read file parameters with jpeg_read_header() */
if (jpeg_read_header(&mInfo, TRUE) == JPEG_SUSPENDED) {
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (JPEG_SUSPENDED)"));
return; /* I/O suspension */
}
@ -267,7 +282,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
default:
mState = JPEG_ERROR;
PostDataError();
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (unknown colorpsace (1))"));
return;
}
@ -284,7 +299,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
default:
mState = JPEG_ERROR;
PostDataError();
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (unknown colorpsace (2))"));
return;
}
@ -341,7 +356,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
default:
mState = JPEG_ERROR;
PostDataError();
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (unknown colorpsace (3))"));
return;
break;
@ -363,12 +378,12 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
&mImageData, &imagelength))) {
mState = JPEG_ERROR;
PostDecoderError(NS_ERROR_OUT_OF_MEMORY);
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (could not initialize image frame)"));
return;
}
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
(" JPEGDecoderAccounting: nsJPEGDecoder::Write -- created image frame with %ux%u pixels",
mInfo.image_width, mInfo.image_height));
@ -380,7 +395,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
case JPEG_START_DECOMPRESS:
{
LOG_SCOPE(gJPEGlog, "nsJPEGDecoder::Write -- entering JPEG_START_DECOMPRESS case");
LOG_SCOPE(GetJPEGLog(), "nsJPEGDecoder::Write -- entering JPEG_START_DECOMPRESS case");
/* Step 4: set parameters for decompression */
/* FIXME -- Should reset dct_method and dither mode
@ -394,7 +409,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
/* Step 5: Start decompressor */
if (jpeg_start_decompress(&mInfo) == FALSE) {
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (I/O suspension after jpeg_start_decompress())"));
return; /* I/O suspension */
}
@ -408,13 +423,13 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
{
if (mState == JPEG_DECOMPRESS_SEQUENTIAL)
{
LOG_SCOPE(gJPEGlog, "nsJPEGDecoder::Write -- JPEG_DECOMPRESS_SEQUENTIAL case");
LOG_SCOPE(GetJPEGLog(), "nsJPEGDecoder::Write -- JPEG_DECOMPRESS_SEQUENTIAL case");
bool suspend;
OutputScanlines(&suspend);
if (suspend) {
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (I/O suspension after OutputScanlines() - SEQUENTIAL)"));
return; /* I/O suspension */
}
@ -429,7 +444,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
{
if (mState == JPEG_DECOMPRESS_PROGRESSIVE)
{
LOG_SCOPE(gJPEGlog, "nsJPEGDecoder::Write -- JPEG_DECOMPRESS_PROGRESSIVE case");
LOG_SCOPE(GetJPEGLog(), "nsJPEGDecoder::Write -- JPEG_DECOMPRESS_PROGRESSIVE case");
int status;
do {
@ -450,7 +465,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
scan--;
if (!jpeg_start_output(&mInfo, scan)) {
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (I/O suspension after jpeg_start_output() - PROGRESSIVE)"));
return; /* I/O suspension */
}
@ -468,7 +483,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
jpeg_start_output() multiple times for the same scan */
mInfo.output_scanline = 0xffffff;
}
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (I/O suspension after OutputScanlines() - PROGRESSIVE)"));
return; /* I/O suspension */
}
@ -476,7 +491,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
if (mInfo.output_scanline == mInfo.output_height)
{
if (!jpeg_finish_output(&mInfo)) {
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (I/O suspension after jpeg_finish_output() - PROGRESSIVE)"));
return; /* I/O suspension */
}
@ -495,12 +510,12 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
case JPEG_DONE:
{
LOG_SCOPE(gJPEGlog, "nsJPEGDecoder::ProcessData -- entering JPEG_DONE case");
LOG_SCOPE(GetJPEGLog(), "nsJPEGDecoder::ProcessData -- entering JPEG_DONE case");
/* Step 7: Finish decompression */
if (jpeg_finish_decompress(&mInfo) == FALSE) {
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (I/O suspension after jpeg_finish_decompress() - DONE)"));
return; /* I/O suspension */
}
@ -511,7 +526,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
break;
}
case JPEG_SINK_NON_JPEG_TRAILER:
PR_LOG(gJPEGlog, PR_LOG_DEBUG,
PR_LOG(GetJPEGLog(), PR_LOG_DEBUG,
("[this=%p] nsJPEGDecoder::ProcessData -- entering JPEG_SINK_NON_JPEG_TRAILER case\n", this));
break;
@ -520,7 +535,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
NS_ABORT_IF_FALSE(0, "Should always return immediately after error and not re-enter decoder");
}
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetJPEGDecoderAccountingLog(), PR_LOG_DEBUG,
("} (end of function)"));
return;
}

View File

@ -27,9 +27,23 @@ namespace mozilla {
namespace image {
#ifdef PR_LOGGING
static PRLogModuleInfo *gPNGLog = PR_NewLogModule("PNGDecoder");
static PRLogModuleInfo *gPNGDecoderAccountingLog =
PR_NewLogModule("PNGDecoderAccounting");
static PRLogModuleInfo *
GetPNGLog()
{
static PRLogModuleInfo *sPNGLog;
if (!sPNGLog)
sPNGLog = PR_NewLogModule("PNGDecoder");
return sPNGLog;
}
static PRLogModuleInfo *
GetPNGDecoderAccountingLog()
{
static PRLogModuleInfo *sPNGDecoderAccountingLog;
if (!sPNGDecoderAccountingLog)
sPNGDecoderAccountingLog = PR_NewLogModule("PNGDecoderAccounting");
return sPNGDecoderAccountingLog;
}
#endif
/* limit image dimensions (bug #251381) */
@ -99,7 +113,7 @@ void nsPNGDecoder::CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset,
// Tell the superclass we're starting a frame
PostFrameStart();
PR_LOG(gPNGDecoderAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetPNGDecoderAccountingLog(), PR_LOG_DEBUG,
("PNGDecoderAccounting: nsPNGDecoder::CreateFrame -- created "
"image frame with %dx%d pixels in container %p",
width, height,
@ -849,7 +863,7 @@ nsPNGDecoder::end_callback(png_structp png_ptr, png_infop info_ptr)
void
nsPNGDecoder::error_callback(png_structp png_ptr, png_const_charp error_msg)
{
PR_LOG(gPNGLog, PR_LOG_ERROR, ("libpng error: %s\n", error_msg));
PR_LOG(GetPNGLog(), PR_LOG_ERROR, ("libpng error: %s\n", error_msg));
longjmp(png_jmpbuf(png_ptr), 1);
}
@ -857,7 +871,7 @@ nsPNGDecoder::error_callback(png_structp png_ptr, png_const_charp error_msg)
void
nsPNGDecoder::warning_callback(png_structp png_ptr, png_const_charp warning_msg)
{
PR_LOG(gPNGLog, PR_LOG_WARNING, ("libpng warning: %s\n", warning_msg));
PR_LOG(GetPNGLog(), PR_LOG_WARNING, ("libpng warning: %s\n", warning_msg));
}
Telemetry::ID

View File

@ -23,7 +23,7 @@
#if defined(PR_LOGGING)
// Declared in imgRequest.cpp.
extern PRLogModuleInfo *gImgLog;
extern PRLogModuleInfo *GetImgLog();
#define GIVE_ME_MS_NOW() PR_IntervalToMilliseconds(PR_IntervalNow())

View File

@ -47,9 +47,16 @@ using namespace mozilla::layers;
/* Accounting for compressed data */
#if defined(PR_LOGGING)
static PRLogModuleInfo *gCompressedImageAccountingLog = PR_NewLogModule ("CompressedImageAccounting");
static PRLogModuleInfo *
GetCompressedImageAccountingLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("CompressedImageAccounting");
return sLog;
}
#else
#define gCompressedImageAccountingLog
#define GetCompressedImageAccountingLog()
#endif
// Tweakable progressive decoding parameters. These are initialized to 0 here
@ -91,7 +98,7 @@ InitPrefCaches()
*/
#define LOG_CONTAINER_ERROR \
PR_BEGIN_MACRO \
PR_LOG (gImgLog, PR_LOG_ERROR, \
PR_LOG (GetImgLog(), PR_LOG_ERROR, \
("RasterImage: [this=%p] Error " \
"detected at line %u for image of " \
"type %s\n", this, __LINE__, \
@ -387,7 +394,7 @@ RasterImage::~RasterImage()
num_discardable_containers--;
discardable_source_bytes -= mSourceData.Length();
PR_LOG (gCompressedImageAccountingLog, PR_LOG_DEBUG,
PR_LOG (GetCompressedImageAccountingLog(), PR_LOG_DEBUG,
("CompressedImageAccounting: destroying RasterImage %p. "
"Total Containers: %d, Discardable containers: %d, "
"Total source bytes: %lld, Source bytes for discardable containers %lld",
@ -1742,7 +1749,7 @@ RasterImage::AddSourceData(const char *aBuffer, uint32_t aCount)
total_source_bytes += aCount;
if (mDiscardable)
discardable_source_bytes += aCount;
PR_LOG (gCompressedImageAccountingLog, PR_LOG_DEBUG,
PR_LOG (GetCompressedImageAccountingLog(), PR_LOG_DEBUG,
("CompressedImageAccounting: Added compressed data to RasterImage %p (%s). "
"Total Containers: %d, Discardable containers: %d, "
"Total source bytes: %lld, Source bytes for discardable containers %lld",
@ -1816,10 +1823,10 @@ RasterImage::SourceDataComplete()
mSourceData.Compact();
// Log header information
if (PR_LOG_TEST(gCompressedImageAccountingLog, PR_LOG_DEBUG)) {
if (PR_LOG_TEST(GetCompressedImageAccountingLog(), PR_LOG_DEBUG)) {
char buf[9];
get_header_str(buf, mSourceData.Elements(), mSourceData.Length());
PR_LOG (gCompressedImageAccountingLog, PR_LOG_DEBUG,
PR_LOG (GetCompressedImageAccountingLog(), PR_LOG_DEBUG,
("CompressedImageAccounting: RasterImage::SourceDataComplete() - data "
"is done for container %p (%s) - header %p is 0x%s (length %d)",
this,
@ -2427,7 +2434,7 @@ RasterImage::Discard(bool force)
DiscardTracker::Remove(&mDiscardTrackerNode);
// Log
PR_LOG(gCompressedImageAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetCompressedImageAccountingLog(), PR_LOG_DEBUG,
("CompressedImageAccounting: discarded uncompressed image "
"data from RasterImage %p (%s) - %d frames (cached count: %d); "
"Total Containers: %d, Discardable containers: %d, "
@ -3083,7 +3090,7 @@ RasterImage::UnlockImage()
// we've decoded.
if (mHasBeenDecoded && mDecoder &&
mLockCount == 0 && CanForciblyDiscard()) {
PR_LOG(gCompressedImageAccountingLog, PR_LOG_DEBUG,
PR_LOG(GetCompressedImageAccountingLog(), PR_LOG_DEBUG,
("RasterImage[0x%p] canceling decode because image "
"is now unlocked.", this));
ShutdownDecoder(eShutdownIntent_Interrupted);

View File

@ -545,12 +545,12 @@ imgCacheEntry::imgCacheEntry(imgLoader* loader, imgRequest *request, bool forceP
imgCacheEntry::~imgCacheEntry()
{
LOG_FUNC(gImgLog, "imgCacheEntry::~imgCacheEntry()");
LOG_FUNC(GetImgLog(), "imgCacheEntry::~imgCacheEntry()");
}
void imgCacheEntry::Touch(bool updateTime /* = true */)
{
LOG_SCOPE(gImgLog, "imgCacheEntry::Touch");
LOG_SCOPE(GetImgLog(), "imgCacheEntry::Touch");
if (updateTime)
mTouchedTime = SecondsFromPRTime(PR_Now());
@ -578,9 +578,9 @@ void imgCacheEntry::SetHasNoProxies(bool hasNoProxies)
if (uri)
uri->GetSpec(spec);
if (hasNoProxies)
LOG_FUNC_WITH_PARAM(gImgLog, "imgCacheEntry::SetHasNoProxies true", "uri", spec.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgCacheEntry::SetHasNoProxies true", "uri", spec.get());
else
LOG_FUNC_WITH_PARAM(gImgLog, "imgCacheEntry::SetHasNoProxies false", "uri", spec.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgCacheEntry::SetHasNoProxies false", "uri", spec.get());
#endif
mHasNoProxies = hasNoProxies;
@ -684,7 +684,7 @@ nsresult imgLoader::CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup
nsLoadFlags aLoadFlags, imgIRequest *aProxyRequest,
imgIRequest **_retval)
{
LOG_SCOPE_WITH_PARAM(gImgLog, "imgLoader::CreateNewProxyForRequest", "imgRequest", aRequest);
LOG_SCOPE_WITH_PARAM(GetImgLog(), "imgLoader::CreateNewProxyForRequest", "imgRequest", aRequest);
/* XXX If we move decoding onto separate threads, we should save off the
calling thread here and pass it off to |proxyRequest| so that it call
@ -766,7 +766,7 @@ void imgCacheExpirationTracker::NotifyExpired(imgCacheEntry *entry)
req->GetURI(getter_AddRefs(uri));
nsAutoCString spec;
uri->GetSpec(spec);
LOG_FUNC_WITH_PARAM(gImgLog, "imgCacheExpirationTracker::NotifyExpired", "entry", spec.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgCacheExpirationTracker::NotifyExpired", "entry", spec.get());
}
#endif
@ -1016,25 +1016,25 @@ bool imgLoader::PutIntoCache(nsIURI *key, imgCacheEntry *entry)
nsAutoCString spec;
key->GetSpec(spec);
LOG_STATIC_FUNC_WITH_PARAM(gImgLog, "imgLoader::PutIntoCache", "uri", spec.get());
LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(), "imgLoader::PutIntoCache", "uri", spec.get());
// Check to see if this request already exists in the cache and is being
// loaded on a different thread. If so, don't allow this entry to be added to
// the cache.
nsRefPtr<imgCacheEntry> tmpCacheEntry;
if (cache.Get(spec, getter_AddRefs(tmpCacheEntry)) && tmpCacheEntry) {
PR_LOG(gImgLog, PR_LOG_DEBUG,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("[this=%p] imgLoader::PutIntoCache -- Element already in the cache", nullptr));
nsRefPtr<imgRequest> tmpRequest = getter_AddRefs(tmpCacheEntry->GetRequest());
// If it already exists, and we're putting the same key into the cache, we
// should remove the old version.
PR_LOG(gImgLog, PR_LOG_DEBUG,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("[this=%p] imgLoader::PutIntoCache -- Replacing cached element", nullptr));
RemoveFromCache(key);
} else {
PR_LOG(gImgLog, PR_LOG_DEBUG,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("[this=%p] imgLoader::PutIntoCache -- Element NOT already in the cache", nullptr));
}
@ -1070,7 +1070,7 @@ bool imgLoader::SetHasNoProxies(nsIURI *key, imgCacheEntry *entry)
nsAutoCString spec;
key->GetSpec(spec);
LOG_STATIC_FUNC_WITH_PARAM(gImgLog, "imgLoader::SetHasNoProxies", "uri", spec.get());
LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(), "imgLoader::SetHasNoProxies", "uri", spec.get());
#endif
if (entry->Evicted())
@ -1103,7 +1103,7 @@ bool imgLoader::SetHasProxies(nsIURI *key)
nsAutoCString spec;
key->GetSpec(spec);
LOG_STATIC_FUNC_WITH_PARAM(gImgLog, "imgLoader::SetHasProxies", "uri", spec.get());
LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(), "imgLoader::SetHasProxies", "uri", spec.get());
nsRefPtr<imgCacheEntry> entry;
if (cache.Get(spec, getter_AddRefs(entry)) && entry && entry->HasNoProxies()) {
@ -1148,7 +1148,7 @@ void imgLoader::CheckCacheLimits(imgCacheTable &cache, imgCacheQueue &queue)
req->GetURI(getter_AddRefs(uri));
nsAutoCString spec;
uri->GetSpec(spec);
LOG_STATIC_FUNC_WITH_PARAM(gImgLog, "imgLoader::CheckCacheLimits", "entry", spec.get());
LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(), "imgLoader::CheckCacheLimits", "entry", spec.get());
}
#endif
@ -1294,7 +1294,7 @@ bool imgLoader::ValidateEntry(imgCacheEntry *aEntry,
nsIPrincipal* aLoadingPrincipal,
int32_t aCORSMode)
{
LOG_SCOPE(gImgLog, "imgLoader::ValidateEntry");
LOG_SCOPE(GetImgLog(), "imgLoader::ValidateEntry");
bool hasExpired;
uint32_t expirationTime = aEntry->GetExpiryTime();
@ -1351,7 +1351,7 @@ bool imgLoader::ValidateEntry(imgCacheEntry *aEntry,
// Determine whether the cache aEntry must be revalidated...
validateRequest = ShouldRevalidateEntry(aEntry, aLoadFlags, hasExpired);
PR_LOG(gImgLog, PR_LOG_DEBUG,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("imgLoader::ValidateEntry validating cache entry. "
"validateRequest = %d", validateRequest));
}
@ -1360,7 +1360,7 @@ bool imgLoader::ValidateEntry(imgCacheEntry *aEntry,
nsAutoCString spec;
aURI->GetSpec(spec);
PR_LOG(gImgLog, PR_LOG_DEBUG,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("imgLoader::ValidateEntry BYPASSING cache validation for %s "
"because of NULL LoadID", spec.get()));
}
@ -1377,7 +1377,7 @@ bool imgLoader::ValidateEntry(imgCacheEntry *aEntry,
appCacheContainer->GetApplicationCache(getter_AddRefs(groupAppCache));
if (requestAppCache != groupAppCache) {
PR_LOG(gImgLog, PR_LOG_DEBUG,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("imgLoader::ValidateEntry - Unable to use cached imgRequest "
"[request=%p] because of mismatched application caches\n",
address_of(request)));
@ -1385,7 +1385,7 @@ bool imgLoader::ValidateEntry(imgCacheEntry *aEntry,
}
if (validateRequest && aCanMakeNewChannel) {
LOG_SCOPE(gImgLog, "imgLoader::ValidateRequest |cache hit| must validate");
LOG_SCOPE(GetImgLog(), "imgLoader::ValidateRequest |cache hit| must validate");
return ValidateRequestWithNewChannel(request, aURI, aInitialDocumentURI,
aReferrerURI, aLoadGroup, aObserver,
@ -1408,7 +1408,7 @@ bool imgLoader::RemoveFromCache(nsIURI *aKey)
nsAutoCString spec;
aKey->GetSpec(spec);
LOG_STATIC_FUNC_WITH_PARAM(gImgLog, "imgLoader::RemoveFromCache", "uri", spec.get());
LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(), "imgLoader::RemoveFromCache", "uri", spec.get());
nsRefPtr<imgCacheEntry> entry;
if (cache.Get(spec, getter_AddRefs(entry)) && entry) {
@ -1436,7 +1436,7 @@ bool imgLoader::RemoveFromCache(nsIURI *aKey)
bool imgLoader::RemoveFromCache(imgCacheEntry *entry)
{
LOG_STATIC_FUNC(gImgLog, "imgLoader::RemoveFromCache entry");
LOG_STATIC_FUNC(GetImgLog(), "imgLoader::RemoveFromCache entry");
nsRefPtr<imgRequest> request(getter_AddRefs(entry->GetRequest()));
if (request) {
@ -1447,12 +1447,12 @@ bool imgLoader::RemoveFromCache(imgCacheEntry *entry)
nsAutoCString spec;
key->GetSpec(spec);
LOG_STATIC_FUNC_WITH_PARAM(gImgLog, "imgLoader::RemoveFromCache", "entry's uri", spec.get());
LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(), "imgLoader::RemoveFromCache", "entry's uri", spec.get());
cache.Remove(spec);
if (entry->HasNoProxies()) {
LOG_STATIC_FUNC(gImgLog, "imgLoader::RemoveFromCache removing from tracker");
LOG_STATIC_FUNC(GetImgLog(), "imgLoader::RemoveFromCache removing from tracker");
if (mCacheTracker)
mCacheTracker->RemoveObject(entry);
queue.Remove(entry);
@ -1482,7 +1482,7 @@ static PLDHashOperator EnumEvictEntries(const nsACString&,
nsresult imgLoader::EvictEntries(imgCacheTable &aCacheToClear)
{
LOG_STATIC_FUNC(gImgLog, "imgLoader::EvictEntries table");
LOG_STATIC_FUNC(GetImgLog(), "imgLoader::EvictEntries table");
// We have to make a temporary, since RemoveFromCache removes the element
// from the queue, invalidating iterators.
@ -1498,7 +1498,7 @@ nsresult imgLoader::EvictEntries(imgCacheTable &aCacheToClear)
nsresult imgLoader::EvictEntries(imgCacheQueue &aQueueToClear)
{
LOG_STATIC_FUNC(gImgLog, "imgLoader::EvictEntries queue");
LOG_STATIC_FUNC(GetImgLog(), "imgLoader::EvictEntries queue");
// We have to make a temporary, since RemoveFromCache removes the element
// from the queue, invalidating iterators.
@ -1545,7 +1545,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
nsAutoCString spec;
aURI->GetSpec(spec);
LOG_SCOPE_WITH_PARAM(gImgLog, "imgLoader::LoadImage", "aURI", spec.get());
LOG_SCOPE_WITH_PARAM(GetImgLog(), "imgLoader::LoadImage", "aURI", spec.get());
*_retval = nullptr;
@ -1620,7 +1620,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
// If this entry has no proxies, its request has no reference to the entry.
if (entry->HasNoProxies()) {
LOG_FUNC_WITH_PARAM(gImgLog, "imgLoader::LoadImage() adding proxyless entry", "uri", spec.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgLoader::LoadImage() adding proxyless entry", "uri", spec.get());
NS_ABORT_IF_FALSE(!request->HasCacheEntry(), "Proxyless entry's request has cache entry!");
request->SetCacheEntry(entry);
@ -1646,7 +1646,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
nsCOMPtr<nsIChannel> newChannel;
// If we didn't get a cache hit, we need to load from the network.
if (!request) {
LOG_SCOPE(gImgLog, "imgLoader::LoadImage |cache miss|");
LOG_SCOPE(GetImgLog(), "imgLoader::LoadImage |cache miss|");
bool forcePrincipalCheck;
rv = NewImageChannel(getter_AddRefs(newChannel),
@ -1666,7 +1666,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
NewRequestAndEntry(forcePrincipalCheck, this, getter_AddRefs(request), getter_AddRefs(entry));
PR_LOG(gImgLog, PR_LOG_DEBUG,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("[this=%p] imgLoader::LoadImage -- Created new imgRequest [request=%p]\n", this, request.get()));
// Create a loadgroup for this new channel. This way if the channel
@ -1691,7 +1691,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
// request.
nsCOMPtr<nsIStreamListener> listener = pl;
if (corsmode != imgIRequest::CORS_NONE) {
PR_LOG(gImgLog, PR_LOG_DEBUG,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("[this=%p] imgLoader::LoadImage -- Setting up a CORS load",
this));
bool withCredentials = corsmode == imgIRequest::CORS_USE_CREDENTIALS;
@ -1700,7 +1700,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
new nsCORSListenerProxy(pl, aLoadingPrincipal, withCredentials);
rv = corsproxy->Init(newChannel);
if (NS_FAILED(rv)) {
PR_LOG(gImgLog, PR_LOG_DEBUG,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("[this=%p] imgLoader::LoadImage -- nsCORSListenerProxy "
"creation failed: 0x%x\n", this, rv));
request->CancelAndAbort(rv);
@ -1710,13 +1710,13 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
listener = corsproxy;
}
PR_LOG(gImgLog, PR_LOG_DEBUG,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("[this=%p] imgLoader::LoadImage -- Calling channel->AsyncOpen()\n", this));
nsresult openRes = newChannel->AsyncOpen(listener, nullptr);
if (NS_FAILED(openRes)) {
PR_LOG(gImgLog, PR_LOG_DEBUG,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("[this=%p] imgLoader::LoadImage -- AsyncOpen() failed: 0x%x\n",
this, openRes));
request->CancelAndAbort(openRes);
@ -1726,7 +1726,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
// Try to add the new request into the cache.
PutIntoCache(aURI, entry);
} else {
LOG_MSG_WITH_PARAM(gImgLog,
LOG_MSG_WITH_PARAM(GetImgLog(),
"imgLoader::LoadImage |cache hit|", "request", request);
}
@ -1744,7 +1744,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI,
// that'll cause us to validate over the network.
request->SetLoadId(aCX);
LOG_MSG(gImgLog, "imgLoader::LoadImage", "creating proxy request.");
LOG_MSG(GetImgLog(), "imgLoader::LoadImage", "creating proxy request.");
rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver,
requestFlags, aRequest, _retval);
if (NS_FAILED(rv)) {
@ -1844,7 +1844,7 @@ NS_IMETHODIMP imgLoader::LoadImageWithChannel(nsIChannel *channel, imgINotificat
if (request && entry) {
// If this entry has no proxies, its request has no reference to the entry.
if (entry->HasNoProxies()) {
LOG_FUNC_WITH_PARAM(gImgLog, "imgLoader::LoadImageWithChannel() adding proxyless entry", "uri", spec.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgLoader::LoadImageWithChannel() adding proxyless entry", "uri", spec.get());
NS_ABORT_IF_FALSE(!request->HasCacheEntry(), "Proxyless entry's request has cache entry!");
request->SetCacheEntry(entry);
@ -2176,7 +2176,7 @@ NS_IMETHODIMP imgCacheValidator::OnStartRequest(nsIRequest *aRequest, nsISupport
#if defined(PR_LOGGING)
nsAutoCString spec;
uri->GetSpec(spec);
LOG_MSG_WITH_PARAM(gImgLog, "imgCacheValidator::OnStartRequest creating new request", "uri", spec.get());
LOG_MSG_WITH_PARAM(GetImgLog(), "imgCacheValidator::OnStartRequest creating new request", "uri", spec.get());
#endif
int32_t corsmode = mRequest->GetCORSMode();

View File

@ -69,7 +69,14 @@ InitPrefCaches()
}
#if defined(PR_LOGGING)
PRLogModuleInfo *gImgLog = PR_NewLogModule("imgRequest");
PRLogModuleInfo *
GetImgLog()
{
static PRLogModuleInfo *sImgLog;
if (!sImgLog)
sImgLog = PR_NewLogModule("imgRequest");
return sImgLog;
}
#endif
NS_IMPL_ISUPPORTS5(imgRequest,
@ -102,9 +109,9 @@ imgRequest::~imgRequest()
if (mURI) {
nsAutoCString spec;
mURI->GetSpec(spec);
LOG_FUNC_WITH_PARAM(gImgLog, "imgRequest::~imgRequest()", "keyuri", spec.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequest::~imgRequest()", "keyuri", spec.get());
} else
LOG_FUNC(gImgLog, "imgRequest::~imgRequest()");
LOG_FUNC(GetImgLog(), "imgRequest::~imgRequest()");
}
nsresult imgRequest::Init(nsIURI *aURI,
@ -116,7 +123,7 @@ nsresult imgRequest::Init(nsIURI *aURI,
nsIPrincipal* aLoadingPrincipal,
int32_t aCORSMode)
{
LOG_FUNC(gImgLog, "imgRequest::Init");
LOG_FUNC(GetImgLog(), "imgRequest::Init");
NS_ABORT_IF_FALSE(!mImage, "Multiple calls to init");
NS_ABORT_IF_FALSE(aURI, "No uri");
@ -183,7 +190,7 @@ void imgRequest::ResetCacheEntry()
void imgRequest::AddProxy(imgRequestProxy *proxy)
{
NS_PRECONDITION(proxy, "null imgRequestProxy passed in");
LOG_SCOPE_WITH_PARAM(gImgLog, "imgRequest::AddProxy", "proxy", proxy);
LOG_SCOPE_WITH_PARAM(GetImgLog(), "imgRequest::AddProxy", "proxy", proxy);
// If we're empty before adding, we have to tell the loader we now have
// proxies.
@ -197,7 +204,7 @@ void imgRequest::AddProxy(imgRequestProxy *proxy)
nsresult imgRequest::RemoveProxy(imgRequestProxy *proxy, nsresult aStatus)
{
LOG_SCOPE_WITH_PARAM(gImgLog, "imgRequest::RemoveProxy", "proxy", proxy);
LOG_SCOPE_WITH_PARAM(GetImgLog(), "imgRequest::RemoveProxy", "proxy", proxy);
// This will remove our animation consumers, so after removing
// this proxy, we don't end up without proxies with observers, but still
@ -225,7 +232,7 @@ nsresult imgRequest::RemoveProxy(imgRequestProxy *proxy, nsresult aStatus)
else {
nsAutoCString spec;
mURI->GetSpec(spec);
LOG_MSG_WITH_PARAM(gImgLog, "imgRequest::RemoveProxy no cache entry", "uri", spec.get());
LOG_MSG_WITH_PARAM(GetImgLog(), "imgRequest::RemoveProxy no cache entry", "uri", spec.get());
}
#endif
@ -235,7 +242,7 @@ nsresult imgRequest::RemoveProxy(imgRequestProxy *proxy, nsresult aStatus)
and won't leave a bad pointer in the observer list.
*/
if (statusTracker.IsLoading() && NS_FAILED(aStatus)) {
LOG_MSG(gImgLog, "imgRequest::RemoveProxy", "load in progress. canceling");
LOG_MSG(GetImgLog(), "imgRequest::RemoveProxy", "load in progress. canceling");
this->Cancel(NS_BINDING_ABORTED);
}
@ -254,7 +261,7 @@ nsresult imgRequest::RemoveProxy(imgRequestProxy *proxy, nsresult aStatus)
void imgRequest::CancelAndAbort(nsresult aStatus)
{
LOG_SCOPE(gImgLog, "imgRequest::CancelAndAbort");
LOG_SCOPE(GetImgLog(), "imgRequest::CancelAndAbort");
Cancel(aStatus);
@ -271,7 +278,7 @@ void imgRequest::Cancel(nsresult aStatus)
{
/* The Cancel() method here should only be called by this class. */
LOG_SCOPE(gImgLog, "imgRequest::Cancel");
LOG_SCOPE(GetImgLog(), "imgRequest::Cancel");
imgStatusTracker& statusTracker = GetStatusTracker();
@ -287,7 +294,7 @@ void imgRequest::Cancel(nsresult aStatus)
nsresult imgRequest::GetURI(nsIURI **aURI)
{
LOG_FUNC(gImgLog, "imgRequest::GetURI");
LOG_FUNC(GetImgLog(), "imgRequest::GetURI");
if (mURI) {
*aURI = mURI;
@ -300,7 +307,7 @@ nsresult imgRequest::GetURI(nsIURI **aURI)
nsresult imgRequest::GetSecurityInfo(nsISupports **aSecurityInfo)
{
LOG_FUNC(gImgLog, "imgRequest::GetSecurityInfo");
LOG_FUNC(GetImgLog(), "imgRequest::GetSecurityInfo");
// Missing security info means this is not a security load
// i.e. it is not an error when security info is missing
@ -310,7 +317,7 @@ nsresult imgRequest::GetSecurityInfo(nsISupports **aSecurityInfo)
void imgRequest::RemoveFromCache()
{
LOG_SCOPE(gImgLog, "imgRequest::RemoveFromCache");
LOG_SCOPE(GetImgLog(), "imgRequest::RemoveFromCache");
if (mIsInCache) {
// mCacheEntry is nulled out when we have no more observers.
@ -351,7 +358,7 @@ void imgRequest::AdjustPriority(imgRequestProxy *proxy, int32_t delta)
void imgRequest::SetIsInCache(bool incache)
{
LOG_FUNC_WITH_PARAM(gImgLog, "imgRequest::SetIsCacheable", "incache", incache);
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequest::SetIsCacheable", "incache", incache);
mIsInCache = incache;
}
@ -478,7 +485,7 @@ imgRequest::StartDecoding()
/* void onStartRequest (in nsIRequest request, in nsISupports ctxt); */
NS_IMETHODIMP imgRequest::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt)
{
LOG_SCOPE(gImgLog, "imgRequest::OnStartRequest");
LOG_SCOPE(GetImgLog(), "imgRequest::OnStartRequest");
// Figure out if we're multipart
nsCOMPtr<nsIMultiPartChannel> mpchan(do_QueryInterface(aRequest));
@ -551,7 +558,7 @@ NS_IMETHODIMP imgRequest::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt
/* void onStopRequest (in nsIRequest request, in nsISupports ctxt, in nsresult status); */
NS_IMETHODIMP imgRequest::OnStopRequest(nsIRequest *aRequest, nsISupports *ctxt, nsresult status)
{
LOG_FUNC(gImgLog, "imgRequest::OnStopRequest");
LOG_FUNC(GetImgLog(), "imgRequest::OnStopRequest");
bool lastPart = true;
nsCOMPtr<nsIMultiPartChannel> mpchan(do_QueryInterface(aRequest));
@ -635,14 +642,14 @@ imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt,
nsIInputStream *inStr, uint64_t sourceOffset,
uint32_t count)
{
LOG_SCOPE_WITH_PARAM(gImgLog, "imgRequest::OnDataAvailable", "count", count);
LOG_SCOPE_WITH_PARAM(GetImgLog(), "imgRequest::OnDataAvailable", "count", count);
NS_ASSERTION(aRequest, "imgRequest::OnDataAvailable -- no request!");
nsresult rv;
if (!mGotData || mResniffMimeType) {
LOG_SCOPE(gImgLog, "imgRequest::OnDataAvailable |First time through... finding mimetype|");
LOG_SCOPE(GetImgLog(), "imgRequest::OnDataAvailable |First time through... finding mimetype|");
mGotData = true;
@ -663,7 +670,7 @@ imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt,
nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
if (newType.IsEmpty()) {
LOG_SCOPE(gImgLog, "imgRequest::OnDataAvailable |sniffing of mimetype failed|");
LOG_SCOPE(GetImgLog(), "imgRequest::OnDataAvailable |sniffing of mimetype failed|");
rv = NS_ERROR_FAILURE;
if (chan) {
@ -671,7 +678,7 @@ imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt,
}
if (NS_FAILED(rv)) {
PR_LOG(gImgLog, PR_LOG_ERROR,
PR_LOG(GetImgLog(), PR_LOG_ERROR,
("[this=%p] imgRequest::OnDataAvailable -- Content type unavailable from the channel\n",
this));
@ -680,7 +687,7 @@ imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt,
return NS_BINDING_ABORTED;
}
LOG_MSG(gImgLog, "imgRequest::OnDataAvailable", "Got content type from the channel");
LOG_MSG(GetImgLog(), "imgRequest::OnDataAvailable", "Got content type from the channel");
}
// If we're a regular image and this is the first call to OnDataAvailable,
@ -734,7 +741,7 @@ imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt,
}
}
LOG_MSG_WITH_PARAM(gImgLog, "imgRequest::OnDataAvailable", "content type", mContentType.get());
LOG_MSG_WITH_PARAM(GetImgLog(), "imgRequest::OnDataAvailable", "content type", mContentType.get());
//
// Figure out our Image initialization flags
@ -852,7 +859,7 @@ imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt,
sourceOffset, count);
}
if (NS_FAILED(rv)) {
PR_LOG(gImgLog, PR_LOG_WARNING,
PR_LOG(GetImgLog(), PR_LOG_WARNING,
("[this=%p] imgRequest::OnDataAvailable -- "
"copy to RasterImage failed\n", this));
this->Cancel(NS_IMAGELIB_ERROR_FAILURE);
@ -970,7 +977,7 @@ imgRequest::OnRedirectVerifyCallback(nsresult result)
nsAutoCString oldspec;
if (mCurrentURI)
mCurrentURI->GetSpec(oldspec);
LOG_MSG_WITH_PARAM(gImgLog, "imgRequest::OnChannelRedirect", "old", oldspec.get());
LOG_MSG_WITH_PARAM(GetImgLog(), "imgRequest::OnChannelRedirect", "old", oldspec.get());
#endif
// make sure we have a protocol that returns data rather than opens

View File

@ -91,7 +91,7 @@ nsresult imgRequestProxy::Init(imgStatusTracker* aStatusTracker,
{
NS_PRECONDITION(!mOwner && !mListener, "imgRequestProxy is already initialized");
LOG_SCOPE_WITH_PARAM(gImgLog, "imgRequestProxy::Init", "request", aStatusTracker->GetRequest());
LOG_SCOPE_WITH_PARAM(GetImgLog(), "imgRequestProxy::Init", "request", aStatusTracker->GetRequest());
NS_ABORT_IF_FALSE(mAnimationConsumers == 0, "Cannot have animation before Init");
@ -230,7 +230,7 @@ NS_IMETHODIMP imgRequestProxy::Cancel(nsresult status)
if (mCanceled)
return NS_ERROR_FAILURE;
LOG_SCOPE(gImgLog, "imgRequestProxy::Cancel");
LOG_SCOPE(GetImgLog(), "imgRequestProxy::Cancel");
mCanceled = true;
@ -260,7 +260,7 @@ NS_IMETHODIMP imgRequestProxy::CancelAndForgetObserver(nsresult aStatus)
if (mCanceled && !mListener)
return NS_ERROR_FAILURE;
LOG_SCOPE(gImgLog, "imgRequestProxy::CancelAndForgetObserver");
LOG_SCOPE(GetImgLog(), "imgRequestProxy::CancelAndForgetObserver");
mCanceled = true;
@ -500,7 +500,7 @@ nsresult imgRequestProxy::PerformClone(imgINotificationObserver* aObserver,
{
NS_PRECONDITION(aClone, "Null out param");
LOG_SCOPE(gImgLog, "imgRequestProxy::Clone");
LOG_SCOPE(GetImgLog(), "imgRequestProxy::Clone");
*aClone = nullptr;
nsRefPtr<imgRequestProxy> clone = aAllocFn(this);
@ -609,7 +609,7 @@ NS_IMETHODIMP imgRequestProxy::GetHasTransferredData(bool* hasData)
void imgRequestProxy::OnStartContainer()
{
LOG_FUNC(gImgLog, "imgRequestProxy::OnStartContainer");
LOG_FUNC(GetImgLog(), "imgRequestProxy::OnStartContainer");
if (mListener && !mCanceled && !mSentStartContainer) {
// Hold a ref to the listener while we call it, just in case.
@ -621,7 +621,7 @@ void imgRequestProxy::OnStartContainer()
void imgRequestProxy::OnFrameUpdate(const nsIntRect * rect)
{
LOG_FUNC(gImgLog, "imgRequestProxy::OnDataAvailable");
LOG_FUNC(GetImgLog(), "imgRequestProxy::OnDataAvailable");
if (mListener && !mCanceled) {
// Hold a ref to the listener while we call it, just in case.
@ -632,7 +632,7 @@ void imgRequestProxy::OnFrameUpdate(const nsIntRect * rect)
void imgRequestProxy::OnStopFrame()
{
LOG_FUNC(gImgLog, "imgRequestProxy::OnStopFrame");
LOG_FUNC(GetImgLog(), "imgRequestProxy::OnStopFrame");
if (mListener && !mCanceled) {
// Hold a ref to the listener while we call it, just in case.
@ -643,7 +643,7 @@ void imgRequestProxy::OnStopFrame()
void imgRequestProxy::OnStopDecode()
{
LOG_FUNC(gImgLog, "imgRequestProxy::OnStopDecode");
LOG_FUNC(GetImgLog(), "imgRequestProxy::OnStopDecode");
if (mListener && !mCanceled) {
// Hold a ref to the listener while we call it, just in case.
@ -658,7 +658,7 @@ void imgRequestProxy::OnStopDecode()
void imgRequestProxy::OnDiscard()
{
LOG_FUNC(gImgLog, "imgRequestProxy::OnDiscard");
LOG_FUNC(GetImgLog(), "imgRequestProxy::OnDiscard");
if (mListener && !mCanceled) {
// Hold a ref to the listener while we call it, just in case.
@ -669,7 +669,7 @@ void imgRequestProxy::OnDiscard()
void imgRequestProxy::OnImageIsAnimated()
{
LOG_FUNC(gImgLog, "imgRequestProxy::OnImageIsAnimated");
LOG_FUNC(GetImgLog(), "imgRequestProxy::OnImageIsAnimated");
if (mListener && !mCanceled) {
// Hold a ref to the listener while we call it, just in case.
nsCOMPtr<imgINotificationObserver> kungFuDeathGrip(mListener);
@ -682,7 +682,7 @@ void imgRequestProxy::OnStartRequest()
#ifdef PR_LOGGING
nsAutoCString name;
GetName(name);
LOG_FUNC_WITH_PARAM(gImgLog, "imgRequestProxy::OnStartRequest", "name", name.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::OnStartRequest", "name", name.get());
#endif
}
@ -691,7 +691,7 @@ void imgRequestProxy::OnStopRequest(bool lastPart)
#ifdef PR_LOGGING
nsAutoCString name;
GetName(name);
LOG_FUNC_WITH_PARAM(gImgLog, "imgRequestProxy::OnStopRequest", "name", name.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::OnStopRequest", "name", name.get());
#endif
// There's all sorts of stuff here that could kill us (the OnStopRequest call
// on the listener, the removal from the loadgroup, the release of the
@ -734,7 +734,7 @@ void imgRequestProxy::BlockOnload()
#ifdef PR_LOGGING
nsAutoCString name;
GetName(name);
LOG_FUNC_WITH_PARAM(gImgLog, "imgRequestProxy::BlockOnload", "name", name.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::BlockOnload", "name", name.get());
#endif
nsCOMPtr<imgIOnloadBlocker> blocker = do_QueryInterface(mListener);
@ -748,7 +748,7 @@ void imgRequestProxy::UnblockOnload()
#ifdef PR_LOGGING
nsAutoCString name;
GetName(name);
LOG_FUNC_WITH_PARAM(gImgLog, "imgRequestProxy::UnblockOnload", "name", name.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::UnblockOnload", "name", name.get());
#endif
nsCOMPtr<imgIOnloadBlocker> blocker = do_QueryInterface(mListener);

View File

@ -30,7 +30,7 @@ NS_IMPL_ISUPPORTS3(imgStatusTrackerObserver,
/* [noscript] void frameChanged (in nsIntRect dirtyRect); */
NS_IMETHODIMP imgStatusTrackerObserver::FrameChanged(const nsIntRect *dirtyRect)
{
LOG_SCOPE(gImgLog, "imgStatusTrackerObserver::FrameChanged");
LOG_SCOPE(GetImgLog(), "imgStatusTrackerObserver::FrameChanged");
NS_ABORT_IF_FALSE(mTracker->GetImage(),
"FrameChanged callback before we've created our image");
@ -48,7 +48,7 @@ NS_IMETHODIMP imgStatusTrackerObserver::FrameChanged(const nsIntRect *dirtyRect)
NS_IMETHODIMP imgStatusTrackerObserver::OnStartDecode()
{
LOG_SCOPE(gImgLog, "imgStatusTrackerObserver::OnStartDecode");
LOG_SCOPE(GetImgLog(), "imgStatusTrackerObserver::OnStartDecode");
NS_ABORT_IF_FALSE(mTracker->GetImage(),
"OnStartDecode callback before we've created our image");
@ -85,7 +85,7 @@ NS_IMETHODIMP imgStatusTrackerObserver::OnStartRequest()
/* void onStartContainer (); */
NS_IMETHODIMP imgStatusTrackerObserver::OnStartContainer()
{
LOG_SCOPE(gImgLog, "imgStatusTrackerObserver::OnStartContainer");
LOG_SCOPE(GetImgLog(), "imgStatusTrackerObserver::OnStartContainer");
NS_ABORT_IF_FALSE(mTracker->GetImage(),
"OnStartContainer callback before we've created our image");
@ -102,7 +102,7 @@ NS_IMETHODIMP imgStatusTrackerObserver::OnStartContainer()
/* [noscript] void onDataAvailable ([const] in nsIntRect rect); */
NS_IMETHODIMP imgStatusTrackerObserver::OnDataAvailable(const nsIntRect * rect)
{
LOG_SCOPE(gImgLog, "imgStatusTrackerObserver::OnDataAvailable");
LOG_SCOPE(GetImgLog(), "imgStatusTrackerObserver::OnDataAvailable");
NS_ABORT_IF_FALSE(mTracker->GetImage(),
"OnDataAvailable callback before we've created our image");
@ -119,7 +119,7 @@ NS_IMETHODIMP imgStatusTrackerObserver::OnDataAvailable(const nsIntRect * rect)
/* void onStopFrame (); */
NS_IMETHODIMP imgStatusTrackerObserver::OnStopFrame()
{
LOG_SCOPE(gImgLog, "imgStatusTrackerObserver::OnStopFrame");
LOG_SCOPE(GetImgLog(), "imgStatusTrackerObserver::OnStopFrame");
NS_ABORT_IF_FALSE(mTracker->GetImage(),
"OnStopFrame callback before we've created our image");
@ -152,7 +152,7 @@ FireFailureNotification(imgRequest* aRequest)
/* void onStopDecode (in nsresult status); */
NS_IMETHODIMP imgStatusTrackerObserver::OnStopDecode(nsresult aStatus)
{
LOG_SCOPE(gImgLog, "imgStatusTrackerObserver::OnStopDecode");
LOG_SCOPE(GetImgLog(), "imgStatusTrackerObserver::OnStopDecode");
NS_ABORT_IF_FALSE(mTracker->GetImage(),
"OnStopDecode callback before we've created our image");
@ -313,7 +313,7 @@ imgStatusTracker::Notify(imgRequest* request, imgRequestProxy* proxy)
request->GetURI(getter_AddRefs(uri));
nsAutoCString spec;
uri->GetSpec(spec);
LOG_FUNC_WITH_PARAM(gImgLog, "imgStatusTracker::Notify async", "uri", spec.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgStatusTracker::Notify async", "uri", spec.get());
#endif
proxy->SetNotificationsDeferred(true);
@ -367,7 +367,7 @@ imgStatusTracker::NotifyCurrentState(imgRequestProxy* proxy)
proxy->GetURI(getter_AddRefs(uri));
nsAutoCString spec;
uri->GetSpec(spec);
LOG_FUNC_WITH_PARAM(gImgLog, "imgStatusTracker::NotifyCurrentState", "uri", spec.get());
LOG_FUNC_WITH_PARAM(GetImgLog(), "imgStatusTracker::NotifyCurrentState", "uri", spec.get());
#endif
proxy->SetNotificationsDeferred(true);
@ -385,7 +385,7 @@ imgStatusTracker::SyncNotify(imgRequestProxy* proxy)
proxy->GetURI(getter_AddRefs(uri));
nsAutoCString spec;
uri->GetSpec(spec);
LOG_SCOPE_WITH_PARAM(gImgLog, "imgStatusTracker::SyncNotify", "uri", spec.get());
LOG_SCOPE_WITH_PARAM(GetImgLog(), "imgStatusTracker::SyncNotify", "uri", spec.get());
#endif
nsCOMPtr<imgIRequest> kungFuDeathGrip(proxy);

View File

@ -176,8 +176,15 @@ using namespace mozilla;
#ifdef PR_LOGGING
static PRLogModuleInfo * kPrintingLogMod = PR_NewLogModule("printing");
#define PR_PL(_p1) PR_LOG(kPrintingLogMod, PR_LOG_DEBUG, _p1);
static PRLogModuleInfo *
GetPrintingLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("printing");
return sLog;
}
#define PR_PL(_p1) PR_LOG(GetPrintingLog(), PR_LOG_DEBUG, _p1);
#define PRT_YESNO(_p) ((_p)?"YES":"NO")
#else

View File

@ -16,7 +16,14 @@
using namespace mozilla::css;
#ifdef PR_LOGGING
static PRLogModuleInfo* nsFlexContainerFrameLM = PR_NewLogModule("nsFlexContainerFrame");
static PRLogModuleInfo*
GetFlexContainerLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsFlexContainerFrame");
return sLog;
}
#endif /* PR_LOGGING */
// XXXdholbert Some of this helper-stuff should be separated out into a general
@ -1088,7 +1095,7 @@ nsFlexContainerFrame::ResolveFlexibleLengths(
nscoord aFlexContainerMainSize,
nsTArray<FlexItem>& aItems)
{
PR_LOG(nsFlexContainerFrameLM, PR_LOG_DEBUG, ("ResolveFlexibleLengths\n"));
PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG, ("ResolveFlexibleLengths\n"));
if (aItems.IsEmpty()) {
return;
}
@ -1127,7 +1134,7 @@ nsFlexContainerFrame::ResolveFlexibleLengths(
availableFreeSpace -= item.GetMainSize();
}
PR_LOG(nsFlexContainerFrameLM, PR_LOG_DEBUG,
PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG,
(" available free space = %d\n", availableFreeSpace));
// If sign of free space matches flexType, give each flexible
@ -1180,7 +1187,7 @@ nsFlexContainerFrame::ResolveFlexibleLengths(
}
if (runningFlexWeightSum != 0.0f) { // no distribution if no flexibility
PR_LOG(nsFlexContainerFrameLM, PR_LOG_DEBUG,
PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG,
(" Distributing available space:"));
for (uint32_t i = aItems.Length() - 1; i < aItems.Length(); --i) {
FlexItem& item = aItems[i];
@ -1219,7 +1226,7 @@ nsFlexContainerFrame::ResolveFlexibleLengths(
availableFreeSpace -= sizeDelta;
item.SetMainSize(item.GetMainSize() + sizeDelta);
PR_LOG(nsFlexContainerFrameLM, PR_LOG_DEBUG,
PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG,
(" child %d receives %d, for a total of %d\n",
i, sizeDelta, item.GetMainSize()));
}
@ -1229,7 +1236,7 @@ nsFlexContainerFrame::ResolveFlexibleLengths(
// Fix min/max violations:
nscoord totalViolation = 0; // keeps track of adjustments for min/max
PR_LOG(nsFlexContainerFrameLM, PR_LOG_DEBUG,
PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG,
(" Checking for violations:"));
for (uint32_t i = 0; i < aItems.Length(); i++) {
@ -1251,7 +1258,7 @@ nsFlexContainerFrame::ResolveFlexibleLengths(
FreezeOrRestoreEachFlexibleSize(totalViolation, aItems);
PR_LOG(nsFlexContainerFrameLM, PR_LOG_DEBUG,
PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG,
(" Total violation: %d\n", totalViolation));
if (totalViolation == 0) {
@ -1946,7 +1953,7 @@ nsFlexContainerFrame::Reflow(nsPresContext* aPresContext,
{
DO_GLOBAL_REFLOW_COUNT("nsFlexContainerFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
PR_LOG(nsFlexContainerFrameLM, PR_LOG_DEBUG,
PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG,
("Reflow() for nsFlexContainerFrame %p\n", this));
// We (and our children) can only depend on our ancestor's height if we have

View File

@ -154,7 +154,14 @@ using mozilla::DefaultXDisplay;
#endif
#ifdef PR_LOGGING
static PRLogModuleInfo *nsObjectFrameLM = PR_NewLogModule("nsObjectFrame");
static PRLogModuleInfo *
GetObjectFrameLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsObjectFrame");
return sLog;
}
#endif /* PR_LOGGING */
#if defined(XP_MACOSX) && !defined(__LP64__)
@ -249,13 +256,13 @@ nsObjectFrame::nsObjectFrame(nsStyleContext* aContext)
: nsObjectFrameSuper(aContext)
, mReflowCallbackPosted(false)
{
PR_LOG(nsObjectFrameLM, PR_LOG_DEBUG,
PR_LOG(GetObjectFrameLog(), PR_LOG_DEBUG,
("Created new nsObjectFrame %p\n", this));
}
nsObjectFrame::~nsObjectFrame()
{
PR_LOG(nsObjectFrameLM, PR_LOG_DEBUG,
PR_LOG(GetObjectFrameLog(), PR_LOG_DEBUG,
("nsObjectFrame %p deleted\n", this));
}
@ -285,7 +292,7 @@ nsObjectFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
PR_LOG(nsObjectFrameLM, PR_LOG_DEBUG,
PR_LOG(GetObjectFrameLog(), PR_LOG_DEBUG,
("Initializing nsObjectFrame %p for content %p\n", this, aContent));
nsresult rv = nsObjectFrameSuper::Init(aContent, aParent, aPrevInFlow);

View File

@ -25,8 +25,8 @@
#include "prlog.h"
#ifdef PR_LOGGING
extern PRLogModuleInfo * kLayoutPrintingLogMod;
#define PR_PL(_p1) PR_LOG(kLayoutPrintingLogMod, PR_LOG_DEBUG, _p1)
extern PRLogModuleInfo *GetLayoutPrintingLog();
#define PR_PL(_p1) PR_LOG(GetLayoutPrintingLog(), PR_LOG_DEBUG, _p1)
#else
#define PR_PL(_p1)
#endif

View File

@ -41,8 +41,15 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printsettings-se
#include "prlog.h"
#ifdef PR_LOGGING
PRLogModuleInfo * kLayoutPrintingLogMod = PR_NewLogModule("printing-layout");
#define PR_PL(_p1) PR_LOG(kLayoutPrintingLogMod, PR_LOG_DEBUG, _p1)
PRLogModuleInfo *
GetLayoutPrintingLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("printing-layout");
return sLog;
}
#define PR_PL(_p1) PR_LOG(GetLayoutPrintingLog(), PR_LOG_DEBUG, _p1)
#else
#define PR_PL(_p1)
#endif

View File

@ -22,8 +22,15 @@
#ifdef PR_LOGGING
#define DUMP_LAYOUT_LEVEL 9 // this turns on the dumping of each doucment's layout info
static PRLogModuleInfo * kPrintingLogMod = PR_NewLogModule("printing");
#define PR_PL(_p1) PR_LOG(kPrintingLogMod, PR_LOG_DEBUG, _p1);
static PRLogModuleInfo *
GetPrintingLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("printing");
return sLog;
}
#define PR_PL(_p1) PR_LOG(GetPrintingLog(), PR_LOG_DEBUG, _p1);
#else
#define PRT_YESNO(_p)
#define PR_PL(_p1)

View File

@ -146,8 +146,15 @@ using namespace mozilla::dom;
#define DUMP_LAYOUT_LEVEL 9 // this turns on the dumping of each doucment's layout info
static PRLogModuleInfo * kPrintingLogMod = PR_NewLogModule("printing");
#define PR_PL(_p1) PR_LOG(kPrintingLogMod, PR_LOG_DEBUG, _p1);
static PRLogModuleInfo *
GetPrintingLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("printing");
return sLog;
}
#define PR_PL(_p1) PR_LOG(GetPrintingLog(), PR_LOG_DEBUG, _p1);
#ifdef EXTENDED_DEBUG_PRINTING
static uint32_t gDumpFileNameCnt = 0;

View File

@ -251,19 +251,26 @@ private:
#include "prlog.h"
#ifdef PR_LOGGING
static PRLogModuleInfo *gLoaderLog = PR_NewLogModule("nsCSSLoader");
static PRLogModuleInfo *
GetLoaderLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsCSSLoader");
return sLog;
}
#endif /* PR_LOGGING */
#define LOG_FORCE(args) PR_LOG(gLoaderLog, PR_LOG_ALWAYS, args)
#define LOG_ERROR(args) PR_LOG(gLoaderLog, PR_LOG_ERROR, args)
#define LOG_WARN(args) PR_LOG(gLoaderLog, PR_LOG_WARNING, args)
#define LOG_DEBUG(args) PR_LOG(gLoaderLog, PR_LOG_DEBUG, args)
#define LOG_FORCE(args) PR_LOG(GetLoaderLog(), PR_LOG_ALWAYS, args)
#define LOG_ERROR(args) PR_LOG(GetLoaderLog(), PR_LOG_ERROR, args)
#define LOG_WARN(args) PR_LOG(GetLoaderLog(), PR_LOG_WARNING, args)
#define LOG_DEBUG(args) PR_LOG(GetLoaderLog(), PR_LOG_DEBUG, args)
#define LOG(args) LOG_DEBUG(args)
#define LOG_FORCE_ENABLED() PR_LOG_TEST(gLoaderLog, PR_LOG_ALWAYS)
#define LOG_ERROR_ENABLED() PR_LOG_TEST(gLoaderLog, PR_LOG_ERROR)
#define LOG_WARN_ENABLED() PR_LOG_TEST(gLoaderLog, PR_LOG_WARNING)
#define LOG_DEBUG_ENABLED() PR_LOG_TEST(gLoaderLog, PR_LOG_DEBUG)
#define LOG_FORCE_ENABLED() PR_LOG_TEST(GetLoaderLog(), PR_LOG_ALWAYS)
#define LOG_ERROR_ENABLED() PR_LOG_TEST(GetLoaderLog(), PR_LOG_ERROR)
#define LOG_WARN_ENABLED() PR_LOG_TEST(GetLoaderLog(), PR_LOG_WARNING)
#define LOG_DEBUG_ENABLED() PR_LOG_TEST(GetLoaderLog(), PR_LOG_DEBUG)
#define LOG_ENABLED() LOG_DEBUG_ENABLED()
#ifdef PR_LOGGING

View File

@ -44,11 +44,18 @@
using namespace mozilla;
#ifdef PR_LOGGING
static PRLogModuleInfo *gFontDownloaderLog = PR_NewLogModule("fontdownloader");
static PRLogModuleInfo *
GetFontDownloaderLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("fontdownloader");
return sLog;
}
#endif /* PR_LOGGING */
#define LOG(args) PR_LOG(gFontDownloaderLog, PR_LOG_DEBUG, args)
#define LOG_ENABLED() PR_LOG_TEST(gFontDownloaderLog, PR_LOG_DEBUG)
#define LOG(args) PR_LOG(GetFontDownloaderLog(), PR_LOG_DEBUG, args)
#define LOG_ENABLED() PR_LOG_TEST(GetFontDownloaderLog(), PR_LOG_DEBUG)
nsFontFaceLoader::nsFontFaceLoader(gfxProxyFontEntry *aProxy, nsIURI *aFontURI,
@ -754,8 +761,8 @@ nsUserFontSet::LogMessage(gfxProxyFontEntry *aProxy,
msg.Append(fontURI);
#ifdef PR_LOGGING
if (PR_LOG_TEST(sUserFontsLog, PR_LOG_DEBUG)) {
PR_LOG(sUserFontsLog, PR_LOG_DEBUG,
if (PR_LOG_TEST(GetUserFontsLog(), PR_LOG_DEBUG)) {
PR_LOG(GetUserFontsLog(), PR_LOG_DEBUG,
("userfonts (%p) %s", this, msg.get()));
}
#endif

View File

@ -18,8 +18,15 @@
#include "nsIAsyncVerifyRedirectCallback.h"
#ifdef PR_LOGGING
static PRLogModuleInfo *gLog = PR_NewLogModule("nsRedirect");
#define LOG(args) PR_LOG(gLog, PR_LOG_DEBUG, args)
static PRLogModuleInfo *
GetRedirectLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsRedirect");
return sLog;
}
#define LOG(args) PR_LOG(GetRedirectLog(), PR_LOG_DEBUG, args)
#else
#define LOG(args)
#endif

View File

@ -39,9 +39,16 @@ using namespace mozilla;
#include "prlog.h"
#if defined(PR_LOGGING)
static PRLogModuleInfo *sLog = PR_NewLogModule("proxy");
static PRLogModuleInfo *
GetProxyLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("proxy");
return sLog;
}
#endif
#define LOG(args) PR_LOG(sLog, PR_LOG_DEBUG, args)
#define LOG(args) PR_LOG(GetProxyLog(), PR_LOG_DEBUG, args)
//----------------------------------------------------------------------------

View File

@ -177,48 +177,55 @@ struct nsListIter
#define GET_COOKIE false
#ifdef PR_LOGGING
static PRLogModuleInfo *sCookieLog = PR_NewLogModule("cookie");
static PRLogModuleInfo *
GetCookieLog()
{
static PRLogModuleInfo *sCookieLog;
if (!sCookieLog)
sCookieLog = PR_NewLogModule("cookie");
return sCookieLog;
}
#define COOKIE_LOGFAILURE(a, b, c, d) LogFailure(a, b, c, d)
#define COOKIE_LOGSUCCESS(a, b, c, d, e) LogSuccess(a, b, c, d, e)
#define COOKIE_LOGEVICTED(a, details) \
PR_BEGIN_MACRO \
if (PR_LOG_TEST(sCookieLog, PR_LOG_DEBUG)) \
if (PR_LOG_TEST(GetCookieLog(), PR_LOG_DEBUG)) \
LogEvicted(a, details); \
PR_END_MACRO
#define COOKIE_LOGSTRING(lvl, fmt) \
PR_BEGIN_MACRO \
PR_LOG(sCookieLog, lvl, fmt); \
PR_LOG(sCookieLog, lvl, ("\n")); \
PR_LOG(GetCookieLog(), lvl, fmt); \
PR_LOG(GetCookieLog(), lvl, ("\n")); \
PR_END_MACRO
static void
LogFailure(bool aSetCookie, nsIURI *aHostURI, const char *aCookieString, const char *aReason)
{
// if logging isn't enabled, return now to save cycles
if (!PR_LOG_TEST(sCookieLog, PR_LOG_WARNING))
if (!PR_LOG_TEST(GetCookieLog(), PR_LOG_WARNING))
return;
nsAutoCString spec;
if (aHostURI)
aHostURI->GetAsciiSpec(spec);
PR_LOG(sCookieLog, PR_LOG_WARNING,
PR_LOG(GetCookieLog(), PR_LOG_WARNING,
("===== %s =====\n", aSetCookie ? "COOKIE NOT ACCEPTED" : "COOKIE NOT SENT"));
PR_LOG(sCookieLog, PR_LOG_WARNING,("request URL: %s\n", spec.get()));
PR_LOG(GetCookieLog(), PR_LOG_WARNING,("request URL: %s\n", spec.get()));
if (aSetCookie)
PR_LOG(sCookieLog, PR_LOG_WARNING,("cookie string: %s\n", aCookieString));
PR_LOG(GetCookieLog(), PR_LOG_WARNING,("cookie string: %s\n", aCookieString));
PRExplodedTime explodedTime;
PR_ExplodeTime(PR_Now(), PR_GMTParameters, &explodedTime);
char timeString[40];
PR_FormatTimeUSEnglish(timeString, 40, "%c GMT", &explodedTime);
PR_LOG(sCookieLog, PR_LOG_WARNING,("current time: %s", timeString));
PR_LOG(sCookieLog, PR_LOG_WARNING,("rejected because %s\n", aReason));
PR_LOG(sCookieLog, PR_LOG_WARNING,("\n"));
PR_LOG(GetCookieLog(), PR_LOG_WARNING,("current time: %s", timeString));
PR_LOG(GetCookieLog(), PR_LOG_WARNING,("rejected because %s\n", aReason));
PR_LOG(GetCookieLog(), PR_LOG_WARNING,("\n"));
}
static void
@ -229,27 +236,27 @@ LogCookie(nsCookie *aCookie)
char timeString[40];
PR_FormatTimeUSEnglish(timeString, 40, "%c GMT", &explodedTime);
PR_LOG(sCookieLog, PR_LOG_DEBUG,("current time: %s", timeString));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("current time: %s", timeString));
if (aCookie) {
PR_LOG(sCookieLog, PR_LOG_DEBUG,("----------------\n"));
PR_LOG(sCookieLog, PR_LOG_DEBUG,("name: %s\n", aCookie->Name().get()));
PR_LOG(sCookieLog, PR_LOG_DEBUG,("value: %s\n", aCookie->Value().get()));
PR_LOG(sCookieLog, PR_LOG_DEBUG,("%s: %s\n", aCookie->IsDomain() ? "domain" : "host", aCookie->Host().get()));
PR_LOG(sCookieLog, PR_LOG_DEBUG,("path: %s\n", aCookie->Path().get()));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("----------------\n"));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("name: %s\n", aCookie->Name().get()));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("value: %s\n", aCookie->Value().get()));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("%s: %s\n", aCookie->IsDomain() ? "domain" : "host", aCookie->Host().get()));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("path: %s\n", aCookie->Path().get()));
PR_ExplodeTime(aCookie->Expiry() * int64_t(PR_USEC_PER_SEC),
PR_GMTParameters, &explodedTime);
PR_FormatTimeUSEnglish(timeString, 40, "%c GMT", &explodedTime);
PR_LOG(sCookieLog, PR_LOG_DEBUG,
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,
("expires: %s%s", timeString, aCookie->IsSession() ? " (at end of session)" : ""));
PR_ExplodeTime(aCookie->CreationTime(), PR_GMTParameters, &explodedTime);
PR_FormatTimeUSEnglish(timeString, 40, "%c GMT", &explodedTime);
PR_LOG(sCookieLog, PR_LOG_DEBUG,("created: %s", timeString));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("created: %s", timeString));
PR_LOG(sCookieLog, PR_LOG_DEBUG,("is secure: %s\n", aCookie->IsSecure() ? "true" : "false"));
PR_LOG(sCookieLog, PR_LOG_DEBUG,("is httpOnly: %s\n", aCookie->IsHttpOnly() ? "true" : "false"));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("is secure: %s\n", aCookie->IsSecure() ? "true" : "false"));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("is httpOnly: %s\n", aCookie->IsHttpOnly() ? "true" : "false"));
}
}
@ -257,7 +264,7 @@ static void
LogSuccess(bool aSetCookie, nsIURI *aHostURI, const char *aCookieString, nsCookie *aCookie, bool aReplacing)
{
// if logging isn't enabled, return now to save cycles
if (!PR_LOG_TEST(sCookieLog, PR_LOG_DEBUG)) {
if (!PR_LOG_TEST(GetCookieLog(), PR_LOG_DEBUG)) {
return;
}
@ -265,27 +272,27 @@ LogSuccess(bool aSetCookie, nsIURI *aHostURI, const char *aCookieString, nsCooki
if (aHostURI)
aHostURI->GetAsciiSpec(spec);
PR_LOG(sCookieLog, PR_LOG_DEBUG,
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,
("===== %s =====\n", aSetCookie ? "COOKIE ACCEPTED" : "COOKIE SENT"));
PR_LOG(sCookieLog, PR_LOG_DEBUG,("request URL: %s\n", spec.get()));
PR_LOG(sCookieLog, PR_LOG_DEBUG,("cookie string: %s\n", aCookieString));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("request URL: %s\n", spec.get()));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("cookie string: %s\n", aCookieString));
if (aSetCookie)
PR_LOG(sCookieLog, PR_LOG_DEBUG,("replaces existing cookie: %s\n", aReplacing ? "true" : "false"));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("replaces existing cookie: %s\n", aReplacing ? "true" : "false"));
LogCookie(aCookie);
PR_LOG(sCookieLog, PR_LOG_DEBUG,("\n"));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("\n"));
}
static void
LogEvicted(nsCookie *aCookie, const char* details)
{
PR_LOG(sCookieLog, PR_LOG_DEBUG,("===== COOKIE EVICTED =====\n"));
PR_LOG(sCookieLog, PR_LOG_DEBUG,("%s\n", details));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("===== COOKIE EVICTED =====\n"));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("%s\n", details));
LogCookie(aCookie);
PR_LOG(sCookieLog, PR_LOG_DEBUG,("\n"));
PR_LOG(GetCookieLog(), PR_LOG_DEBUG,("\n"));
}
// inline wrappers to make passing in nsAFlatCStrings easier

View File

@ -31,7 +31,14 @@
#include "DataChannelProtocol.h"
#ifdef PR_LOGGING
PRLogModuleInfo* dataChannelLog = PR_NewLogModule("DataChannel");
PRLogModuleInfo*
GetDataChannelLog()
{
static PRLogModuleInfo* sLog;
if (!sLog)
sLog = PR_NewLogModule("DataChannel");
return sLog;
}
#endif
static bool sctp_initialized;

View File

@ -19,10 +19,10 @@
#include "prlog.h"
#ifdef PR_LOGGING
extern PRLogModuleInfo* dataChannelLog;
extern PRLogModuleInfo* GetDataChannelLog();
#endif
#undef LOG
#define LOG(args) PR_LOG(dataChannelLog, PR_LOG_DEBUG, args)
#define LOG(args) PR_LOG(GetDataChannelLog(), PR_LOG_DEBUG, args)
#endif

View File

@ -33,7 +33,14 @@
static const PRUnichar kUTF16[] = { 'U', 'T', 'F', '-', '1', '6', '\0' };
#ifdef PR_LOGGING
static PRLogModuleInfo *gExpatDriverLog = PR_NewLogModule("expatdriver");
static PRLogModuleInfo *
GetExpatDriverLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("expatdriver");
return sLog;
}
#endif
/***************************** EXPAT CALL BACKS ******************************/
@ -1031,7 +1038,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
nsScannerIterator end;
aScanner.EndReading(end);
PR_LOG(gExpatDriverLog, PR_LOG_DEBUG,
PR_LOG(GetExpatDriverLog(), PR_LOG_DEBUG,
("Remaining in expat's buffer: %i, remaining in scanner: %i.",
mExpatBuffered, Distance(start, end)));
@ -1053,7 +1060,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
#if defined(PR_LOGGING) || defined (DEBUG)
if (blocked) {
PR_LOG(gExpatDriverLog, PR_LOG_DEBUG,
PR_LOG(GetExpatDriverLog(), PR_LOG_DEBUG,
("Resuming Expat, will parse data remaining in Expat's "
"buffer.\nContent of Expat's buffer:\n-----\n%s\n-----\n",
NS_ConvertUTF16toUTF8(currentExpatPosition.get(),
@ -1062,7 +1069,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
else {
NS_ASSERTION(mExpatBuffered == Distance(currentExpatPosition, end),
"Didn't pass all the data to Expat?");
PR_LOG(gExpatDriverLog, PR_LOG_DEBUG,
PR_LOG(GetExpatDriverLog(), PR_LOG_DEBUG,
("Last call to Expat, will parse data remaining in Expat's "
"buffer.\nContent of Expat's buffer:\n-----\n%s\n-----\n",
NS_ConvertUTF16toUTF8(currentExpatPosition.get(),
@ -1074,7 +1081,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
buffer = start.get();
length = uint32_t(start.size_forward());
PR_LOG(gExpatDriverLog, PR_LOG_DEBUG,
PR_LOG(GetExpatDriverLog(), PR_LOG_DEBUG,
("Calling Expat, will parse data remaining in Expat's buffer and "
"new data.\nContent of Expat's buffer:\n-----\n%s\n-----\nNew "
"data:\n-----\n%s\n-----\n",
@ -1114,7 +1121,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
mExpatBuffered += length - consumed;
if (BlockedOrInterrupted()) {
PR_LOG(gExpatDriverLog, PR_LOG_DEBUG,
PR_LOG(GetExpatDriverLog(), PR_LOG_DEBUG,
("Blocked or interrupted parser (probably for loading linked "
"stylesheets or scripts)."));
@ -1175,7 +1182,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
aScanner.SetPosition(currentExpatPosition, true);
aScanner.Mark();
PR_LOG(gExpatDriverLog, PR_LOG_DEBUG,
PR_LOG(GetExpatDriverLog(), PR_LOG_DEBUG,
("Remaining in expat's buffer: %i, remaining in scanner: %i.",
mExpatBuffered, Distance(currentExpatPosition, end)));

View File

@ -33,10 +33,17 @@
#define STS_KNOCKOUT (nsIPermissionManager::DENY_ACTION)
#if defined(PR_LOGGING)
PRLogModuleInfo *gSTSLog = PR_NewLogModule("nsSTSService");
static PRLogModuleInfo *
GetSTSLog()
{
static PRLogModuleInfo *gSTSLog;
if (!gSTSLog)
gSTSLog = PR_NewLogModule("nsSTSService");
return gSTSLog;
}
#endif
#define STSLOG(args) PR_LOG(gSTSLog, 4, args)
#define STSLOG(args) PR_LOG(GetSTSLog(), 4, args)
#define STS_PARSER_FAIL_IF(test,args) \
if (test) { \

View File

@ -22,10 +22,17 @@
#include "mozilla/Likely.h"
#ifdef PR_LOGGING
PRLogModuleInfo *gNTLMLog = PR_NewLogModule("NTLM");
static PRLogModuleInfo *
GetNTLMLog()
{
static PRLogModuleInfo *sNTLMLog;
if (!sNTLMLog)
sNTLMLog = PR_NewLogModule("NTLM");
return sNTLMLog;
}
#define LOG(x) PR_LOG(gNTLMLog, PR_LOG_DEBUG, x)
#define LOG_ENABLED() PR_LOG_TEST(gNTLMLog, PR_LOG_DEBUG)
#define LOG(x) PR_LOG(GetNTLMLog(), PR_LOG_DEBUG, x)
#define LOG_ENABLED() PR_LOG_TEST(GetNTLMLog(), PR_LOG_DEBUG)
#else
#define LOG(x)
#endif

View File

@ -71,9 +71,16 @@
#endif
#ifdef PR_LOGGING
static PRLogModuleInfo *sUpdateLog = PR_NewLogModule("updatedriver");
static PRLogModuleInfo *
GetUpdateLog()
{
static PRLogModuleInfo *sUpdateLog;
if (!sUpdateLog)
sUpdateLog = PR_NewLogModule("updatedriver");
return sUpdateLog;
}
#endif
#define LOG(args) PR_LOG(sUpdateLog, PR_LOG_DEBUG, args)
#define LOG(args) PR_LOG(GetUpdateLog(), PR_LOG_DEBUG, args)
#ifdef XP_WIN
static const char kUpdaterBin[] = "updater.exe";

View File

@ -42,10 +42,17 @@
using namespace mozilla;
#ifdef PR_LOGGING
static PRLogModuleInfo *DeviceContextSpecGTKLM = PR_NewLogModule("DeviceContextSpecGTK");
static PRLogModuleInfo *
GetDeviceContextSpecGTKLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("DeviceContextSpecGTK");
return sLog;
}
#endif /* PR_LOGGING */
/* Macro to make lines shorter */
#define DO_PR_DEBUG_LOG(x) PR_LOG(DeviceContextSpecGTKLM, PR_LOG_DEBUG, x)
#define DO_PR_DEBUG_LOG(x) PR_LOG(GetDeviceContextSpecGTKLog(), PR_LOG_DEBUG, x)
//----------------------------------------------------------------------------------
// The printer data is shared between the PrinterEnumerator and the nsDeviceContextSpecGTK

View File

@ -17,8 +17,15 @@ namespace mozilla {
namespace probes {
#if defined(MOZ_LOGGING)
static PRLogModuleInfo *gProbeLog = PR_NewLogModule("SysProbe");
#define LOG(x) PR_LOG(gProbeLog, PR_LOG_DEBUG, x)
static PRLogModuleInfo *
GetProbeLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("SysProbe");
return sLog;
}
#define LOG(x) PR_LOG(GetProbeLog(), PR_LOG_DEBUG, x)
#else
#define LOG(x)
#endif

View File

@ -68,8 +68,15 @@ HasStableTSC()
//
// this enables PR_LOG_DEBUG level information and places all output in
// the file nspr.log
PRLogModuleInfo* timeStampLog = PR_NewLogModule("TimeStampWindows");
#define LOG(x) PR_LOG(timeStampLog, PR_LOG_DEBUG, x)
static PRLogModuleInfo*
GetTimeStampLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("TimeStampWindows");
return sLog;
}
#define LOG(x) PR_LOG(GetTimeStampLog(), PR_LOG_DEBUG, x)
#else
#define LOG(x)
#endif /* PR_LOGGING */

View File

@ -30,8 +30,15 @@
//
// this enables PR_LOG_DEBUG level information and places all output in
// the file nspr.log
PRLogModuleInfo* observerServiceLog = PR_NewLogModule("ObserverService");
#define LOG(x) PR_LOG(observerServiceLog, PR_LOG_DEBUG, x)
static PRLogModuleInfo*
GetObserverServiceLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("ObserverService");
return sLog;
}
#define LOG(x) PR_LOG(GetObserverServiceLog(), PR_LOG_DEBUG, x)
#else
#define LOG(x)
#endif /* PR_LOGGING */

View File

@ -19,8 +19,15 @@
using namespace mozilla;
#ifdef PR_LOGGING
static PRLogModuleInfo* gInputStreamTeeLog = PR_NewLogModule("nsInputStreamTee");
#define LOG(args) PR_LOG(gInputStreamTeeLog, PR_LOG_DEBUG, args)
static PRLogModuleInfo*
GetTeeLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsInputStreamTee");
return sLog;
}
#define LOG(args) PR_LOG(GetTeeLog(), PR_LOG_DEBUG, args)
#else
#define LOG(args)
#endif

View File

@ -23,8 +23,15 @@ using namespace mozilla;
//
// set NSPR_LOG_MODULES=nsPipe:5
//
static PRLogModuleInfo *gPipeLog = PR_NewLogModule("nsPipe");
#define LOG(args) PR_LOG(gPipeLog, PR_LOG_DEBUG, args)
static PRLogModuleInfo *
GetPipeLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsPipe");
return sLog;
}
#define LOG(args) PR_LOG(GetPipeLog(), PR_LOG_DEBUG, args)
#else
#define LOG(args)
#endif

View File

@ -36,9 +36,16 @@
// this enables PR_LOG_DEBUG level information and places all output in
// the file nspr.log
//
static PRLogModuleInfo* sLog = PR_NewLogModule("nsStorageStream");
static PRLogModuleInfo*
GetStorageStreamLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsStorageStream");
return sLog;
}
#endif
#define LOG(args) PR_LOG(sLog, PR_LOG_DEBUG, args)
#define LOG(args) PR_LOG(GetStorageStreamLog(), PR_LOG_DEBUG, args)
nsStorageStream::nsStorageStream()
: mSegmentedBuffer(0), mSegmentSize(0), mWriteInProgress(false),

View File

@ -75,7 +75,7 @@ TimerObserverRunnable::Run()
nsresult TimerThread::Init()
{
PR_LOG(gTimerLog, PR_LOG_DEBUG, ("TimerThread::Init [%d]\n", mInitialized));
PR_LOG(GetTimerLog(), PR_LOG_DEBUG, ("TimerThread::Init [%d]\n", mInitialized));
if (mInitialized) {
if (!mThread)
@ -121,7 +121,7 @@ nsresult TimerThread::Init()
nsresult TimerThread::Shutdown()
{
PR_LOG(gTimerLog, PR_LOG_DEBUG, ("TimerThread::Shutdown begin\n"));
PR_LOG(GetTimerLog(), PR_LOG_DEBUG, ("TimerThread::Shutdown begin\n"));
if (!mThread)
return NS_ERROR_NOT_INITIALIZED;
@ -155,7 +155,7 @@ nsresult TimerThread::Shutdown()
mThread->Shutdown(); // wait for the thread to die
PR_LOG(gTimerLog, PR_LOG_DEBUG, ("TimerThread::Shutdown end\n"));
PR_LOG(GetTimerLog(), PR_LOG_DEBUG, ("TimerThread::Shutdown end\n"));
return NS_OK;
}
@ -207,7 +207,7 @@ void TimerThread::UpdateFilter(uint32_t aDelay, TimeStamp aTimeout,
}
#ifdef DEBUG_TIMERS
PR_LOG(gTimerLog, PR_LOG_DEBUG,
PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
("UpdateFilter: smoothSlack = %g, filterLength = %u\n",
smoothSlack, filterLength));
#endif
@ -273,8 +273,8 @@ NS_IMETHODIMP TimerThread::Run()
MonitorAutoUnlock unlock(mMonitor);
#ifdef DEBUG_TIMERS
if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
PR_LOG(gTimerLog, PR_LOG_DEBUG,
if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
("Timer thread woke up %fms from when it was supposed to\n",
fabs((now - timer->mTimeout).ToMilliseconds())));
}
@ -333,12 +333,12 @@ NS_IMETHODIMP TimerThread::Run()
}
#ifdef DEBUG_TIMERS
if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
if (waitFor == PR_INTERVAL_NO_TIMEOUT)
PR_LOG(gTimerLog, PR_LOG_DEBUG,
PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
("waiting for PR_INTERVAL_NO_TIMEOUT\n"));
else
PR_LOG(gTimerLog, PR_LOG_DEBUG,
PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
("waiting for %u\n", PR_IntervalToMilliseconds(waitFor)));
}
#endif

View File

@ -12,9 +12,16 @@
using namespace mozilla;
#ifdef PR_LOGGING
static PRLogModuleInfo *sLog = PR_NewLogModule("nsEventQueue");
static PRLogModuleInfo *
GetLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsEventQueue");
return sLog;
}
#endif
#define LOG(args) PR_LOG(sLog, PR_LOG_DEBUG, args)
#define LOG(args) PR_LOG(GetLog(), PR_LOG_DEBUG, args)
nsEventQueue::nsEventQueue()
: mReentrantMonitor("nsEventQueue.mReentrantMonitor")

View File

@ -41,9 +41,16 @@
using namespace mozilla;
#ifdef PR_LOGGING
static PRLogModuleInfo *sLog = PR_NewLogModule("nsThread");
static PRLogModuleInfo *
GetThreadLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsThread");
return sLog;
}
#endif
#define LOG(args) PR_LOG(sLog, PR_LOG_DEBUG, args)
#define LOG(args) PR_LOG(GetThreadLog(), PR_LOG_DEBUG, args)
NS_DECL_CI_INTERFACE_GETTER(nsThread)

View File

@ -16,9 +16,16 @@
using namespace mozilla;
#ifdef PR_LOGGING
static PRLogModuleInfo *sLog = PR_NewLogModule("nsThreadPool");
static PRLogModuleInfo *
GetThreadPoolLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsThreadPool");
return sLog;
}
#endif
#define LOG(args) PR_LOG(sLog, PR_LOG_DEBUG, args)
#define LOG(args) PR_LOG(GetThreadPoolLog(), PR_LOG_DEBUG, args)
// DESIGN:
// o Allocate anonymous threads.

View File

@ -19,6 +19,16 @@ static int32_t gGenerator = 0;
static TimerThread* gThread = nullptr;
#ifdef DEBUG_TIMERS
PRLogModuleInfo*
GetTimerLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("nsTimerImpl");
return sLog;
}
#include <math.h>
double nsTimerImpl::sDeltaSumSquared = 0;
@ -222,12 +232,12 @@ nsTimerImpl::Startup()
void nsTimerImpl::Shutdown()
{
#ifdef DEBUG_TIMERS
if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
double mean = 0, stddev = 0;
myNS_MeanAndStdDev(sDeltaNum, sDeltaSum, sDeltaSumSquared, &mean, &stddev);
PR_LOG(gTimerLog, PR_LOG_DEBUG, ("sDeltaNum = %f, sDeltaSum = %f, sDeltaSumSquared = %f\n", sDeltaNum, sDeltaSum, sDeltaSumSquared));
PR_LOG(gTimerLog, PR_LOG_DEBUG, ("mean: %fms, stddev: %fms\n", mean, stddev));
PR_LOG(GetTimerLog(), PR_LOG_DEBUG, ("sDeltaNum = %f, sDeltaSum = %f, sDeltaSumSquared = %f\n", sDeltaNum, sDeltaSum, sDeltaSumSquared));
PR_LOG(GetTimerLog(), PR_LOG_DEBUG, ("mean: %fms, stddev: %fms\n", mean, stddev));
}
#endif
@ -425,7 +435,7 @@ void nsTimerImpl::Fire()
TimeStamp now = TimeStamp::Now();
#ifdef DEBUG_TIMERS
if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
TimeDuration a = now - mStart; // actual delay in intervals
TimeDuration b = TimeDuration::FromMilliseconds(mDelay); // expected delay in intervals
TimeDuration delta = (a > b) ? a - b : b - a;
@ -434,10 +444,10 @@ void nsTimerImpl::Fire()
sDeltaSumSquared += double(d) * double(d);
sDeltaNum++;
PR_LOG(gTimerLog, PR_LOG_DEBUG, ("[this=%p] expected delay time %4ums\n", this, mDelay));
PR_LOG(gTimerLog, PR_LOG_DEBUG, ("[this=%p] actual delay time %fms\n", this, a.ToMilliseconds()));
PR_LOG(gTimerLog, PR_LOG_DEBUG, ("[this=%p] (mType is %d) -------\n", this, mType));
PR_LOG(gTimerLog, PR_LOG_DEBUG, ("[this=%p] delta %4dms\n", this, (a > b) ? (int32_t)d : -(int32_t)d));
PR_LOG(GetTimerLog(), PR_LOG_DEBUG, ("[this=%p] expected delay time %4ums\n", this, mDelay));
PR_LOG(GetTimerLog(), PR_LOG_DEBUG, ("[this=%p] actual delay time %fms\n", this, a.ToMilliseconds()));
PR_LOG(GetTimerLog(), PR_LOG_DEBUG, ("[this=%p] (mType is %d) -------\n", this, mType));
PR_LOG(GetTimerLog(), PR_LOG_DEBUG, ("[this=%p] delta %4dms\n", this, (a > b) ? (int32_t)d : -(int32_t)d));
mStart = mStart2;
mStart2 = TimeStamp();
@ -500,8 +510,8 @@ void nsTimerImpl::Fire()
mTimerCallbackWhileFiring = nullptr;
#ifdef DEBUG_TIMERS
if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
PR_LOG(gTimerLog, PR_LOG_DEBUG,
if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
("[this=%p] Took %fms to fire timer callback\n",
this, (TimeStamp::Now() - now).ToMilliseconds()));
}
@ -544,9 +554,9 @@ NS_IMETHODIMP nsTimerEvent::Run()
return NS_OK;
#ifdef DEBUG_TIMERS
if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
TimeStamp now = TimeStamp::Now();
PR_LOG(gTimerLog, PR_LOG_DEBUG,
PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
("[this=%p] time between PostTimerEvent() and Fire(): %fms\n",
this, (now - mInitTime).ToMilliseconds()));
}
@ -571,7 +581,7 @@ nsresult nsTimerImpl::PostTimerEvent()
return NS_ERROR_OUT_OF_MEMORY;
#ifdef DEBUG_TIMERS
if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
event->mInitTime = TimeStamp::Now();
}
#endif
@ -608,7 +618,7 @@ void nsTimerImpl::SetDelayInternal(uint32_t aDelay)
mTimeout += delayInterval;
#ifdef DEBUG_TIMERS
if (PR_LOG_TEST(gTimerLog, PR_LOG_DEBUG)) {
if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
if (mStart.IsNull())
mStart = now;
else

View File

@ -19,7 +19,7 @@
#include "mozilla/Attributes.h"
#if defined(PR_LOGGING)
static PRLogModuleInfo *gTimerLog = PR_NewLogModule("nsTimerImpl");
extern PRLogModuleInfo *GetTimerLog();
#define DEBUG_TIMERS 1
#else
#undef DEBUG_TIMERS