Adding more detail to MessageQueue::Dispatch logging.
Every message will now be traced with the location from which it was
posted, including function name, file and line number.
This CL also writes a normal LOG message when the dispatch took more
than a certain amount of time (currently 50ms).
This logging should help us identify messages that are taking
longer than expected to be dispatched.
R=pthatcher@webrtc.org, tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2019423006 .
Cr-Commit-Position: refs/heads/master@{#13104}
diff --git a/webrtc/base/thread.cc b/webrtc/base/thread.cc
index c6dc3c4..5278c93 100644
--- a/webrtc/base/thread.cc
+++ b/webrtc/base/thread.cc
@@ -26,14 +26,13 @@
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/base/timeutils.h"
+#include "webrtc/base/trace_event.h"
#if !__has_feature(objc_arc) && (defined(WEBRTC_MAC))
#include "webrtc/base/maccocoathreadhelper.h"
#include "webrtc/base/scoped_autorelease_pool.h"
#endif
-#include "webrtc/base/trace_event.h"
-
namespace rtc {
ThreadManager* ThreadManager::Instance() {
@@ -343,7 +342,10 @@
Join();
}
-void Thread::Send(MessageHandler* phandler, uint32_t id, MessageData* pdata) {
+void Thread::Send(const Location& posted_from,
+ MessageHandler* phandler,
+ uint32_t id,
+ MessageData* pdata) {
if (fStop_)
return;
@@ -351,6 +353,7 @@
// of "thread", like Win32 SendMessage. If in the right context,
// call the handler directly.
Message msg;
+ msg.posted_from = posted_from;
msg.phandler = phandler;
msg.message_id = id;
msg.pdata = pdata;
@@ -444,12 +447,12 @@
return false;
}
-void Thread::InvokeBegin() {
- TRACE_EVENT_BEGIN0("webrtc", "Thread::Invoke");
-}
-
-void Thread::InvokeEnd() {
- TRACE_EVENT_END0("webrtc", "Thread::Invoke");
+void Thread::InvokeInternal(const Location& posted_from,
+ MessageHandler* handler) {
+ TRACE_EVENT2("webrtc", "Thread::Invoke", "src_file_and_line",
+ posted_from.file_and_line(), "src_func",
+ posted_from.function_name());
+ Send(posted_from, handler);
}
void Thread::Clear(MessageHandler* phandler,