blob: a9a1c199c3a94a6d0c9de89aa7e3f069041ce6e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// Copyright 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
|