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

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

Issue 14197014: Add TestBrowserThreadBundle into RenderViewHostTestHarness. Kill some unnecessary real threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address jyasskin's comments\ Created 7 years, 7 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..a1882c78c2171ea56284531eeb70b954120594df
--- /dev/null
+++ b/content/public/test/test_browser_thread_bundle.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/public/test/test_browser_thread_bundle.h"
+
+#include "base/run_loop.h"
+
+namespace content {
+
+TestBrowserThreadBundle::TestBrowserThreadBundle()
+ : ui_thread_(BrowserThread::UI, &message_loop_),
+ db_thread_(BrowserThread::DB, &message_loop_),
+ file_thread_(BrowserThread::FILE, &message_loop_),
+ file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING,
+ &message_loop_),
+ io_thread_(BrowserThread::IO, &message_loop_) {
+}
+
+TestBrowserThreadBundle::TestBrowserThreadBundle(int real_threads_mask)
+ : ui_thread_(BrowserThread::UI, &message_loop_),
+ db_thread_(BrowserThread::DB,
+ real_threads_mask & REAL_DB_THREAD ? NULL : &message_loop_),
+ file_thread_(BrowserThread::FILE,
+ real_threads_mask & REAL_FILE_THREAD ? NULL : &message_loop_),
+ file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING,
+ real_threads_mask & REAL_FILE_USER_BLOCKING_THREAD ?
+ NULL : &message_loop_),
+ io_thread_(BrowserThread::IO,
+ real_threads_mask & REAL_IO_THREAD ? NULL : &message_loop_) {
+ if (real_threads_mask & REAL_DB_THREAD) {
+ db_thread_.Start();
+ }
+ if (real_threads_mask & REAL_FILE_THREAD) {
+ file_thread_.Start();
+ }
+ if (real_threads_mask & REAL_FILE_USER_BLOCKING_THREAD) {
+ file_user_blocking_thread_.Start();
+ }
+ if (real_threads_mask & REAL_IO_THREAD) {
+ io_thread_.StartIOThread();
+ }
+}
+
+TestBrowserThreadBundle::~TestBrowserThreadBundle() {
+ base::RunLoop().RunUntilIdle();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698