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

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: Review fix. 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"
12 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 13 #include "base/command_line.h"
12 #include "base/location.h" 14 #include "base/location.h"
13 #include "base/logging.h" 15 #include "base/logging.h"
14 #include "base/message_loop.h" 16 #include "base/message_loop.h"
15 #include "base/process_util.h" 17 #include "base/process_util.h"
16 #include "base/string_number_conversions.h" 18 #include "base/string_number_conversions.h"
17 #include "base/string_util.h" 19 #include "base/string_util.h"
18 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
19 #include "base/time.h" 21 #include "base/time.h"
20 #include "ipc/ipc_switches.h" 22 #include "ipc/ipc_switches.h"
21 #include "ipc/ipc_sync_message.h" 23 #include "ipc/ipc_sync_message.h"
22 #include "ipc/ipc_message_utils.h" 24 #include "ipc/ipc_message_utils.h"
23 25
24 #if defined(OS_POSIX) 26 #if defined(OS_POSIX)
25 #include <unistd.h> 27 #include <unistd.h>
26 #endif 28 #endif
27 29
28 #ifdef IPC_MESSAGE_LOG_ENABLED 30 #ifdef IPC_MESSAGE_LOG_ENABLED
29 31
30 using base::Time; 32 using base::Time;
31 33
32 // IPC::Logging is allocated as a singleton, so we don't need any kind of
33 // special retention program.
34 DISABLE_RUNNABLE_METHOD_REFCOUNT(IPC::Logging);
35
36 namespace IPC { 34 namespace IPC {
37 35
38 const int kLogSendDelayMs = 100; 36 const int kLogSendDelayMs = 100;
39 37
40 // We use a pointer to the function table to avoid any linker dependencies on 38 // We use a pointer to the function table to avoid any linker dependencies on
41 // all the traits used as IPC message parameters. 39 // all the traits used as IPC message parameters.
42 LogFunctionMap* Logging::log_function_map_; 40 LogFunctionMap* Logging::log_function_map_;
43 41
44 Logging::Logging() 42 Logging::Logging()
45 : enabled_(false), 43 : enabled_(false),
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 !message.received_time() || 154 !message.received_time() ||
157 message.dont_log()) 155 message.dont_log())
158 return; 156 return;
159 157
160 LogData data; 158 LogData data;
161 GenerateLogData(channel_id, message, &data, true); 159 GenerateLogData(channel_id, message, &data, true);
162 160
163 if (MessageLoop::current() == main_thread_) { 161 if (MessageLoop::current() == main_thread_) {
164 Log(data); 162 Log(data);
165 } else { 163 } else {
166 main_thread_->PostTask(FROM_HERE, NewRunnableMethod( 164 main_thread_->PostTask(
167 this, &Logging::Log, data)); 165 FROM_HERE, base::Bind(&Logging::Log, base::Unretained(this), data));
168 } 166 }
169 } 167 }
170 168
171 void Logging::GetMessageText(uint32 type, std::string* name, 169 void Logging::GetMessageText(uint32 type, std::string* name,
172 const Message* message, 170 const Message* message,
173 std::string* params) { 171 std::string* params) {
174 if (!log_function_map_) 172 if (!log_function_map_)
175 return; 173 return;
176 174
177 LogFunctionMap::iterator it = log_function_map_->find(type); 175 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) { 224 void Logging::Log(const LogData& data) {
227 if (consumer_) { 225 if (consumer_) {
228 // We're in the browser process. 226 // We're in the browser process.
229 consumer_->Log(data); 227 consumer_->Log(data);
230 } else { 228 } else {
231 // We're in the renderer or plugin processes. 229 // We're in the renderer or plugin processes.
232 if (sender_) { 230 if (sender_) {
233 queued_logs_.push_back(data); 231 queued_logs_.push_back(data);
234 if (!queue_invoke_later_pending_) { 232 if (!queue_invoke_later_pending_) {
235 queue_invoke_later_pending_ = true; 233 queue_invoke_later_pending_ = true;
236 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( 234 MessageLoop::current()->PostDelayedTask(
237 this, &Logging::OnSendLogs), kLogSendDelayMs); 235 FROM_HERE, base::Bind(&Logging::OnSendLogs, base::Unretained(this)),
236 kLogSendDelayMs);
238 } 237 }
239 } 238 }
240 } 239 }
241 if (enabled_on_stderr_) { 240 if (enabled_on_stderr_) {
242 std::string message_name; 241 std::string message_name;
243 if (data.message_name.empty()) { 242 if (data.message_name.empty()) {
244 message_name = StringPrintf("[unknown type %d]", data.type); 243 message_name = StringPrintf("[unknown type %d]", data.type);
245 } else { 244 } else {
246 message_name = data.message_name; 245 message_name = data.message_name;
247 } 246 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 data->receive = message.received_time(); 305 data->receive = message.received_time();
307 data->dispatch = Time::Now().ToInternalValue(); 306 data->dispatch = Time::Now().ToInternalValue();
308 data->params = params; 307 data->params = params;
309 data->message_name = message_name; 308 data->message_name = message_name;
310 } 309 }
311 } 310 }
312 311
313 } 312 }
314 313
315 #endif // IPC_MESSAGE_LOG_ENABLED 314 #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