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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. | 9 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. |
10 | 10 |
11 #ifdef IPC_MESSAGE_LOG_ENABLED | 11 #ifdef IPC_MESSAGE_LOG_ENABLED |
12 | 12 |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/hash_tables.h" | 15 #include "base/hash_tables.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/singleton.h" | 17 #include "base/memory/singleton.h" |
18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
| 19 #include "ipc/ipc_export.h" |
19 | 20 |
20 // Logging function. |name| is a string in ASCII and |params| is a string in | 21 // Logging function. |name| is a string in ASCII and |params| is a string in |
21 // UTF-8. | 22 // UTF-8. |
22 typedef void (*LogFunction)(std::string* name, | 23 typedef void (*LogFunction)(std::string* name, |
23 const IPC::Message* msg, | 24 const IPC::Message* msg, |
24 std::string* params); | 25 std::string* params); |
25 | 26 |
26 typedef base::hash_map<uint32, LogFunction > LogFunctionMap; | 27 typedef base::hash_map<uint32, LogFunction > LogFunctionMap; |
27 | 28 |
28 namespace IPC { | 29 namespace IPC { |
29 | 30 |
30 class Message; | 31 class Message; |
31 | 32 |
32 // One instance per process. Needs to be created on the main thread (the UI | 33 // One instance per process. Needs to be created on the main thread (the UI |
33 // thread in the browser) but OnPreDispatchMessage/OnPostDispatchMessage | 34 // thread in the browser) but OnPreDispatchMessage/OnPostDispatchMessage |
34 // can be called on other threads. | 35 // can be called on other threads. |
35 class Logging { | 36 class IPC_EXPORT Logging { |
36 public: | 37 public: |
37 // Implemented by consumers of log messages. | 38 // Implemented by consumers of log messages. |
38 class Consumer { | 39 class Consumer { |
39 public: | 40 public: |
40 virtual void Log(const LogData& data) = 0; | 41 virtual void Log(const LogData& data) = 0; |
41 | 42 |
42 protected: | 43 protected: |
43 virtual ~Consumer() {} | 44 virtual ~Consumer() {} |
44 }; | 45 }; |
45 | 46 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 Consumer* consumer_; | 103 Consumer* consumer_; |
103 | 104 |
104 static LogFunctionMap* log_function_map_; | 105 static LogFunctionMap* log_function_map_; |
105 }; | 106 }; |
106 | 107 |
107 } // namespace IPC | 108 } // namespace IPC |
108 | 109 |
109 #endif // IPC_MESSAGE_LOG_ENABLED | 110 #endif // IPC_MESSAGE_LOG_ENABLED |
110 | 111 |
111 #endif // IPC_IPC_LOGGING_H_ | 112 #endif // IPC_IPC_LOGGING_H_ |
OLD | NEW |