Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | 4f68ed7 | 2012-10-30 05:24:07 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 5 | #include <stdint.h> |
6 | |||||
Scott Violet | a35f9a4 | 2018-03-22 22:00:44 | [diff] [blame] | 7 | #include "ipc/ipc_buildflags.h" |
davidsz | 041528a | 2017-05-12 09:19:23 | [diff] [blame] | 8 | |
9 | #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) | ||||
[email protected] | 4f68ed7 | 2012-10-30 05:24:07 | [diff] [blame] | 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" | ||||
[email protected] | 4f68ed7 | 2012-10-30 05:24:07 | [diff] [blame] | 15 | |
[email protected] | 4f68ed7 | 2012-10-30 05:24:07 | [diff] [blame] | 16 | |
[email protected] | 4f68ed7 | 2012-10-30 05:24:07 | [diff] [blame] | 17 | #include "base/lazy_instance.h" |
18 | |||||
19 | namespace content { | ||||
20 | |||||
21 | namespace { | ||||
22 | |||||
Takuto Ikuta | adf31eb | 2019-01-05 00:32:48 | [diff] [blame] | 23 | base::LazyInstance<std::unordered_map<uint32_t, LogFunction>>::Leaky |
[email protected] | 4f68ed7 | 2012-10-30 05:24:07 | [diff] [blame] | 24 | g_log_function_mapping = LAZY_INSTANCE_INITIALIZER; |
25 | |||||
26 | } // namespace | ||||
27 | |||||
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 28 | void RegisterIPCLogger(uint32_t msg_id, LogFunction logger) { |
Lukasz Anforowicz | d3e1913 | 2017-12-06 19:44:27 | [diff] [blame] | 29 | if (!g_log_function_mapping.IsCreated()) |
[email protected] | 4f68ed7 | 2012-10-30 05:24:07 | [diff] [blame] | 30 | IPC::Logging::set_log_function_map(g_log_function_mapping.Pointer()); |
31 | g_log_function_mapping.Get()[msg_id] = logger; | ||||
32 | } | ||||
33 | |||||
34 | } // content | ||||
35 | |||||
davidsz | 041528a | 2017-05-12 09:19:23 | [diff] [blame] | 36 | #endif // BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) |