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

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: merged ToT Created 7 years, 6 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/public/test/test_browser_thread_bundle.h ('k') | content/public/test/test_renderer_host.h » ('j') | 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
new file mode 100644
index 0000000000000000000000000000000000000000..94537e366d8a414a7bbef6d0a354067fe163cffe
--- /dev/null
+++ b/content/public/test/test_browser_thread_bundle.cc
@@ -0,0 +1,98 @@
+// 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/message_loop.h"
+#include "base/run_loop.h"
+#include "content/public/test/test_browser_thread.h"
+
+namespace content {
+
+TestBrowserThreadBundle::TestBrowserThreadBundle() {
+ Init(DEFAULT);
+}
+
+TestBrowserThreadBundle::TestBrowserThreadBundle(int options) {
+ Init(options);
+}
+
+TestBrowserThreadBundle::~TestBrowserThreadBundle() {
+ base::RunLoop().RunUntilIdle();
+}
+
+void TestBrowserThreadBundle::Init(int options) {
+ if (options & IO_MAINLOOP) {
+ message_loop_.reset(new base::MessageLoopForIO());
+ } else {
+ message_loop_.reset(new base::MessageLoopForUI());
+ }
+
+ ui_thread_.reset(new TestBrowserThread(BrowserThread::UI,
+ message_loop_.get()));
+
+ if (options & REAL_DB_THREAD) {
+ db_thread_.reset(new TestBrowserThread(BrowserThread::DB));
+ db_thread_->Start();
+ } else {
+ db_thread_.reset(new TestBrowserThread(BrowserThread::DB,
+ message_loop_.get()));
+ }
+
+ if (options & REAL_WEBKIT_DEPRECATED_THREAD) {
+ webkit_deprecated_thread_.reset(
+ new TestBrowserThread(BrowserThread::WEBKIT_DEPRECATED));
+ webkit_deprecated_thread_->Start();
+ } else {
+ webkit_deprecated_thread_.reset(
+ new TestBrowserThread(BrowserThread::WEBKIT_DEPRECATED,
+ message_loop_.get()));
+ }
+
+ if (options & REAL_FILE_THREAD) {
+ file_thread_.reset(new TestBrowserThread(BrowserThread::FILE));
+ file_thread_->Start();
+ } else {
+ file_thread_.reset(new TestBrowserThread(BrowserThread::FILE,
+ message_loop_.get()));
+ }
+
+ if (options & REAL_FILE_USER_BLOCKING_THREAD) {
+ file_user_blocking_thread_.reset(
+ new TestBrowserThread(BrowserThread::FILE_USER_BLOCKING));
+ file_user_blocking_thread_->Start();
+ } else {
+ file_user_blocking_thread_.reset(
+ new TestBrowserThread(BrowserThread::FILE_USER_BLOCKING,
+ message_loop_.get()));
+ }
+
+ if (options & REAL_PROCESS_LAUNCHER_THREAD) {
+ process_launcher_thread_.reset(
+ new TestBrowserThread(BrowserThread::PROCESS_LAUNCHER));
+ process_launcher_thread_->Start();
+ } else {
+ process_launcher_thread_.reset(
+ new TestBrowserThread(BrowserThread::PROCESS_LAUNCHER,
+ message_loop_.get()));
+ }
+
+ if (options & REAL_CACHE_THREAD) {
+ cache_thread_.reset(new TestBrowserThread(BrowserThread::CACHE));
+ cache_thread_->Start();
+ } else {
+ cache_thread_.reset(new TestBrowserThread(BrowserThread::CACHE,
+ message_loop_.get()));
+ }
+
+ if (options & REAL_IO_THREAD) {
+ io_thread_.reset(new TestBrowserThread(BrowserThread::IO));
+ io_thread_->StartIOThread();
+ } else {
+ io_thread_.reset(
+ new TestBrowserThread(BrowserThread::IO, message_loop_.get()));
+ }
+}
+
+} // namespace content
« no previous file with comments | « content/public/test/test_browser_thread_bundle.h ('k') | content/public/test/test_renderer_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698