зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1163201 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=froydnj
This commit is contained in:
Родитель
34f99e4b4c
Коммит
47d9aba92d
|
@ -187,8 +187,8 @@ nsContentPolicy::CheckPolicy(CPMethod policyMethod,
|
|||
//logType must be a literal string constant
|
||||
#define LOG_CHECK(logType) \
|
||||
PR_BEGIN_MACRO \
|
||||
/* skip all this nonsense if the call failed */ \
|
||||
if (NS_SUCCEEDED(rv)) { \
|
||||
/* skip all this nonsense if the call failed or logging is disabled */ \
|
||||
if (NS_SUCCEEDED(rv) && PR_LOG_TEST(gConPolLog, PR_LOG_DEBUG)) { \
|
||||
const char *resultName; \
|
||||
if (decision) { \
|
||||
resultName = NS_CP_ResponseName(*decision); \
|
||||
|
|
|
@ -2864,14 +2864,17 @@ nsDocument::InitCSP(nsIChannel* aChannel)
|
|||
!applyLoopCSP &&
|
||||
cspHeaderValue.IsEmpty() &&
|
||||
cspROHeaderValue.IsEmpty()) {
|
||||
nsCOMPtr<nsIURI> chanURI;
|
||||
aChannel->GetURI(getter_AddRefs(chanURI));
|
||||
nsAutoCString aspec;
|
||||
chanURI->GetAsciiSpec(aspec);
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("no CSP for document, %s, %s",
|
||||
aspec.get(),
|
||||
applyAppDefaultCSP ? "is app" : "not an app"));
|
||||
if (PR_LOG_TEST(gCspPRLog, PR_LOG_DEBUG)) {
|
||||
nsCOMPtr<nsIURI> chanURI;
|
||||
aChannel->GetURI(getter_AddRefs(chanURI));
|
||||
nsAutoCString aspec;
|
||||
chanURI->GetAsciiSpec(aspec);
|
||||
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
|
||||
("no CSP for document, %s, %s",
|
||||
aspec.get(),
|
||||
applyAppDefaultCSP ? "is app" : "not an app"));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,16 +77,16 @@ using namespace mozilla::widget;
|
|||
PRLogModuleInfo* gFocusLog;
|
||||
PRLogModuleInfo* gFocusNavigationLog;
|
||||
|
||||
#define LOGFOCUS(args) PR_LOG(gFocusLog, 4, args)
|
||||
#define LOGFOCUSNAVIGATION(args) PR_LOG(gFocusNavigationLog, 4, args)
|
||||
#define LOGFOCUS(args) PR_LOG(gFocusLog, PR_LOG_DEBUG, args)
|
||||
#define LOGFOCUSNAVIGATION(args) PR_LOG(gFocusNavigationLog, PR_LOG_DEBUG, args)
|
||||
|
||||
#define LOGTAG(log, format, content) \
|
||||
{ \
|
||||
if (PR_LOG_TEST(log, PR_LOG_DEBUG)) { \
|
||||
nsAutoCString tag(NS_LITERAL_CSTRING("(none)")); \
|
||||
if (content) { \
|
||||
content->NodeInfo()->NameAtom()->ToUTF8String(tag); \
|
||||
} \
|
||||
PR_LOG(log, 4, (format, tag.get())); \
|
||||
PR_LOG(log, PR_LOG_DEBUG, (format, tag.get())); \
|
||||
}
|
||||
|
||||
#define LOGCONTENT(format, content) LOGTAG(gFocusLog, format, content)
|
||||
|
|
|
@ -507,13 +507,15 @@ IMEStateManager::OnMouseButtonEventInEditor(nsPresContext* aPresContext,
|
|||
bool consumed =
|
||||
sActiveIMEContentObserver->OnMouseButtonEvent(aPresContext, internalEvent);
|
||||
|
||||
nsAutoString eventType;
|
||||
aMouseEvent->GetType(eventType);
|
||||
PR_LOG(sISMLog, PR_LOG_ALWAYS,
|
||||
("ISM: IMEStateManager::OnMouseButtonEventInEditor(), "
|
||||
"mouse event (type=%s, button=%d) is %s",
|
||||
NS_ConvertUTF16toUTF8(eventType).get(), internalEvent->button,
|
||||
consumed ? "consumed" : "not consumed"));
|
||||
if (PR_LOG_TEST(sISMLog, PR_LOG_ALWAYS)) {
|
||||
nsAutoString eventType;
|
||||
aMouseEvent->GetType(eventType);
|
||||
PR_LOG(sISMLog, PR_LOG_ALWAYS,
|
||||
("ISM: IMEStateManager::OnMouseButtonEventInEditor(), "
|
||||
"mouse event (type=%s, button=%d) is %s",
|
||||
NS_ConvertUTF16toUTF8(eventType).get(), internalEvent->button,
|
||||
consumed ? "consumed" : "not consumed"));
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
|
|
@ -65,11 +65,13 @@ SampleSink::Receive(IMediaSample* aSample)
|
|||
mon.Wait();
|
||||
}
|
||||
|
||||
REFERENCE_TIME start = 0, end = 0;
|
||||
HRESULT hr = aSample->GetMediaTime(&start, &end);
|
||||
LOG("SampleSink::Receive() [%4.2lf-%4.2lf]",
|
||||
(double)RefTimeToUsecs(start) / USECS_PER_S,
|
||||
(double)RefTimeToUsecs(end) / USECS_PER_S);
|
||||
if (PR_LOG_TEST(GetDirectShowLog(), PR_LOG_DEBUG)) {
|
||||
REFERENCE_TIME start = 0, end = 0;
|
||||
HRESULT hr = aSample->GetMediaTime(&start, &end);
|
||||
LOG("SampleSink::Receive() [%4.2lf-%4.2lf]",
|
||||
(double)RefTimeToUsecs(start) / USECS_PER_S,
|
||||
(double)RefTimeToUsecs(end) / USECS_PER_S);
|
||||
}
|
||||
|
||||
mSample = aSample;
|
||||
// Notify the signal, to awaken the consumer thread in WaitForSample()
|
||||
|
@ -100,11 +102,13 @@ SampleSink::Extract(RefPtr<IMediaSample>& aOutSample)
|
|||
}
|
||||
aOutSample = mSample;
|
||||
|
||||
int64_t start = 0, end = 0;
|
||||
mSample->GetMediaTime(&start, &end);
|
||||
LOG("SampleSink::Extract() [%4.2lf-%4.2lf]",
|
||||
(double)RefTimeToUsecs(start) / USECS_PER_S,
|
||||
(double)RefTimeToUsecs(end) / USECS_PER_S);
|
||||
if (PR_LOG_TEST(GetDirectShowLog(), PR_LOG_DEBUG)) {
|
||||
int64_t start = 0, end = 0;
|
||||
mSample->GetMediaTime(&start, &end);
|
||||
LOG("SampleSink::Extract() [%4.2lf-%4.2lf]",
|
||||
(double)RefTimeToUsecs(start) / USECS_PER_S,
|
||||
(double)RefTimeToUsecs(end) / USECS_PER_S);
|
||||
}
|
||||
|
||||
mSample = nullptr;
|
||||
// Notify the signal, to awaken the producer thread in Receive()
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace mozilla {
|
|||
#ifndef EME_LOG
|
||||
PRLogModuleInfo* GetEMELog();
|
||||
#define EME_LOG(...) PR_LOG(GetEMELog(), PR_LOG_DEBUG, (__VA_ARGS__))
|
||||
#define EME_LOG_ENABLED() PR_LOG_TEST(GetEMELog(), PR_LOG_DEBUG)
|
||||
#endif
|
||||
|
||||
#ifndef EME_VERBOSE_LOG
|
||||
|
|
|
@ -138,22 +138,24 @@ MediaKeySession::UpdateKeyStatusMap()
|
|||
|
||||
mKeyStatusMap->Update(keyStatuses);
|
||||
|
||||
nsAutoCString message(
|
||||
nsPrintfCString("MediaKeySession[%p,'%s'] key statuses change {",
|
||||
this, NS_ConvertUTF16toUTF8(mSessionId).get()));
|
||||
for (const CDMCaps::KeyStatus& status : keyStatuses) {
|
||||
nsAutoCString base64KeyId;
|
||||
nsDependentCSubstring rawKeyId(reinterpret_cast<const char*>(status.mId.Elements()),
|
||||
status.mId.Length());
|
||||
nsresult rv = Base64Encode(rawKeyId, base64KeyId);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
continue;
|
||||
if (EME_LOG_ENABLED()) {
|
||||
nsAutoCString message(
|
||||
nsPrintfCString("MediaKeySession[%p,'%s'] key statuses change {",
|
||||
this, NS_ConvertUTF16toUTF8(mSessionId).get()));
|
||||
for (const CDMCaps::KeyStatus& status : keyStatuses) {
|
||||
nsAutoCString base64KeyId;
|
||||
nsDependentCSubstring rawKeyId(reinterpret_cast<const char*>(status.mId.Elements()),
|
||||
status.mId.Length());
|
||||
nsresult rv = Base64Encode(rawKeyId, base64KeyId);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
continue;
|
||||
}
|
||||
message.Append(nsPrintfCString(" (%s,%s)", base64KeyId.get(),
|
||||
MediaKeyStatusValues::strings[status.mStatus].value));
|
||||
}
|
||||
message.Append(nsPrintfCString(" (%s,%s)", base64KeyId.get(),
|
||||
MediaKeyStatusValues::strings[status.mStatus].value));
|
||||
message.Append(" }");
|
||||
EME_LOG(message.get());
|
||||
}
|
||||
message.Append(" }");
|
||||
EME_LOG(message.get());
|
||||
}
|
||||
|
||||
MediaKeyStatusMap*
|
||||
|
@ -195,10 +197,12 @@ MediaKeySession::GenerateRequest(const nsAString& aInitDataType,
|
|||
// Note: UpdateSession() Move()s the data out of the array, so we have
|
||||
// to copy it here.
|
||||
nsAutoCString base64InitData;
|
||||
nsDependentCSubstring rawInitData(reinterpret_cast<const char*>(data.Elements()),
|
||||
data.Length());
|
||||
if (NS_FAILED(Base64Encode(rawInitData, base64InitData))) {
|
||||
NS_WARNING("Failed to base64 encode initData for logging");
|
||||
if (EME_LOG_ENABLED()) {
|
||||
nsDependentCSubstring rawInitData(reinterpret_cast<const char*>(data.Elements()),
|
||||
data.Length());
|
||||
if (NS_FAILED(Base64Encode(rawInitData, base64InitData))) {
|
||||
NS_WARNING("Failed to base64 encode initData for logging");
|
||||
}
|
||||
}
|
||||
|
||||
PromiseId pid = mKeys->StorePromise(promise);
|
||||
|
@ -280,10 +284,12 @@ MediaKeySession::Update(const ArrayBufferViewOrArrayBuffer& aResponse, ErrorResu
|
|||
// Note: UpdateSession() Move()s the data out of the array, so we have
|
||||
// to copy it here.
|
||||
nsAutoCString base64Response;
|
||||
nsDependentCSubstring rawResponse(reinterpret_cast<const char*>(data.Elements()),
|
||||
data.Length());
|
||||
if (NS_FAILED(Base64Encode(rawResponse, base64Response))) {
|
||||
NS_WARNING("Failed to base64 encode response for logging");
|
||||
if (EME_LOG_ENABLED()) {
|
||||
nsDependentCSubstring rawResponse(reinterpret_cast<const char*>(data.Elements()),
|
||||
data.Length());
|
||||
if (NS_FAILED(Base64Encode(rawResponse, base64Response))) {
|
||||
NS_WARNING("Failed to base64 encode response for logging");
|
||||
}
|
||||
}
|
||||
|
||||
PromiseId pid = mKeys->StorePromise(promise);
|
||||
|
@ -376,16 +382,18 @@ void
|
|||
MediaKeySession::DispatchKeyMessage(MediaKeyMessageType aMessageType,
|
||||
const nsTArray<uint8_t>& aMessage)
|
||||
{
|
||||
nsAutoCString base64MsgData;
|
||||
nsDependentCSubstring rawMsgData(reinterpret_cast<const char*>(aMessage.Elements()),
|
||||
aMessage.Length());
|
||||
if (NS_FAILED(Base64Encode(rawMsgData, base64MsgData))) {
|
||||
NS_WARNING("Failed to base64 encode message for logging");
|
||||
if (EME_LOG_ENABLED()) {
|
||||
nsAutoCString base64MsgData;
|
||||
nsDependentCSubstring rawMsgData(reinterpret_cast<const char*>(aMessage.Elements()),
|
||||
aMessage.Length());
|
||||
if (NS_FAILED(Base64Encode(rawMsgData, base64MsgData))) {
|
||||
NS_WARNING("Failed to base64 encode message for logging");
|
||||
}
|
||||
EME_LOG("MediaKeySession[%p,'%s'] DispatchKeyMessage() type=%s message(base64)='%s'",
|
||||
this, NS_ConvertUTF16toUTF8(mSessionId).get(),
|
||||
MediaKeyMessageTypeValues::strings[uint32_t(aMessageType)].value,
|
||||
base64MsgData.get());
|
||||
}
|
||||
EME_LOG("MediaKeySession[%p,'%s'] DispatchKeyMessage() type=%s message(base64)='%s'",
|
||||
this, NS_ConvertUTF16toUTF8(mSessionId).get(),
|
||||
MediaKeyMessageTypeValues::strings[uint32_t(aMessageType)].value,
|
||||
base64MsgData.get());
|
||||
|
||||
nsRefPtr<MediaKeyMessageEvent> event(
|
||||
MediaKeyMessageEvent::Constructor(this, aMessageType, aMessage));
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#undef LOG_ENABLED
|
||||
PRLogModuleInfo *gOpenSLESProviderLog;
|
||||
#define LOG(args) PR_LOG(gOpenSLESProviderLog, PR_LOG_DEBUG, args)
|
||||
#define LOG_ENABLED() PR_LOG_TEST(gLoadManagerLog, 5)
|
||||
#define LOG_ENABLED() PR_LOG_TEST(gOpenSLESProviderLog, PR_LOG_DEBUG)
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
|
|
@ -105,6 +105,10 @@ static void webm_log(nestegg * context,
|
|||
unsigned int severity,
|
||||
char const * format, ...)
|
||||
{
|
||||
if (!PR_LOG_TEST(gNesteggLog, PR_LOG_DEBUG)) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_list args;
|
||||
char msg[256];
|
||||
const char * sevStr;
|
||||
|
|
|
@ -218,14 +218,16 @@ MediaEngineCameraVideoSource::ChooseCapability(
|
|||
const dom::MediaTrackConstraints &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs)
|
||||
{
|
||||
LOG(("ChooseCapability: prefs: %dx%d @%d-%dfps",
|
||||
aPrefs.GetWidth(), aPrefs.GetHeight(),
|
||||
aPrefs.mFPS, aPrefs.mMinFPS));
|
||||
LogConstraints(aConstraints, false);
|
||||
if (aConstraints.mAdvanced.WasPassed()) {
|
||||
LOG(("Advanced array[%u]:", aConstraints.mAdvanced.Value().Length()));
|
||||
for (auto& advanced : aConstraints.mAdvanced.Value()) {
|
||||
LogConstraints(advanced, true);
|
||||
if (PR_LOG_TEST(GetMediaManagerLog(), PR_LOG_DEBUG)) {
|
||||
LOG(("ChooseCapability: prefs: %dx%d @%d-%dfps",
|
||||
aPrefs.GetWidth(), aPrefs.GetHeight(),
|
||||
aPrefs.mFPS, aPrefs.mMinFPS));
|
||||
LogConstraints(aConstraints, false);
|
||||
if (aConstraints.mAdvanced.WasPassed()) {
|
||||
LOG(("Advanced array[%u]:", aConstraints.mAdvanced.Value().Length()));
|
||||
for (auto& advanced : aConstraints.mAdvanced.Value()) {
|
||||
LogConstraints(advanced, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ MediaEngineWebRTCAudioSource::Allocate(const dom::MediaTrackConstraints &aConstr
|
|||
LOG(("Audio device is not initalized"));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
} else if (PR_LOG_TEST(GetMediaManagerLog(), PR_LOG_DEBUG)) {
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
if (mSources.IsEmpty()) {
|
||||
LOG(("Audio device %d reallocated", mCapIndex));
|
||||
|
|
|
@ -227,7 +227,7 @@ MediaEngineWebRTCVideoSource::Allocate(const dom::MediaTrackConstraints &aConstr
|
|||
}
|
||||
mState = kAllocated;
|
||||
LOG(("Video device %d allocated", mCaptureIndex));
|
||||
} else {
|
||||
} else if (PR_LOG_TEST(GetMediaManagerLog(), PR_LOG_DEBUG)) {
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
if (mSources.IsEmpty()) {
|
||||
LOG(("Video device %d reallocated", mCaptureIndex));
|
||||
|
|
Загрузка…
Ссылка в новой задаче