blob: 44d4792cf94251eda1e95f8a6e6cda1a0ef41b21 [file] [log] [blame]
Eric Seckler502a8b42020-01-10 10:51:281// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef IPC_TRACE_IPC_MESSAGE_H_
6#define IPC_TRACE_IPC_MESSAGE_H_
7
8#include <stdint.h>
9
10#include "base/component_export.h"
11#include "services/tracing/public/cpp/perfetto/macros.h"
12#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_legacy_ipc.pbzero.h"
13
14// When tracing is enabled, emits a trace event with the given category and
15// event name and typed arguments for the message's type (message class and line
16// number).
17#define TRACE_IPC_MESSAGE_SEND(category, name, msg) \
18 TRACE_EVENT(category, name, [msg](perfetto::EventContext ctx) { \
19 IPC::WriteIpcMessageIdAsProtozero(msg->type(), \
20 ctx.event()->set_chrome_legacy_ipc()); \
21 });
22
23namespace IPC {
24
25// Converts |message_id| into its message class and line number parts and writes
26// them to the protozero message |ChromeLegacyIpc| for trace events.
27void COMPONENT_EXPORT(IPC)
28 WriteIpcMessageIdAsProtozero(uint32_t message_id,
29 perfetto::protos::pbzero::ChromeLegacyIpc*);
30
31} // namespace IPC
32
33#endif // IPC_TRACE_IPC_MESSAGE_H_