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

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

Issue 28154: Make IPC::Logging register to watch for message loop destruction. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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/browser/browser_uitest.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/message_loop.h"
13 #include "base/singleton.h" 14 #include "base/singleton.h"
14 #include "base/waitable_event_watcher.h" 15 #include "base/waitable_event_watcher.h"
15 #include "chrome/common/ipc_message_utils.h" 16 #include "chrome/common/ipc_message_utils.h"
16 17
17 class MessageLoop; 18 class MessageLoop;
18 19
19 namespace IPC { 20 namespace IPC {
20 21
21 class Message; 22 class Message;
22 23
23 // One instance per process. Needs to be created on the main thread (the UI 24 // One instance per process. Needs to be created on the main thread (the UI
24 // thread in the browser) but OnPreDispatchMessage/OnPostDispatchMessage 25 // thread in the browser) but OnPreDispatchMessage/OnPostDispatchMessage
25 // can be called on other threads. 26 // can be called on other threads.
26 class Logging : public base::WaitableEventWatcher::Delegate { 27 class Logging : public base::WaitableEventWatcher::Delegate,
28 public MessageLoop::DestructionObserver {
27 public: 29 public:
28 // Implemented by consumers of log messages. 30 // Implemented by consumers of log messages.
29 class Consumer { 31 class Consumer {
30 public: 32 public:
31 virtual void Log(const LogData& data) = 0; 33 virtual void Log(const LogData& data) = 0;
32 }; 34 };
33 35
34 void SetConsumer(Consumer* consumer); 36 void SetConsumer(Consumer* consumer);
35 37
36 ~Logging(); 38 ~Logging();
(...skipping 23 matching lines...) Expand all
60 62
61 // Like the *MsgLog functions declared for each message class, except this 63 // Like the *MsgLog functions declared for each message class, except this
62 // calls the correct one based on the message type automatically. Defined in 64 // calls the correct one based on the message type automatically. Defined in
63 // ipc_logging.cc. 65 // ipc_logging.cc.
64 static void GetMessageText(uint16 type, std::wstring* name, 66 static void GetMessageText(uint16 type, std::wstring* name,
65 const Message* message, std::wstring* params); 67 const Message* message, std::wstring* params);
66 68
67 // WaitableEventWatcher::Delegate implementation 69 // WaitableEventWatcher::Delegate implementation
68 void OnWaitableEventSignaled(base::WaitableEvent* event); 70 void OnWaitableEventSignaled(base::WaitableEvent* event);
69 71
72 // MessageLoop::DestructionObserver implementation
73 void WillDestroyCurrentMessageLoop();
74
70 typedef void (*LogFunction)(uint16 type, 75 typedef void (*LogFunction)(uint16 type,
71 std::wstring* name, 76 std::wstring* name,
72 const Message* msg, 77 const Message* msg,
73 std::wstring* params); 78 std::wstring* params);
74 79
75 static void SetLoggerFunctions(LogFunction *functions); 80 static void SetLoggerFunctions(LogFunction *functions);
76 81
77 private: 82 private:
78 friend struct DefaultSingletonTraits<Logging>; 83 friend struct DefaultSingletonTraits<Logging>;
79 Logging(); 84 Logging();
(...skipping 20 matching lines...) Expand all
100 105
101 static LogFunction *log_function_mapping_; 106 static LogFunction *log_function_mapping_;
102 }; 107 };
103 108
104 } // namespace IPC 109 } // namespace IPC
105 110
106 #endif // IPC_MESSAGE_LOG_ENABLED 111 #endif // IPC_MESSAGE_LOG_ENABLED
107 112
108 #endif // CHROME_COMMON_IPC_LOGGING_H_ 113 #endif // CHROME_COMMON_IPC_LOGGING_H_
109 114
OLDNEW
« no previous file with comments | « chrome/browser/browser_uitest.cc ('k') | chrome/common/ipc_logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698