forked from mirrors/gecko-dev
Bug 1886922: Do not dereference a Maybe if it is not Some r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D205409
This commit is contained in:
parent
0aed52d2bb
commit
06692a4fe7
4 changed files with 46 additions and 16 deletions
|
|
@ -8093,7 +8093,7 @@ IPCResult ContentParent::RecvRawMessage(
|
||||||
stack->BorrowFromClonedMessageData(*aStack);
|
stack->BorrowFromClonedMessageData(*aStack);
|
||||||
}
|
}
|
||||||
MMPrinter::Print("ContentParent::RecvRawMessage", aMeta.actorName(),
|
MMPrinter::Print("ContentParent::RecvRawMessage", aMeta.actorName(),
|
||||||
aMeta.messageName(), *aData);
|
aMeta.messageName(), aData);
|
||||||
ReceiveRawMessage(aMeta, std::move(data), std::move(stack));
|
ReceiveRawMessage(aMeta, std::move(data), std::move(stack));
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ LazyLogModule MMPrinter::sMMLog("MessageManager");
|
||||||
// the output of the logs into logs more friendly to reading.
|
// the output of the logs into logs more friendly to reading.
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
void MMPrinter::PrintImpl(char const* aLocation, const nsAString& aMsg,
|
Maybe<uint64_t> MMPrinter::PrintHeader(char const* aLocation,
|
||||||
ClonedMessageData const& aData) {
|
const nsAString& aMsg) {
|
||||||
NS_ConvertUTF16toUTF8 charMsg(aMsg);
|
NS_ConvertUTF16toUTF8 charMsg(aMsg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -43,15 +43,29 @@ void MMPrinter::PrintImpl(char const* aLocation, const nsAString& aMsg,
|
||||||
char* mmSkipLog = PR_GetEnv("MOZ_LOG_MESSAGEMANAGER_SKIP");
|
char* mmSkipLog = PR_GetEnv("MOZ_LOG_MESSAGEMANAGER_SKIP");
|
||||||
|
|
||||||
if (mmSkipLog && strstr(mmSkipLog, charMsg.get())) {
|
if (mmSkipLog && strstr(mmSkipLog, charMsg.get())) {
|
||||||
return;
|
return Nothing();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t msg_id = RandomUint64OrDie();
|
uint64_t aMsgId = RandomUint64OrDie();
|
||||||
|
|
||||||
MOZ_LOG(MMPrinter::sMMLog, LogLevel::Debug,
|
MOZ_LOG(MMPrinter::sMMLog, LogLevel::Debug,
|
||||||
("%" PRIu64 " %s Message: %s in process type: %s", msg_id, aLocation,
|
("%" PRIu64 " %s Message: %s in process type: %s", aMsgId, aLocation,
|
||||||
charMsg.get(), XRE_GetProcessTypeString()));
|
charMsg.get(), XRE_GetProcessTypeString()));
|
||||||
|
|
||||||
|
return Some(aMsgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
void MMPrinter::PrintNoData(uint64_t aMsgId) {
|
||||||
|
if (!MOZ_LOG_TEST(sMMLog, LogLevel::Verbose)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MOZ_LOG(MMPrinter::sMMLog, LogLevel::Verbose,
|
||||||
|
("%" PRIu64 " (No Data)", aMsgId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
void MMPrinter::PrintData(uint64_t aMsgId, ClonedMessageData const& aData) {
|
||||||
if (!MOZ_LOG_TEST(sMMLog, LogLevel::Verbose)) {
|
if (!MOZ_LOG_TEST(sMMLog, LogLevel::Verbose)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -75,8 +89,7 @@ void MMPrinter::PrintImpl(char const* aLocation, const nsAString& aMsg,
|
||||||
if (rv.Failed()) {
|
if (rv.Failed()) {
|
||||||
// In testing, the only reason this would fail was if there was no data in
|
// In testing, the only reason this would fail was if there was no data in
|
||||||
// the message; so it seems like this is safe-ish.
|
// the message; so it seems like this is safe-ish.
|
||||||
MOZ_LOG(MMPrinter::sMMLog, LogLevel::Verbose,
|
MMPrinter::PrintNoData(aMsgId);
|
||||||
("%" PRIu64 " (No Data)", msg_id));
|
|
||||||
rv.SuppressException();
|
rv.SuppressException();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +99,7 @@ void MMPrinter::PrintImpl(char const* aLocation, const nsAString& aMsg,
|
||||||
if (!srcString.init(cx, unevalObj)) return;
|
if (!srcString.init(cx, unevalObj)) return;
|
||||||
|
|
||||||
MOZ_LOG(MMPrinter::sMMLog, LogLevel::Verbose,
|
MOZ_LOG(MMPrinter::sMMLog, LogLevel::Verbose,
|
||||||
("%" PRIu64 " %s", msg_id, NS_ConvertUTF16toUTF8(srcString).get()));
|
("%" PRIu64 " %s", aMsgId, NS_ConvertUTF16toUTF8(srcString).get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla::dom
|
} // namespace mozilla::dom
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#ifndef MMPrinter_h
|
#ifndef MMPrinter_h
|
||||||
#define MMPrinter_h
|
#define MMPrinter_h
|
||||||
|
|
||||||
|
#include "mozilla/Maybe.h"
|
||||||
#include "mozilla/dom/DOMTypes.h"
|
#include "mozilla/dom/DOMTypes.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
|
||||||
|
|
@ -17,24 +18,40 @@ class MMPrinter {
|
||||||
static void Print(char const* aLocation, const nsAString& aMsg,
|
static void Print(char const* aLocation, const nsAString& aMsg,
|
||||||
ClonedMessageData const& aData) {
|
ClonedMessageData const& aData) {
|
||||||
if (MOZ_UNLIKELY(MOZ_LOG_TEST(MMPrinter::sMMLog, LogLevel::Debug))) {
|
if (MOZ_UNLIKELY(MOZ_LOG_TEST(MMPrinter::sMMLog, LogLevel::Debug))) {
|
||||||
MMPrinter::PrintImpl(aLocation, aMsg, aData);
|
Maybe<uint64_t> msgId = MMPrinter::PrintHeader(aLocation, aMsg);
|
||||||
|
if (!msgId.isSome()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MMPrinter::PrintData(*msgId, aData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Print(char const* aLocation, const nsACString& aActorName,
|
static void Print(char const* aLocation, const nsACString& aActorName,
|
||||||
const nsAString& aMessageName,
|
const nsAString& aMessageName,
|
||||||
ClonedMessageData const& aData) {
|
const Maybe<ClonedMessageData>& aData) {
|
||||||
if (MOZ_UNLIKELY(MOZ_LOG_TEST(MMPrinter::sMMLog, LogLevel::Debug))) {
|
if (MOZ_UNLIKELY(MOZ_LOG_TEST(MMPrinter::sMMLog, LogLevel::Debug))) {
|
||||||
MMPrinter::PrintImpl(
|
Maybe<uint64_t> msgId = MMPrinter::PrintHeader(
|
||||||
aLocation,
|
aLocation,
|
||||||
NS_ConvertUTF8toUTF16(aActorName + " - "_ns) + aMessageName, aData);
|
NS_ConvertUTF8toUTF16(aActorName + " - "_ns) + aMessageName);
|
||||||
|
|
||||||
|
if (!msgId.isSome()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aData.isSome()) {
|
||||||
|
MMPrinter::PrintData(*msgId, *aData);
|
||||||
|
} else {
|
||||||
|
MMPrinter::PrintNoData(*msgId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static LazyLogModule sMMLog;
|
static LazyLogModule sMMLog;
|
||||||
static void PrintImpl(char const* aLocation, const nsAString& aMsg,
|
static Maybe<uint64_t> PrintHeader(char const* aLocation,
|
||||||
ClonedMessageData const& aData);
|
const nsAString& aMsg);
|
||||||
|
static void PrintNoData(uint64_t aMsgId);
|
||||||
|
static void PrintData(uint64_t aMsgId, ClonedMessageData const& aData);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla::dom
|
} // namespace mozilla::dom
|
||||||
|
|
|
||||||
|
|
@ -566,7 +566,7 @@ IPCResult WindowGlobalParent::RecvRawMessage(
|
||||||
stack->BorrowFromClonedMessageData(*aStack);
|
stack->BorrowFromClonedMessageData(*aStack);
|
||||||
}
|
}
|
||||||
MMPrinter::Print("WindowGlobalParent::RecvRawMessage", aMeta.actorName(),
|
MMPrinter::Print("WindowGlobalParent::RecvRawMessage", aMeta.actorName(),
|
||||||
aMeta.messageName(), *aData);
|
aMeta.messageName(), aData);
|
||||||
ReceiveRawMessage(aMeta, std::move(data), std::move(stack));
|
ReceiveRawMessage(aMeta, std::move(data), std::move(stack));
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue