Bug 1160064 - Explicitly initialize logging at the right time. r=jww

The patches in this bug can cause us to log things before some of the Ensure*Log
macros are called. Let's just do this right.
This commit is contained in:
Bobby Holley 2015-04-30 19:04:59 -07:00
parent 4d0ad3c305
commit df81097317
5 changed files with 10 additions and 40 deletions

View File

@ -2099,7 +2099,6 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
if (!gMediaElementEventsLog) {
gMediaElementEventsLog = PR_NewLogModule("nsMediaElementEvents");
}
EnsureStateWatchingLog();
#endif
mAudioChannel = AudioChannelService::GetDefaultAudioChannel();

View File

@ -117,10 +117,20 @@ public:
StaticRefPtr<MediaMemoryTracker> MediaMemoryTracker::sUniqueInstance;
PRLogModuleInfo* gStateWatchingLog;
PRLogModuleInfo* gMediaPromiseLog;
PRLogModuleInfo* gMediaTimerLog;
void
MediaDecoder::InitStatics()
{
AbstractThread::InitStatics();
// Log modules.
gMediaDecoderLog = PR_NewLogModule("MediaDecoder");
gMediaPromiseLog = PR_NewLogModule("MediaPromise");
gStateWatchingLog = PR_NewLogModule("StateWatching");
gMediaTimerLog = PR_NewLogModule("MediaTimer");
}
NS_IMPL_ISUPPORTS(MediaMemoryTracker, nsIMemoryReporter)
@ -617,12 +627,6 @@ MediaDecoder::MediaDecoder() :
MOZ_COUNT_CTOR(MediaDecoder);
MOZ_ASSERT(NS_IsMainThread());
MediaMemoryTracker::AddMediaDecoder(this);
#ifdef PR_LOGGING
if (!gMediaDecoderLog) {
gMediaDecoderLog = PR_NewLogModule("MediaDecoder");
}
EnsureStateWatchingLog();
#endif
// Initialize canonicals.
mPlayState.Init(AbstractThread::MainThread(), PLAY_STATE_LOADING, "MediaDecoder::mPlayState (Canonical)");

View File

@ -33,26 +33,6 @@ extern PRLogModuleInfo* gMediaDecoderLog;
#define DECODER_WARN(x, ...) \
DECODER_WARN_HELPER(0, (nsPrintfCString("Decoder=%p " x, mDecoder, ##__VA_ARGS__).get()))
PRLogModuleInfo* gMediaPromiseLog;
PRLogModuleInfo* gStateWatchingLog;
void
EnsureMediaPromiseLog()
{
if (!gMediaPromiseLog) {
gMediaPromiseLog = PR_NewLogModule("MediaPromise");
}
}
void
EnsureStateWatchingLog()
{
if (!gStateWatchingLog) {
gStateWatchingLog = PR_NewLogModule("StateWatching");
}
}
class VideoQueueMemoryFunctor : public nsDequeFunctor {
public:
VideoQueueMemoryFunctor() : mSize(0) {}
@ -96,8 +76,6 @@ MediaDecoderReader::MediaDecoderReader(AbstractMediaDecoder* aDecoder)
, mVideoDiscontinuity(false)
{
MOZ_COUNT_CTOR(MediaDecoderReader);
EnsureMediaPromiseLog();
EnsureStateWatchingLog();
}
MediaDecoderReader::~MediaDecoderReader()

View File

@ -16,14 +16,6 @@
namespace mozilla {
PRLogModuleInfo* gMediaTimerLog;
static void EnsureMediaTimerLog()
{
if (!gMediaTimerLog) {
gMediaTimerLog = PR_NewLogModule("MediaTimer");
}
}
NS_IMPL_ADDREF(MediaTimer)
NS_IMPL_RELEASE_WITH_DESTROY(MediaTimer, DispatchDestroy())
@ -33,7 +25,6 @@ MediaTimer::MediaTimer()
, mCreationTimeStamp(TimeStamp::Now())
, mUpdateScheduled(false)
{
EnsureMediaTimerLog();
TIMER_LOG("MediaTimer::MediaTimer");
// Use the SharedThreadPool to create an nsIThreadPool with a maximum of one

View File

@ -58,8 +58,6 @@ namespace mozilla {
extern PRLogModuleInfo* gStateWatchingLog;
void EnsureStateWatchingLog();
#define WATCH_LOG(x, ...) \
MOZ_ASSERT(gStateWatchingLog); \
PR_LOG(gStateWatchingLog, PR_LOG_DEBUG, (x, ##__VA_ARGS__))