blob: 6318e710ea2989d9ba7204dafaf7c3d772d27f19 (
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
|
// Copyright 2014 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 "ios/web/public/test/test_web_thread.h"
#include "content/public/test/test_browser_thread.h"
#include "ios/web/web_thread_impl.h"
namespace web {
// TestWebThreadImpl delegates to content::TestBrowserThread until WebThread
// implementation is indenpendent of content::BrowserThread.
class TestWebThreadImpl {
public:
TestWebThreadImpl(WebThread::ID identifier)
: test_browser_thread_(BrowserThreadIDFromWebThreadID(identifier)) {}
TestWebThreadImpl(WebThread::ID identifier, base::MessageLoop* message_loop)
: test_browser_thread_(BrowserThreadIDFromWebThreadID(identifier),
message_loop) {}
~TestWebThreadImpl() { Stop(); }
bool Start() { return test_browser_thread_.Start(); }
bool StartIOThread() { return test_browser_thread_.StartIOThread(); }
void Stop() { test_browser_thread_.Stop(); }
bool IsRunning() { return test_browser_thread_.IsRunning(); }
private:
content::TestBrowserThread test_browser_thread_;
};
TestWebThread::TestWebThread(WebThread::ID identifier)
: impl_(new TestWebThreadImpl(identifier)) {
}
TestWebThread::TestWebThread(WebThread::ID identifier,
base::MessageLoop* message_loop)
: impl_(new TestWebThreadImpl(identifier, message_loop)) {
}
TestWebThread::~TestWebThread() {
}
bool TestWebThread::Start() {
return impl_->Start();
}
bool TestWebThread::StartIOThread() {
return impl_->StartIOThread();
}
void TestWebThread::Stop() {
impl_->Stop();
}
bool TestWebThread::IsRunning() {
return impl_->IsRunning();
}
} // namespace web
|