OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/single_thread_task_runner.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/thread_task_runner_handle.h" |
19 #include "base/threading/thread.h" | 20 #include "base/threading/thread.h" |
20 #include "base/time/time.h" | 21 #include "base/time/time.h" |
21 #include "ipc/ipc_message_utils.h" | 22 #include "ipc/ipc_message_utils.h" |
22 #include "ipc/ipc_sender.h" | 23 #include "ipc/ipc_sender.h" |
23 #include "ipc/ipc_switches.h" | 24 #include "ipc/ipc_switches.h" |
24 #include "ipc/ipc_sync_message.h" | 25 #include "ipc/ipc_sync_message.h" |
25 | 26 |
26 #if defined(OS_POSIX) | 27 #if defined(OS_POSIX) |
27 #include <unistd.h> | 28 #include <unistd.h> |
28 #endif | 29 #endif |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 !message.received_time() || | 155 !message.received_time() || |
155 message.dont_log()) | 156 message.dont_log()) |
156 return; | 157 return; |
157 | 158 |
158 LogData data; | 159 LogData data; |
159 GenerateLogData(channel_id, message, &data, true); | 160 GenerateLogData(channel_id, message, &data, true); |
160 | 161 |
161 if (base::MessageLoop::current() == main_thread_) { | 162 if (base::MessageLoop::current() == main_thread_) { |
162 Log(data); | 163 Log(data); |
163 } else { | 164 } else { |
164 main_thread_->PostTask( | 165 main_thread_->task_runner()->PostTask( |
165 FROM_HERE, base::Bind(&Logging::Log, base::Unretained(this), data)); | 166 FROM_HERE, base::Bind(&Logging::Log, base::Unretained(this), data)); |
166 } | 167 } |
167 } | 168 } |
168 | 169 |
169 void Logging::GetMessageText(uint32 type, std::string* name, | 170 void Logging::GetMessageText(uint32 type, std::string* name, |
170 const Message* message, | 171 const Message* message, |
171 std::string* params) { | 172 std::string* params) { |
172 if (!log_function_map_) | 173 if (!log_function_map_) |
173 return; | 174 return; |
174 | 175 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 void Logging::Log(const LogData& data) { | 225 void Logging::Log(const LogData& data) { |
225 if (consumer_) { | 226 if (consumer_) { |
226 // We're in the browser process. | 227 // We're in the browser process. |
227 consumer_->Log(data); | 228 consumer_->Log(data); |
228 } else { | 229 } else { |
229 // We're in the renderer or plugin processes. | 230 // We're in the renderer or plugin processes. |
230 if (sender_) { | 231 if (sender_) { |
231 queued_logs_.push_back(data); | 232 queued_logs_.push_back(data); |
232 if (!queue_invoke_later_pending_) { | 233 if (!queue_invoke_later_pending_) { |
233 queue_invoke_later_pending_ = true; | 234 queue_invoke_later_pending_ = true; |
234 base::MessageLoop::current()->PostDelayedTask( | 235 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
235 FROM_HERE, | 236 FROM_HERE, base::Bind(&Logging::OnSendLogs, base::Unretained(this)), |
236 base::Bind(&Logging::OnSendLogs, base::Unretained(this)), | |
237 base::TimeDelta::FromMilliseconds(kLogSendDelayMs)); | 237 base::TimeDelta::FromMilliseconds(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 = base::StringPrintf("[unknown type %d]", data.type); | 244 message_name = base::StringPrintf("[unknown type %d]", data.type); |
245 } else { | 245 } else { |
246 message_name = data.message_name; | 246 message_name = data.message_name; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |