Bug 1512690 - Introduce a MesageManager log topic for MM topics and data r=tjr

This logging topic will output the topic of MEssageManager data at log
level 4 (debug); and will output the entire content of the data at level
5 (verbose).

--HG--
extra : histedit_source : 7be60b456a1652f9a9985fd4a01571b207a5f9e6
This commit is contained in:
Tom Ritter 2018-12-11 11:31:24 -06:00
Родитель 66b8ff36dc
Коммит 04ad4da5ff
9 изменённых файлов: 101 добавлений и 0 удалений

Просмотреть файл

@ -242,6 +242,7 @@
#include "VRManagerChild.h"
#include "private/pprio.h"
#include "nsString.h"
#include "MMPrinter.h"
#ifdef MOZ_WIDGET_GTK
#include "nsAppRunner.h"
@ -2259,6 +2260,7 @@ mozilla::ipc::IPCResult ContentChild::RecvAsyncMessage(
const IPC::Principal& aPrincipal, const ClonedMessageData& aData) {
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING("ContentChild::RecvAsyncMessage",
OTHER, aMsg);
MMPrinter::Print("ContentChild::RecvAsyncMessage", aMsg, aData);
CrossProcessCpowHolder cpows(this, aCpows);
RefPtr<nsFrameMessageManager> cpm =

54
dom/ipc/MMPrinter.cpp Normal file
Просмотреть файл

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "MMPrinter.h"
namespace mozilla {
namespace dom {
LazyLogModule MMPrinter::sMMLog("MessageManager");
/* static */
void MMPrinter::PrintImpl(char const* aLocation, const nsAString& aMsg,
ClonedMessageData const& aData) {
NS_ConvertUTF16toUTF8 charMsg(aMsg);
MOZ_LOG(MMPrinter::sMMLog, LogLevel::Debug,
("%s Message: %s in process type: %s", aLocation, charMsg.get(),
XRE_ChildProcessTypeToString(XRE_GetProcessType())));
if (!MOZ_LOG_TEST(sMMLog, LogLevel::Verbose)) {
return;
}
ErrorResult rv;
AutoJSAPI jsapi;
MOZ_ALWAYS_TRUE(jsapi.Init(xpc::UnprivilegedJunkScope()));
JSContext* cx = jsapi.cx();
ipc::StructuredCloneData data;
ipc::UnpackClonedMessageDataForChild(aData, data);
/* Read original StructuredCloneData. */
JS::RootedValue scdContent(cx);
data.Read(cx, &scdContent, rv);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
return;
}
JS::RootedString unevalObj(cx, JS_ValueToSource(cx, scdContent));
nsAutoJSString srcString;
if (!srcString.init(cx, unevalObj)) return;
MOZ_LOG(MMPrinter::sMMLog, LogLevel::Verbose,
(" %s", NS_ConvertUTF16toUTF8(srcString).get()));
return;
}
} // namespace dom
} // namespace mozilla

31
dom/ipc/MMPrinter.h Normal file
Просмотреть файл

@ -0,0 +1,31 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MMPrinter_h
#define MMPrinter_h
namespace mozilla {
namespace dom {
class MMPrinter {
public:
static void Print(char const* aLocation, const nsAString& aMsg,
ClonedMessageData const& aData) {
if (MOZ_UNLIKELY(MOZ_LOG_TEST(MMPrinter::sMMLog, LogLevel::Debug))) {
MMPrinter::PrintImpl(aLocation, aMsg, aData);
}
}
private:
static LazyLogModule sMMLog;
static void PrintImpl(char const* aLocation, const nsAString& aMsg,
ClonedMessageData const& aData);
};
} // namespace dom
} // namespace mozilla
#endif /* MMPrinter_h */

Просмотреть файл

@ -14,6 +14,7 @@
#include "mozilla/dom/ContentProcessMessageManager.h"
#include "mozilla/dom/IPCBlobUtils.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/ScriptPreloader.h"
using namespace mozilla::loader;

Просмотреть файл

@ -123,6 +123,7 @@
#include "nsDocShellLoadState.h"
#include "nsWebBrowser.h"
#include "mozilla/dom/WindowGlobalChild.h"
#include "MMPrinter.h"
#ifdef XP_WIN
#include "mozilla/plugins/PluginWidgetChild.h"
@ -2056,6 +2057,7 @@ mozilla::ipc::IPCResult TabChild::RecvAsyncMessage(
const IPC::Principal& aPrincipal, const ClonedMessageData& aData) {
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING("TabChild::RecvAsyncMessage",
OTHER, aMessage);
MMPrinter::Print("TabChild::RecvAsyncMessage", aMessage, aData);
CrossProcessCpowHolder cpows(Manager(), aCpows);
if (!mTabChildMessageManager) {

Просмотреть файл

@ -1579,6 +1579,7 @@ mozilla::ipc::IPCResult TabParent::RecvSyncMessage(
nsTArray<StructuredCloneData>* aRetVal) {
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING("TabParent::RecvSyncMessage",
OTHER, aMessage);
MMPrinter::Print("TabParent::RecvSyncMessage", aMessage, aData);
StructuredCloneData data;
ipc::UnpackClonedMessageDataForParent(aData, data);
@ -1596,6 +1597,7 @@ mozilla::ipc::IPCResult TabParent::RecvRpcMessage(
nsTArray<StructuredCloneData>* aRetVal) {
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING("TabParent::RecvRpcMessage", OTHER,
aMessage);
MMPrinter::Print("TabParent::RecvRpcMessage", aMessage, aData);
StructuredCloneData data;
ipc::UnpackClonedMessageDataForParent(aData, data);
@ -1612,6 +1614,7 @@ mozilla::ipc::IPCResult TabParent::RecvAsyncMessage(
const IPC::Principal& aPrincipal, const ClonedMessageData& aData) {
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING("TabParent::RecvAsyncMessage",
OTHER, aMessage);
MMPrinter::Print("TabParent::RecvAsyncMessage", aMessage, aData);
StructuredCloneData data;
ipc::UnpackClonedMessageDataForParent(aData, data);

Просмотреть файл

@ -72,6 +72,7 @@ UNIFIED_SOURCES += [
'FilePickerParent.cpp',
'MemMapSnapshot.cpp',
'MemoryReportRequest.cpp',
'MMPrinter.cpp',
'nsIContentChild.cpp',
'nsIContentParent.cpp',
'PermissionMessageUtils.cpp',
@ -148,6 +149,7 @@ LOCAL_INCLUDES += [
'/gfx/2d',
'/hal/sandbox',
'/js/xpconnect/loader',
'/js/xpconnect/src',
'/layout/base',
'/media/webrtc',
'/netwerk/base',

Просмотреть файл

@ -23,6 +23,7 @@
#include "mozilla/ipc/PParentToChildStreamChild.h"
#include "mozilla/dom/ipc/IPCBlobInputStreamChild.h"
#include "MMPrinter.h"
#include "nsPrintfCString.h"
#include "xpcpublic.h"
@ -147,6 +148,7 @@ mozilla::ipc::IPCResult nsIContentChild::RecvAsyncMessage(
const IPC::Principal& aPrincipal, const ClonedMessageData& aData) {
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(
"nsIContentChild::RecvAsyncMessage", OTHER, aMsg);
MMPrinter::Print("nsIContentChild::RecvAsyncMessage", aMsg, aData);
CrossProcessCpowHolder cpows(this, aCpows);
RefPtr<nsFrameMessageManager> cpm =

Просмотреть файл

@ -25,6 +25,7 @@
#include "mozilla/ipc/IPCStreamSource.h"
#include "mozilla/Unused.h"
#include "MMPrinter.h"
#include "nsIWebBrowserChrome.h"
#include "nsPrintfCString.h"
#include "xpcpublic.h"
@ -235,6 +236,7 @@ mozilla::ipc::IPCResult nsIContentParent::RecvSyncMessage(
nsTArray<ipc::StructuredCloneData>* aRetvals) {
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(
"nsIContentParent::RecvSyncMessage", OTHER, aMsg);
MMPrinter::Print("nsIContentParent::RecvSyncMessage", aMsg, aData);
CrossProcessCpowHolder cpows(this, aCpows);
RefPtr<nsFrameMessageManager> ppm = mMessageManager;
@ -254,6 +256,7 @@ mozilla::ipc::IPCResult nsIContentParent::RecvRpcMessage(
nsTArray<ipc::StructuredCloneData>* aRetvals) {
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING("nsIContentParent::RecvRpcMessage",
OTHER, aMsg);
MMPrinter::Print("nsIContentParent::RecvRpcMessage", aMsg, aData);
CrossProcessCpowHolder cpows(this, aCpows);
RefPtr<nsFrameMessageManager> ppm = mMessageManager;
@ -305,6 +308,7 @@ mozilla::ipc::IPCResult nsIContentParent::RecvAsyncMessage(
const IPC::Principal& aPrincipal, const ClonedMessageData& aData) {
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(
"nsIContentParent::RecvAsyncMessage", OTHER, aMsg);
MMPrinter::Print("nsIContentParent::RecvAsyncMessage", aMsg, aData);
CrossProcessCpowHolder cpows(this, aCpows);
RefPtr<nsFrameMessageManager> ppm = mMessageManager;