Index: base/synchronization/waitable_event_posix.cc |
diff --git a/base/synchronization/waitable_event_posix.cc b/base/synchronization/waitable_event_posix.cc |
index b32c882711638f497c7e260398c7eca265202565..a8b686b88ce8ff583f68daad2c37e63efe1b1c67 100644 |
--- a/base/synchronization/waitable_event_posix.cc |
+++ b/base/synchronization/waitable_event_posix.cc |
@@ -7,6 +7,7 @@ |
#include <algorithm> |
#include <vector> |
+#include "base/debug/activity_tracker.h" |
#include "base/logging.h" |
#include "base/synchronization/condition_variable.h" |
#include "base/synchronization/lock.h" |
@@ -157,6 +158,9 @@ void WaitableEvent::Wait() { |
} |
bool WaitableEvent::TimedWait(const TimeDelta& max_time) { |
+ // Record the event that this thread is blocking upon (for hang diagnosis). |
+ base::debug::ScopedEventWaitActivity event_activity(this); |
+ |
base::ThreadRestrictions::AssertWaitAllowed(); |
const TimeTicks end_time(TimeTicks::Now() + max_time); |
const bool finite_time = max_time.ToInternalValue() >= 0; |
@@ -232,6 +236,9 @@ size_t WaitableEvent::WaitMany(WaitableEvent** raw_waitables, |
base::ThreadRestrictions::AssertWaitAllowed(); |
DCHECK(count) << "Cannot wait on no events"; |
+ // Record an event (the first) that this thread is blocking upon. |
+ base::debug::ScopedEventWaitActivity event_activity(raw_waitables[0]); |
+ |
// We need to acquire the locks in a globally consistent order. Thus we sort |
// the array of waitables by address. We actually sort a pairs so that we can |
// map back to the original index values later. |