Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / web / test / test_web_thread_adapter.cc
blobe71558704fd0b420892d334c7557855d933d2b3f
1 // Copyright 2014 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.
5 #include "ios/web/public/test/test_web_thread.h"
7 #include "content/public/test/test_browser_thread.h"
8 #include "ios/web/web_thread_adapter.h"
10 namespace web {
12 // TestWebThreadImpl delegates to content::TestBrowserThread until WebThread
13 // implementation is indenpendent of content::BrowserThread.
14 class TestWebThreadImpl {
15 public:
16 TestWebThreadImpl(WebThread::ID identifier)
17 : test_browser_thread_(BrowserThreadIDFromWebThreadID(identifier)) {}
19 TestWebThreadImpl(WebThread::ID identifier, base::MessageLoop* message_loop)
20 : test_browser_thread_(BrowserThreadIDFromWebThreadID(identifier),
21 message_loop) {}
23 ~TestWebThreadImpl() { Stop(); }
25 bool Start() { return test_browser_thread_.Start(); }
27 bool StartIOThread() { return test_browser_thread_.StartIOThread(); }
29 void Stop() { test_browser_thread_.Stop(); }
31 bool IsRunning() { return test_browser_thread_.IsRunning(); }
33 private:
34 content::TestBrowserThread test_browser_thread_;
37 TestWebThread::TestWebThread(WebThread::ID identifier)
38 : impl_(new TestWebThreadImpl(identifier)) {
41 TestWebThread::TestWebThread(WebThread::ID identifier,
42 base::MessageLoop* message_loop)
43 : impl_(new TestWebThreadImpl(identifier, message_loop)) {
46 TestWebThread::~TestWebThread() {
49 bool TestWebThread::Start() {
50 return impl_->Start();
53 bool TestWebThread::StartIOThread() {
54 return impl_->StartIOThread();
57 void TestWebThread::Stop() {
58 impl_->Stop();
61 bool TestWebThread::IsRunning() {
62 return impl_->IsRunning();
65 } // namespace web