blob: 2012f07c3ac6676774d909012591da3fb16b015b [file] [log] [blame]
[email protected]4f68ed72012-10-30 05:24:071// Copyright (c) 2012 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#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
6
avia9aa7a82015-12-25 03:06:317#include <stdint.h>
8
[email protected]4f68ed72012-10-30 05:24:079#if defined(IPC_MESSAGE_LOG_ENABLED)
10#define IPC_MESSAGE_MACROS_LOG_ENABLED
11#include "content/public/common/content_ipc_logging.h"
12#define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
13 content::RegisterIPCLogger(msg_id, logger)
14#include "content/common/all_messages.h"
15#endif
16
17#if defined(IPC_MESSAGE_LOG_ENABLED)
18
[email protected]14c1c232013-06-11 17:52:4419#include "base/containers/hash_tables.h"
[email protected]4f68ed72012-10-30 05:24:0720#include "base/lazy_instance.h"
21
22namespace content {
23
24namespace {
25
avia9aa7a82015-12-25 03:06:3126base::LazyInstance<base::hash_map<uint32_t, LogFunction>>::Leaky
[email protected]4f68ed72012-10-30 05:24:0727 g_log_function_mapping = LAZY_INSTANCE_INITIALIZER;
28
29} // namespace
30
avia9aa7a82015-12-25 03:06:3131void RegisterIPCLogger(uint32_t msg_id, LogFunction logger) {
[email protected]4f68ed72012-10-30 05:24:0732 if (g_log_function_mapping == NULL)
33 IPC::Logging::set_log_function_map(g_log_function_mapping.Pointer());
34 g_log_function_mapping.Get()[msg_id] = logger;
35}
36
37} // content
38
39#endif