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

Unified Diff: content/public/test/test_browser_thread_bundle.cc

Issue 22799005: Flush the blocking pool in TestBrowserThreadBundle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: flush the message loop one extra time Created 7 years, 4 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
« no previous file with comments | « content/browser/browser_thread_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/test_browser_thread_bundle.cc
diff --git a/content/public/test/test_browser_thread_bundle.cc b/content/public/test/test_browser_thread_bundle.cc
index 7d2e58e708f8ac0016c31ab579c3fcfdf2bc29ae..9cf83c96763e990f5675b8762cc06d7523b6dab9 100644
--- a/content/public/test/test_browser_thread_bundle.cc
+++ b/content/public/test/test_browser_thread_bundle.cc
@@ -6,6 +6,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
+#include "content/browser/browser_thread_impl.h"
#include "content/public/test/test_browser_thread.h"
namespace content {
@@ -19,6 +20,12 @@ TestBrowserThreadBundle::TestBrowserThreadBundle(int options) {
}
TestBrowserThreadBundle::~TestBrowserThreadBundle() {
+ // To avoid memory leaks, we must ensure that any tasks posted to the blocking
+ // pool via PostTaskAndReply are able to reply back to the originating thread.
+ // Thus we must flush the blocking pool while the browser threads still exist.
+ base::RunLoop().RunUntilIdle();
+ BrowserThreadImpl::FlushThreadPoolHelper();
awong 2013/08/12 18:45:53 I'm thinking this should be done after db_thread_
earthdok 2013/08/12 19:18:31 Note that our goal here is to be tidy, not to simu
awong 2013/08/12 19:29:10 I actually disagree with this strongly...the furth
+
// To ensure a clean teardown, each thread's message loop must be flushed
// just before the thread is destroyed. But destroying a fake thread does not
// automatically flush the message loop, so we have to do it manually.
« no previous file with comments | « content/browser/browser_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698