Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: chrome/common/ipc_logging.h

Issue 21039: Revert my change to get the tree green. Not sure why the tests became flaky.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/ipc_fuzzing_tests.cc ('k') | chrome/common/ipc_logging.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 CHROME_COMMON_IPC_LOGGING_H_ 5 #ifndef CHROME_COMMON_IPC_LOGGING_H_
6 #define CHROME_COMMON_IPC_LOGGING_H_ 6 #define CHROME_COMMON_IPC_LOGGING_H_
7 7
8 #include "chrome/common/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. 8 #include "chrome/common/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
9 9
10 #ifdef IPC_MESSAGE_LOG_ENABLED 10 #ifdef IPC_MESSAGE_LOG_ENABLED
11 11
12 #include "base/lock.h" 12 #include "base/lock.h"
13 #include "base/object_watcher.h" 13 #include "base/object_watcher.h"
14 #include "base/singleton.h" 14 #include "base/singleton.h"
15 #include "chrome/common/ipc_message_utils.h"
16 15
17 class MessageLoop; 16 class MessageLoop;
18 17
19 namespace IPC { 18 namespace IPC {
20 19
21 class Message; 20 class Message;
22 21
23 // One instance per process. Needs to be created on the main thread (the UI 22 // One instance per process. Needs to be created on the main thread (the UI
24 // thread in the browser) but OnPreDispatchMessage/OnPostDispatchMessage 23 // thread in the browser) but OnPreDispatchMessage/OnPostDispatchMessage
25 // can be called on other threads. 24 // can be called on other threads.
26 class Logging : public base::ObjectWatcher::Delegate { 25 class Logging : public base::ObjectWatcher::Delegate {
27 public: 26 public:
28 // Implemented by consumers of log messages. 27 // Implemented by consumers of log messages.
29 class Consumer { 28 class Consumer {
30 public: 29 public:
31 virtual void Log(const LogData& data) = 0; 30 virtual void Log(const IPC::LogData& data) = 0;
32 }; 31 };
33 32
34 void SetConsumer(Consumer* consumer); 33 void SetConsumer(Consumer* consumer);
35 34
36 ~Logging(); 35 ~Logging();
37 static Logging* current(); 36 static Logging* current();
38 37
39 void Enable(); 38 void Enable();
40 void Disable(); 39 void Disable();
41 bool inline Enabled() const; 40 bool inline Enabled() const;
42 41
43 // Called by child processes to give the logger object the channel to send 42 // Called by child processes to give the logger object the channel to send
44 // logging data to the browser process. 43 // logging data to the browser process.
45 void SetIPCSender(Message::Sender* sender); 44 void SetIPCSender(IPC::Message::Sender* sender);
46 45
47 // Called in the browser process when logging data from a child process is 46 // Called in the browser process when logging data from a child process is
48 // received. 47 // received.
49 void OnReceivedLoggingMessage(const Message& message); 48 void OnReceivedLoggingMessage(const Message& message);
50 49
51 void OnSendMessage(Message* message, const std::wstring& channel_id); 50 void OnSendMessage(Message* message, const std::wstring& channel_id);
52 void OnPreDispatchMessage(const Message& message); 51 void OnPreDispatchMessage(const Message& message);
53 void OnPostDispatchMessage(const Message& message, 52 void OnPostDispatchMessage(const Message& message,
54 const std::wstring& channel_id); 53 const std::wstring& channel_id);
55 54
56 // Returns the name of the logging enabled/disabled events so that the 55 // Returns the name of the logging enabled/disabled events so that the
57 // sandbox can add them to to the policy. If true, gets the name of the 56 // sandbox can add them to to the policy. If true, gets the name of the
58 // enabled event, if false, gets the name of the disabled event. 57 // enabled event, if false, gets the name of the disabled event.
59 static std::wstring GetEventName(bool enabled); 58 static std::wstring GetEventName(bool enabled);
60 59
61 // Like the *MsgLog functions declared for each message class, except this 60 // Like the *MsgLog functions declared for each message class, except this
62 // calls the correct one based on the message type automatically. Defined in 61 // calls the correct one based on the message type automatically. Defined in
63 // ipc_logging.cc. 62 // ipc_logging.cc.
64 static void GetMessageText(uint16 type, std::wstring* name, 63 static void GetMessageText(uint16 type, std::wstring* name,
65 const Message* message, std::wstring* params); 64 const Message* message, std::wstring* params);
66 65
67 // ObjectWatcher::Delegate implementation 66 // ObjectWatcher::Delegate implementation
68 void OnObjectSignaled(HANDLE object); 67 void OnObjectSignaled(HANDLE object);
69 68
70 typedef void (LogFunction)(uint16 type,
71 std::wstring* name,
72 const Message* msg,
73 std::wstring* params);
74 void RegisterMessageLogger(int msg_start, LogFunction* func);
75
76 private: 69 private:
77 friend struct DefaultSingletonTraits<Logging>; 70 friend struct DefaultSingletonTraits<IPC::Logging>;
78 Logging(); 71 Logging();
79 72
80 std::wstring GetEventName(int browser_pid, bool enabled); 73 std::wstring GetEventName(int browser_pid, bool enabled);
81 void OnSendLogs(); 74 void OnSendLogs();
82 void Log(const LogData& data); 75 void Log(const LogData& data);
83 76
84 void RegisterWaitForEvent(bool enabled); 77 void RegisterWaitForEvent(bool enabled);
85 78
86 base::ObjectWatcher watcher_; 79 base::ObjectWatcher watcher_;
87 80
88 HANDLE logging_event_on_; 81 HANDLE logging_event_on_;
89 HANDLE logging_event_off_; 82 HANDLE logging_event_off_;
90 bool enabled_; 83 bool enabled_;
91 84
92 std::vector<LogData> queued_logs_; 85 std::vector<LogData> queued_logs_;
93 bool queue_invoke_later_pending_; 86 bool queue_invoke_later_pending_;
94 87
95 Message::Sender* sender_; 88 IPC::Message::Sender* sender_;
96 MessageLoop* main_thread_; 89 MessageLoop* main_thread_;
97 90
98 Consumer* consumer_; 91 Consumer* consumer_;
99
100 LogFunction* log_function_mapping_[LastMsgIndex];
101 }; 92 };
102 93
103 } // namespace IPC 94 } // namespace IPC
104 95
105 #endif // IPC_MESSAGE_LOG_ENABLED 96 #endif // IPC_MESSAGE_LOG_ENABLED
106 97
107 #endif // CHROME_COMMON_IPC_LOGGING_H_ 98 #endif // CHROME_COMMON_IPC_LOGGING_H_
108 99
OLDNEW
« no previous file with comments | « chrome/common/ipc_fuzzing_tests.cc ('k') | chrome/common/ipc_logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698