| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/test/render_thread_impl_browser_test_ipc_helper.h" | 5 #include "content/test/render_thread_impl_browser_test_ipc_helper.h" |
| 6 | 6 |
| 7 #include "content/common/mojo/channel_init.h" |
| 7 #include "ipc/mojo/ipc_channel_mojo_host.h" | 8 #include "ipc/mojo/ipc_channel_mojo_host.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 10 |
| 10 namespace content { | 11 namespace content { |
| 11 | 12 |
| 12 class RenderThreadImplBrowserIPCTestHelper::DummyListener | 13 class RenderThreadImplBrowserIPCTestHelper::DummyListener |
| 13 : public IPC::Listener { | 14 : public IPC::Listener { |
| 14 public: | 15 public: |
| 15 bool OnMessageReceived(const IPC::Message& message) override { return true; } | 16 bool OnMessageReceived(const IPC::Message& message) override { return true; } |
| 16 }; | 17 }; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 33 } | 34 } |
| 34 | 35 |
| 35 RenderThreadImplBrowserIPCTestHelper::~RenderThreadImplBrowserIPCTestHelper() { | 36 RenderThreadImplBrowserIPCTestHelper::~RenderThreadImplBrowserIPCTestHelper() { |
| 36 } | 37 } |
| 37 | 38 |
| 38 void RenderThreadImplBrowserIPCTestHelper::SetupIpcThread() { | 39 void RenderThreadImplBrowserIPCTestHelper::SetupIpcThread() { |
| 39 ipc_thread_.reset(new base::Thread("test_ipc_thread")); | 40 ipc_thread_.reset(new base::Thread("test_ipc_thread")); |
| 40 base::Thread::Options options; | 41 base::Thread::Options options; |
| 41 options.message_loop_type = base::MessageLoop::TYPE_IO; | 42 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 42 ASSERT_TRUE(ipc_thread_->StartWithOptions(options)); | 43 ASSERT_TRUE(ipc_thread_->StartWithOptions(options)); |
| 44 ChannelInit::SetSingleProcessIOTaskRunner(ipc_thread_->task_runner()); |
| 43 } | 45 } |
| 44 | 46 |
| 45 void RenderThreadImplBrowserIPCTestHelper::SetupMojo() { | 47 void RenderThreadImplBrowserIPCTestHelper::SetupMojo() { |
| 46 InitializeMojo(); | 48 InitializeMojo(); |
| 47 | 49 |
| 50 ipc_support_.reset(new IPC::ScopedIPCSupport(ipc_thread_->task_runner())); |
| 48 mojo_host_.reset(new IPC::ChannelMojoHost(ipc_thread_->task_runner())); | 51 mojo_host_.reset(new IPC::ChannelMojoHost(ipc_thread_->task_runner())); |
| 49 mojo_application_host_.reset(new MojoApplicationHost()); | 52 mojo_application_host_.reset(new MojoApplicationHost()); |
| 53 mojo_application_host_->OverrideIOTaskRunnerForTest( |
| 54 ipc_thread_->task_runner()); |
| 50 | 55 |
| 51 channel_ = IPC::ChannelProxy::Create( | 56 channel_ = IPC::ChannelProxy::Create( |
| 52 IPC::ChannelMojo::CreateServerFactory(mojo_host_->channel_delegate(), | 57 IPC::ChannelMojo::CreateServerFactory(mojo_host_->channel_delegate(), |
| 53 channel_id_), | 58 channel_id_), |
| 54 dummy_listener_.get(), ipc_thread_->task_runner()); | 59 dummy_listener_.get(), ipc_thread_->task_runner()); |
| 55 | 60 |
| 56 mojo_application_host_->Init(); | 61 mojo_application_host_->Init(); |
| 57 mojo_application_host_->Activate(channel_.get(), | 62 mojo_application_host_->Activate(channel_.get(), |
| 58 base::GetCurrentProcessHandle()); | 63 base::GetCurrentProcessHandle()); |
| 59 mojo_host_->OnClientLaunched(base::GetCurrentProcessHandle()); | 64 mojo_host_->OnClientLaunched(base::GetCurrentProcessHandle()); |
| 60 } | 65 } |
| 61 | 66 |
| 62 } // namespace content | 67 } // namespace content |
| OLD | NEW |