trace_ipc_message.h 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. // 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. #ifndef IPC_TRACE_IPC_MESSAGE_H_
  5. #define IPC_TRACE_IPC_MESSAGE_H_
  6. #include <stdint.h>
  7. #include "base/component_export.h"
  8. #include "services/tracing/public/cpp/perfetto/macros.h"
  9. #include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_legacy_ipc.pbzero.h"
  10. // When tracing is enabled, emits a trace event with the given category and
  11. // event name and typed arguments for the message's type (message class and line
  12. // number).
  13. #define TRACE_IPC_MESSAGE_SEND(category, name, msg) \
  14. TRACE_EVENT(category, name, [msg](perfetto::EventContext ctx) { \
  15. IPC::WriteIpcMessageIdAsProtozero(msg->type(), \
  16. ctx.event()->set_chrome_legacy_ipc()); \
  17. });
  18. namespace IPC {
  19. // Converts |message_id| into its message class and line number parts and writes
  20. // them to the protozero message |ChromeLegacyIpc| for trace events.
  21. void COMPONENT_EXPORT(IPC)
  22. WriteIpcMessageIdAsProtozero(uint32_t message_id,
  23. perfetto::protos::pbzero::ChromeLegacyIpc*);
  24. } // namespace IPC
  25. #endif // IPC_TRACE_IPC_MESSAGE_H_