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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/public/test/test_browser_thread_bundle.h"
6
7 #include "base/message_loop.h"
8 #include "base/run_loop.h"
9 #include "content/public/test/test_browser_thread.h"
10
11 namespace content {
12
13 TestBrowserThreadBundle::TestBrowserThreadBundle() {
14 Init(DEFAULT);
15 }
16
17 TestBrowserThreadBundle::TestBrowserThreadBundle(int options) {
18 Init(options);
19 }
20
21 TestBrowserThreadBundle::~TestBrowserThreadBundle() {
22 base::RunLoop().RunUntilIdle();
23 }
24
25 void TestBrowserThreadBundle::Init(int options) {
26 if (options & IO_MAINLOOP) {
27 message_loop_.reset(new base::MessageLoopForIO());
28 } else {
29 message_loop_.reset(new base::MessageLoopForUI());
30 }
31
32 ui_thread_.reset(new TestBrowserThread(BrowserThread::UI,
33 message_loop_.get()));
34
35 if (options & REAL_DB_THREAD) {
36 db_thread_.reset(new TestBrowserThread(BrowserThread::DB));
37 db_thread_->Start();
38 } else {
39 db_thread_.reset(new TestBrowserThread(BrowserThread::DB,
40 message_loop_.get()));
41 }
42
43 if (options & REAL_WEBKIT_DEPRECATED_THREAD) {
44 webkit_deprecated_thread_.reset(
45 new TestBrowserThread(BrowserThread::WEBKIT_DEPRECATED));
46 webkit_deprecated_thread_->Start();
47 } else {
48 webkit_deprecated_thread_.reset(
49 new TestBrowserThread(BrowserThread::WEBKIT_DEPRECATED,
50 message_loop_.get()));
51 }
52
53 if (options & REAL_FILE_THREAD) {
54 file_thread_.reset(new TestBrowserThread(BrowserThread::FILE));
55 file_thread_->Start();
56 } else {
57 file_thread_.reset(new TestBrowserThread(BrowserThread::FILE,
58 message_loop_.get()));
59 }
60
61 if (options & REAL_FILE_USER_BLOCKING_THREAD) {
62 file_user_blocking_thread_.reset(
63 new TestBrowserThread(BrowserThread::FILE_USER_BLOCKING));
64 file_user_blocking_thread_->Start();
65 } else {
66 file_user_blocking_thread_.reset(
67 new TestBrowserThread(BrowserThread::FILE_USER_BLOCKING,
68 message_loop_.get()));
69 }
70
71 if (options & REAL_PROCESS_LAUNCHER_THREAD) {
72 process_launcher_thread_.reset(
73 new TestBrowserThread(BrowserThread::PROCESS_LAUNCHER));
74 process_launcher_thread_->Start();
75 } else {
76 process_launcher_thread_.reset(
77 new TestBrowserThread(BrowserThread::PROCESS_LAUNCHER,
78 message_loop_.get()));
79 }
80
81 if (options & REAL_CACHE_THREAD) {
82 cache_thread_.reset(new TestBrowserThread(BrowserThread::CACHE));
83 cache_thread_->Start();
84 } else {
85 cache_thread_.reset(new TestBrowserThread(BrowserThread::CACHE,
86 message_loop_.get()));
87 }
88
89 if (options & REAL_IO_THREAD) {
90 io_thread_.reset(new TestBrowserThread(BrowserThread::IO));
91 io_thread_->StartIOThread();
92 } else {
93 io_thread_.reset(
94 new TestBrowserThread(BrowserThread::IO, message_loop_.get()));
95 }
96 }
97
98 } // namespace content
OLDNEW
« 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