| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "ios/web/public/test/test_web_thread.h" | |
| 6 | |
| 7 #include "content/public/test/test_browser_thread.h" | |
| 8 #include "ios/web/web_thread_adapter.h" | |
| 9 | |
| 10 namespace web { | |
| 11 | |
| 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)) {} | |
| 18 | |
| 19 TestWebThreadImpl(WebThread::ID identifier, base::MessageLoop* message_loop) | |
| 20 : test_browser_thread_(BrowserThreadIDFromWebThreadID(identifier), | |
| 21 message_loop) {} | |
| 22 | |
| 23 ~TestWebThreadImpl() { Stop(); } | |
| 24 | |
| 25 bool Start() { return test_browser_thread_.Start(); } | |
| 26 | |
| 27 bool StartIOThread() { return test_browser_thread_.StartIOThread(); } | |
| 28 | |
| 29 void Stop() { test_browser_thread_.Stop(); } | |
| 30 | |
| 31 bool IsRunning() { return test_browser_thread_.IsRunning(); } | |
| 32 | |
| 33 private: | |
| 34 content::TestBrowserThread test_browser_thread_; | |
| 35 }; | |
| 36 | |
| 37 TestWebThread::TestWebThread(WebThread::ID identifier) | |
| 38 : impl_(new TestWebThreadImpl(identifier)) { | |
| 39 } | |
| 40 | |
| 41 TestWebThread::TestWebThread(WebThread::ID identifier, | |
| 42 base::MessageLoop* message_loop) | |
| 43 : impl_(new TestWebThreadImpl(identifier, message_loop)) { | |
| 44 } | |
| 45 | |
| 46 TestWebThread::~TestWebThread() { | |
| 47 } | |
| 48 | |
| 49 bool TestWebThread::Start() { | |
| 50 return impl_->Start(); | |
| 51 } | |
| 52 | |
| 53 bool TestWebThread::StartIOThread() { | |
| 54 return impl_->StartIOThread(); | |
| 55 } | |
| 56 | |
| 57 void TestWebThread::Stop() { | |
| 58 impl_->Stop(); | |
| 59 } | |
| 60 | |
| 61 bool TestWebThread::IsRunning() { | |
| 62 return impl_->IsRunning(); | |
| 63 } | |
| 64 | |
| 65 } // namespace web | |
| OLD | NEW |