Index: content/browser/browser_thread.cc |
diff --git a/content/browser/browser_thread.cc b/content/browser/browser_thread.cc |
index c3b400540e8d8897a68ea7cccccd4340f4b65908..84fa13b8cfe5470273d55ef84cee285a8b1de4fb 100644 |
--- a/content/browser/browser_thread.cc |
+++ b/content/browser/browser_thread.cc |
@@ -7,6 +7,7 @@ |
#include "base/bind.h" |
#include "base/message_loop.h" |
#include "base/message_loop_proxy.h" |
+#include "base/synchronization/waitable_event.h" |
#include "base/threading/thread_restrictions.h" |
// Friendly names for the well-known threads. |
@@ -252,6 +253,22 @@ bool BrowserThread::GetCurrentThreadIdentifier(ID* identifier) { |
} |
// static |
+bool BrowserThread::WaitForPendingTasksOn(ID identifier) { |
+ // Avoid deadlocking self. |
+ if (CurrentlyOn(identifier)) |
+ return false; |
+ base::WaitableEvent event(true /* manual reset */, |
+ false /* not initially signaled */); |
+ if (!PostTask(identifier, |
+ FROM_HERE, |
+ base::Bind(&base::WaitableEvent::Signal, |
+ base::Unretained(&event)))) |
+ return false; |
+ event.Wait(); |
+ return true; |
+} |
+ |
+// static |
scoped_refptr<base::MessageLoopProxy> |
BrowserThread::GetMessageLoopProxyForThread( |
ID identifier) { |