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

Unified Diff: content/browser/browser_thread.cc

Issue 8274012: Wait for URLBlacklist update tasks on automation tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added BrowserThread::WaitForPendingTasksOn, removed SignalingTask Created 9 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« content/browser/browser_thread.h ('K') | « content/browser/browser_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« content/browser/browser_thread.h ('K') | « content/browser/browser_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698