[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / content / public / test / test_browser_thread.cc
blob62d9eb84534033756d7b3bc649f41b0bdef2cc25
1 // Copyright (c) 2011 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 "content/public/test/test_browser_thread.h"
7 #include "base/message_loop/message_loop.h"
8 #include "base/threading/thread.h"
9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/notification_service_impl.h"
12 namespace content {
14 class TestBrowserThreadImpl : public BrowserThreadImpl {
15 public:
16 explicit TestBrowserThreadImpl(BrowserThread::ID identifier)
17 : BrowserThreadImpl(identifier),
18 notification_service_(NULL) {
21 TestBrowserThreadImpl(BrowserThread::ID identifier,
22 base::MessageLoop* message_loop)
23 : BrowserThreadImpl(identifier, message_loop),
24 notification_service_(NULL) {}
26 ~TestBrowserThreadImpl() override { Stop(); }
28 void Init() override {
29 notification_service_ = new NotificationServiceImpl;
30 BrowserThreadImpl::Init();
33 void CleanUp() override {
34 delete notification_service_;
35 notification_service_ = NULL;
36 BrowserThreadImpl::CleanUp();
39 private:
40 NotificationService* notification_service_;
42 DISALLOW_COPY_AND_ASSIGN(TestBrowserThreadImpl);
45 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier)
46 : impl_(new TestBrowserThreadImpl(identifier)) {
49 TestBrowserThread::TestBrowserThread(BrowserThread::ID identifier,
50 base::MessageLoop* message_loop)
51 : impl_(new TestBrowserThreadImpl(identifier, message_loop)) {}
53 TestBrowserThread::~TestBrowserThread() {
54 Stop();
57 bool TestBrowserThread::Start() {
58 return impl_->Start();
61 bool TestBrowserThread::StartAndWaitForTesting() {
62 return impl_->StartAndWaitForTesting();
65 bool TestBrowserThread::StartIOThread() {
66 base::Thread::Options options;
67 options.message_loop_type = base::MessageLoop::TYPE_IO;
68 return impl_->StartWithOptions(options);
71 void TestBrowserThread::Stop() {
72 impl_->Stop();
75 bool TestBrowserThread::IsRunning() {
76 return impl_->IsRunning();
79 base::Thread* TestBrowserThread::DeprecatedGetThreadObject() {
80 return impl_.get();
83 } // namespace content