| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef IPC_IPC_LOGGING_H_ | 5 #ifndef IPC_IPC_LOGGING_H_ |
| 6 #define IPC_IPC_LOGGING_H_ | 6 #define IPC_IPC_LOGGING_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. | 10 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. |
| 9 | 11 |
| 10 #ifdef IPC_MESSAGE_LOG_ENABLED | 12 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 11 | 13 |
| 12 #include <vector> | 14 #include <vector> |
| 13 | 15 |
| 14 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
| 15 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
| 17 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 18 #include "ipc/ipc_export.h" | 20 #include "ipc/ipc_export.h" |
| 19 | 21 |
| 20 // Logging function. |name| is a string in ASCII and |params| is a string in | 22 // Logging function. |name| is a string in ASCII and |params| is a string in |
| 21 // UTF-8. | 23 // UTF-8. |
| 22 typedef void (*LogFunction)(std::string* name, | 24 typedef void (*LogFunction)(std::string* name, |
| 23 const IPC::Message* msg, | 25 const IPC::Message* msg, |
| 24 std::string* params); | 26 std::string* params); |
| 25 | 27 |
| 26 typedef base::hash_map<uint32, LogFunction > LogFunctionMap; | 28 typedef base::hash_map<uint32_t, LogFunction > LogFunctionMap; |
| 27 | 29 |
| 28 namespace IPC { | 30 namespace IPC { |
| 29 | 31 |
| 30 class Message; | 32 class Message; |
| 31 class Sender; | 33 class Sender; |
| 32 | 34 |
| 33 // One instance per process. Needs to be created on the main thread (the UI | 35 // One instance per process. Needs to be created on the main thread (the UI |
| 34 // thread in the browser) but OnPreDispatchMessage/OnPostDispatchMessage | 36 // thread in the browser) but OnPreDispatchMessage/OnPostDispatchMessage |
| 35 // can be called on other threads. | 37 // can be called on other threads. |
| 36 class IPC_EXPORT Logging { | 38 class IPC_EXPORT Logging { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 66 void OnReceivedLoggingMessage(const Message& message); | 68 void OnReceivedLoggingMessage(const Message& message); |
| 67 | 69 |
| 68 void OnSendMessage(Message* message, const std::string& channel_id); | 70 void OnSendMessage(Message* message, const std::string& channel_id); |
| 69 void OnPreDispatchMessage(const Message& message); | 71 void OnPreDispatchMessage(const Message& message); |
| 70 void OnPostDispatchMessage(const Message& message, | 72 void OnPostDispatchMessage(const Message& message, |
| 71 const std::string& channel_id); | 73 const std::string& channel_id); |
| 72 | 74 |
| 73 // Like the *MsgLog functions declared for each message class, except this | 75 // Like the *MsgLog functions declared for each message class, except this |
| 74 // calls the correct one based on the message type automatically. Defined in | 76 // calls the correct one based on the message type automatically. Defined in |
| 75 // ipc_logging.cc. | 77 // ipc_logging.cc. |
| 76 static void GetMessageText(uint32 type, std::string* name, | 78 static void GetMessageText(uint32_t type, std::string* name, |
| 77 const Message* message, std::string* params); | 79 const Message* message, std::string* params); |
| 78 | 80 |
| 79 static void set_log_function_map(LogFunctionMap* functions) { | 81 static void set_log_function_map(LogFunctionMap* functions) { |
| 80 log_function_map_ = functions; | 82 log_function_map_ = functions; |
| 81 } | 83 } |
| 82 | 84 |
| 83 static LogFunctionMap* log_function_map() { | 85 static LogFunctionMap* log_function_map() { |
| 84 return log_function_map_; | 86 return log_function_map_; |
| 85 } | 87 } |
| 86 | 88 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 Consumer* consumer_; | 120 Consumer* consumer_; |
| 119 | 121 |
| 120 static LogFunctionMap* log_function_map_; | 122 static LogFunctionMap* log_function_map_; |
| 121 }; | 123 }; |
| 122 | 124 |
| 123 } // namespace IPC | 125 } // namespace IPC |
| 124 | 126 |
| 125 #endif // IPC_MESSAGE_LOG_ENABLED | 127 #endif // IPC_MESSAGE_LOG_ENABLED |
| 126 | 128 |
| 127 #endif // IPC_IPC_LOGGING_H_ | 129 #endif // IPC_IPC_LOGGING_H_ |
| OLD | NEW |