blob: 9224726dcc8f231e7009240e2265b29f2b9caa84 (
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
|
// Copyright (c) 2011 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/test/test_browser_thread.h"
#include "base/message_loop.h"
#include "base/threading/thread.h"
#include "content/browser/browser_thread_impl.h"
namespace content {
// This gives access to set_message_loop().
class TestBrowserThreadImpl : public BrowserThreadImpl {
public:
explicit TestBrowserThreadImpl(BrowserThread::ID identifier)
: BrowserThreadImpl(identifier) {
}
TestBrowserThreadImpl(BrowserThread::ID identifier,
MessageLoop* message_loop)
: BrowserThreadImpl(identifier, message_loop) {
}
virtual ~TestBrowserThreadImpl() {
Stop();
}
void set_message_loop(MessageLoop* loop) {
Thread::set_message_loop(loop);
}
private:
DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl);
};
TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier)
: impl_(new TestBrowserThreadImpl(identifier)) {
}
TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier,
MessageLoop* message_loop)
: impl_(new TestBrowserThreadImpl(identifier, message_loop)) {
}
TestBrowserThread::~TestBrowserThread() {
Stop();
}
bool TestBrowserThread::Start() {
return impl_->Start();
}
bool TestBrowserThread::StartIOThread() {
base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO;
return impl_->StartWithOptions(options);
}
void TestBrowserThread::Stop() {
impl_->Stop();
}
bool TestBrowserThread::IsRunning() {
return impl_->IsRunning();
}
base::Thread* TestBrowserThread::DeprecatedGetThreadObject() {
return impl_.get();
}
void TestBrowserThread::DeprecatedSetMessageLoop(MessageLoop* loop) {
impl_->set_message_loop(loop);
}
} // namespace content
|