Bug 1889091 - Part 6: Remove "scratch" register parameter from emitPushArguments...
[gecko.git] / dom / ipc / MMPrinter.h
blob1d00bfc2e622166f8b6cb4ccf7b1f571340375b5
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef MMPrinter_h
8 #define MMPrinter_h
10 #include "mozilla/Maybe.h"
11 #include "mozilla/dom/DOMTypes.h"
12 #include "nsString.h"
14 namespace mozilla::dom {
16 class MMPrinter {
17 public:
18 static void Print(char const* aLocation, const nsAString& aMsg,
19 ClonedMessageData const& aData) {
20 if (MOZ_UNLIKELY(MOZ_LOG_TEST(MMPrinter::sMMLog, LogLevel::Debug))) {
21 Maybe<uint64_t> msgId = MMPrinter::PrintHeader(aLocation, aMsg);
22 if (!msgId.isSome()) {
23 return;
25 MMPrinter::PrintData(*msgId, aData);
29 static void Print(char const* aLocation, const nsACString& aActorName,
30 const nsAString& aMessageName,
31 const Maybe<ClonedMessageData>& aData) {
32 if (MOZ_UNLIKELY(MOZ_LOG_TEST(MMPrinter::sMMLog, LogLevel::Debug))) {
33 Maybe<uint64_t> msgId = MMPrinter::PrintHeader(
34 aLocation,
35 NS_ConvertUTF8toUTF16(aActorName + " - "_ns) + aMessageName);
37 if (!msgId.isSome()) {
38 return;
41 if (aData.isSome()) {
42 MMPrinter::PrintData(*msgId, *aData);
43 } else {
44 MMPrinter::PrintNoData(*msgId);
49 private:
50 static LazyLogModule sMMLog;
51 static Maybe<uint64_t> PrintHeader(char const* aLocation,
52 const nsAString& aMsg);
53 static void PrintNoData(uint64_t aMsgId);
54 static void PrintData(uint64_t aMsgId, ClonedMessageData const& aData);
57 } // namespace mozilla::dom
59 #endif /* MMPrinter_h */