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

Side by Side Diff: ipc/ipc_logging.cc

Issue 8539036: base:Bind: Convert ipc/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | « ipc/ipc_channel_win.cc ('k') | ipc/ipc_sync_channel.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) 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 #include "ipc/ipc_logging.h" 5 #include "ipc/ipc_logging.h"
6 6
7 #ifdef IPC_MESSAGE_LOG_ENABLED 7 #ifdef IPC_MESSAGE_LOG_ENABLED
8 #define IPC_MESSAGE_MACROS_LOG_ENABLED 8 #define IPC_MESSAGE_MACROS_LOG_ENABLED
9 #endif 9 #endif
10 10
11 #include "base/bind.h"
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/message_loop.h" 15 #include "base/message_loop.h"
15 #include "base/process_util.h" 16 #include "base/process_util.h"
16 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
17 #include "base/string_util.h" 18 #include "base/string_util.h"
18 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
19 #include "base/time.h" 20 #include "base/time.h"
20 #include "ipc/ipc_switches.h" 21 #include "ipc/ipc_switches.h"
21 #include "ipc/ipc_sync_message.h" 22 #include "ipc/ipc_sync_message.h"
22 #include "ipc/ipc_message_utils.h" 23 #include "ipc/ipc_message_utils.h"
23 24
24 #if defined(OS_POSIX) 25 #if defined(OS_POSIX)
25 #include <unistd.h> 26 #include <unistd.h>
26 #endif 27 #endif
27 28
28 #ifdef IPC_MESSAGE_LOG_ENABLED 29 #ifdef IPC_MESSAGE_LOG_ENABLED
29 30
30 using base::Time; 31 using base::Time;
31 32
32 // IPC::Logging is allocated as a singleton, so we don't need any kind of 33 // IPC::Logging is allocated as a singleton, so we don't need any kind of
33 // special retention program. 34 // special retention program.
34 DISABLE_RUNNABLE_METHOD_REFCOUNT(IPC::Logging); 35 DISABLE_RUNNABLE_METHOD_REFCOUNT(IPC::Logging);
csilv 2011/11/12 03:49:50 Remove, obsolete
James Hawkins 2011/11/12 18:02:19 Damn this macro!! Done.
35 36
36 namespace IPC { 37 namespace IPC {
37 38
38 const int kLogSendDelayMs = 100; 39 const int kLogSendDelayMs = 100;
39 40
40 // We use a pointer to the function table to avoid any linker dependencies on 41 // We use a pointer to the function table to avoid any linker dependencies on
41 // all the traits used as IPC message parameters. 42 // all the traits used as IPC message parameters.
42 LogFunctionMap* Logging::log_function_map_; 43 LogFunctionMap* Logging::log_function_map_;
43 44
44 Logging::Logging() 45 Logging::Logging()
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 !message.received_time() || 157 !message.received_time() ||
157 message.dont_log()) 158 message.dont_log())
158 return; 159 return;
159 160
160 LogData data; 161 LogData data;
161 GenerateLogData(channel_id, message, &data, true); 162 GenerateLogData(channel_id, message, &data, true);
162 163
163 if (MessageLoop::current() == main_thread_) { 164 if (MessageLoop::current() == main_thread_) {
164 Log(data); 165 Log(data);
165 } else { 166 } else {
166 main_thread_->PostTask(FROM_HERE, NewRunnableMethod( 167 main_thread_->PostTask(FROM_HERE, base::Bind(&Logging::Log, this, data));
csilv 2011/11/12 03:49:50 make 'this' unretained, here and below
James Hawkins 2011/11/12 18:02:19 Done.
167 this, &Logging::Log, data));
168 } 168 }
169 } 169 }
170 170
171 void Logging::GetMessageText(uint32 type, std::string* name, 171 void Logging::GetMessageText(uint32 type, std::string* name,
172 const Message* message, 172 const Message* message,
173 std::string* params) { 173 std::string* params) {
174 if (!log_function_map_) 174 if (!log_function_map_)
175 return; 175 return;
176 176
177 LogFunctionMap::iterator it = log_function_map_->find(type); 177 LogFunctionMap::iterator it = log_function_map_->find(type);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 void Logging::Log(const LogData& data) { 226 void Logging::Log(const LogData& data) {
227 if (consumer_) { 227 if (consumer_) {
228 // We're in the browser process. 228 // We're in the browser process.
229 consumer_->Log(data); 229 consumer_->Log(data);
230 } else { 230 } else {
231 // We're in the renderer or plugin processes. 231 // We're in the renderer or plugin processes.
232 if (sender_) { 232 if (sender_) {
233 queued_logs_.push_back(data); 233 queued_logs_.push_back(data);
234 if (!queue_invoke_later_pending_) { 234 if (!queue_invoke_later_pending_) {
235 queue_invoke_later_pending_ = true; 235 queue_invoke_later_pending_ = true;
236 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( 236 MessageLoop::current()->PostDelayedTask(
237 this, &Logging::OnSendLogs), kLogSendDelayMs); 237 FROM_HERE, base::Bind(&Logging::OnSendLogs, this), kLogSendDelayMs);
238 } 238 }
239 } 239 }
240 } 240 }
241 if (enabled_on_stderr_) { 241 if (enabled_on_stderr_) {
242 std::string message_name; 242 std::string message_name;
243 if (data.message_name.empty()) { 243 if (data.message_name.empty()) {
244 message_name = StringPrintf("[unknown type %d]", data.type); 244 message_name = StringPrintf("[unknown type %d]", data.type);
245 } else { 245 } else {
246 message_name = data.message_name; 246 message_name = data.message_name;
247 } 247 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 data->receive = message.received_time(); 306 data->receive = message.received_time();
307 data->dispatch = Time::Now().ToInternalValue(); 307 data->dispatch = Time::Now().ToInternalValue();
308 data->params = params; 308 data->params = params;
309 data->message_name = message_name; 309 data->message_name = message_name;
310 } 310 }
311 } 311 }
312 312
313 } 313 }
314 314
315 #endif // IPC_MESSAGE_LOG_ENABLED 315 #endif // IPC_MESSAGE_LOG_ENABLED
OLDNEW
« no previous file with comments | « ipc/ipc_channel_win.cc ('k') | ipc/ipc_sync_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698