| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. |
| 6 |
| 5 #include <stdint.h> | 7 #include <stdint.h> |
| 6 | 8 |
| 7 #include "ipc/ipc_features.h" | 9 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 8 | |
| 9 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) | |
| 10 #define IPC_MESSAGE_MACROS_LOG_ENABLED | 10 #define IPC_MESSAGE_MACROS_LOG_ENABLED |
| 11 #include "content/public/common/content_ipc_logging.h" | 11 #include "content/public/common/content_ipc_logging.h" |
| 12 #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \ | 12 #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \ |
| 13 content::RegisterIPCLogger(msg_id, logger) | 13 content::RegisterIPCLogger(msg_id, logger) |
| 14 #include "content/common/all_messages.h" | 14 #include "content/common/all_messages.h" |
| 15 #endif |
| 15 | 16 |
| 17 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 16 | 18 |
| 17 #include "base/containers/hash_tables.h" | 19 #include "base/containers/hash_tables.h" |
| 18 #include "base/lazy_instance.h" | 20 #include "base/lazy_instance.h" |
| 19 | 21 |
| 20 namespace content { | 22 namespace content { |
| 21 | 23 |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 base::LazyInstance<base::hash_map<uint32_t, LogFunction>>::Leaky | 26 base::LazyInstance<base::hash_map<uint32_t, LogFunction>>::Leaky |
| 25 g_log_function_mapping = LAZY_INSTANCE_INITIALIZER; | 27 g_log_function_mapping = LAZY_INSTANCE_INITIALIZER; |
| 26 | 28 |
| 27 } // namespace | 29 } // namespace |
| 28 | 30 |
| 29 void RegisterIPCLogger(uint32_t msg_id, LogFunction logger) { | 31 void RegisterIPCLogger(uint32_t msg_id, LogFunction logger) { |
| 30 if (g_log_function_mapping == NULL) | 32 if (g_log_function_mapping == NULL) |
| 31 IPC::Logging::set_log_function_map(g_log_function_mapping.Pointer()); | 33 IPC::Logging::set_log_function_map(g_log_function_mapping.Pointer()); |
| 32 g_log_function_mapping.Get()[msg_id] = logger; | 34 g_log_function_mapping.Get()[msg_id] = logger; |
| 33 } | 35 } |
| 34 | 36 |
| 35 } // content | 37 } // content |
| 36 | 38 |
| 37 #endif // BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) | 39 #endif |
| OLD | NEW |