| 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 "content/common/mojo/channel_init.h" | 
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" | 
| 9 | 9 | 
| 10 namespace content { | 10 namespace content { | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 21   channel_id_ = IPC::Channel::GenerateVerifiedChannelID(""); | 21   channel_id_ = IPC::Channel::GenerateVerifiedChannelID(""); | 
| 22   dummy_listener_.reset(new DummyListener()); | 22   dummy_listener_.reset(new DummyListener()); | 
| 23 | 23 | 
| 24   SetupIpcThread(); | 24   SetupIpcThread(); | 
| 25 | 25 | 
| 26   if (IPC::ChannelMojo::ShouldBeUsed()) { | 26   if (IPC::ChannelMojo::ShouldBeUsed()) { | 
| 27     SetupMojo(); | 27     SetupMojo(); | 
| 28   } else { | 28   } else { | 
| 29     channel_ = IPC::ChannelProxy::Create(channel_id_, IPC::Channel::MODE_SERVER, | 29     channel_ = IPC::ChannelProxy::Create(channel_id_, IPC::Channel::MODE_SERVER, | 
| 30                                          dummy_listener_.get(), | 30                                          dummy_listener_.get(), | 
| 31                                          ipc_thread_->task_runner(), nullptr); | 31                                          ipc_thread_->task_runner()); | 
| 32   } | 32   } | 
| 33 } | 33 } | 
| 34 | 34 | 
| 35 RenderThreadImplBrowserIPCTestHelper::~RenderThreadImplBrowserIPCTestHelper() { | 35 RenderThreadImplBrowserIPCTestHelper::~RenderThreadImplBrowserIPCTestHelper() { | 
| 36 } | 36 } | 
| 37 | 37 | 
| 38 void RenderThreadImplBrowserIPCTestHelper::SetupIpcThread() { | 38 void RenderThreadImplBrowserIPCTestHelper::SetupIpcThread() { | 
| 39   ipc_thread_.reset(new base::Thread("test_ipc_thread")); | 39   ipc_thread_.reset(new base::Thread("test_ipc_thread")); | 
| 40   base::Thread::Options options; | 40   base::Thread::Options options; | 
| 41   options.message_loop_type = base::MessageLoop::TYPE_IO; | 41   options.message_loop_type = base::MessageLoop::TYPE_IO; | 
| 42   ASSERT_TRUE(ipc_thread_->StartWithOptions(options)); | 42   ASSERT_TRUE(ipc_thread_->StartWithOptions(options)); | 
| 43 } | 43 } | 
| 44 | 44 | 
| 45 void RenderThreadImplBrowserIPCTestHelper::SetupMojo() { | 45 void RenderThreadImplBrowserIPCTestHelper::SetupMojo() { | 
| 46   InitializeMojo(); | 46   InitializeMojo(); | 
| 47 | 47 | 
| 48   ipc_support_.reset(new IPC::ScopedIPCSupport(ipc_thread_->task_runner())); | 48   ipc_support_.reset(new IPC::ScopedIPCSupport(ipc_thread_->task_runner())); | 
| 49   mojo_application_host_.reset(new MojoApplicationHost()); | 49   mojo_application_host_.reset(new MojoApplicationHost()); | 
| 50   mojo_application_host_->OverrideIOTaskRunnerForTest( | 50   mojo_application_host_->OverrideIOTaskRunnerForTest( | 
| 51       ipc_thread_->task_runner()); | 51       ipc_thread_->task_runner()); | 
| 52 | 52 | 
| 53   channel_ = IPC::ChannelProxy::Create( | 53   channel_ = IPC::ChannelProxy::Create( | 
| 54       IPC::ChannelMojo::CreateServerFactory(ipc_thread_->task_runner(), | 54       IPC::ChannelMojo::CreateServerFactory(ipc_thread_->task_runner(), | 
| 55                                             channel_id_, nullptr), | 55                                             channel_id_), | 
| 56       dummy_listener_.get(), ipc_thread_->task_runner()); | 56       dummy_listener_.get(), ipc_thread_->task_runner()); | 
| 57 | 57 | 
| 58   mojo_application_host_->Init(); | 58   mojo_application_host_->Init(); | 
| 59   mojo_application_host_->Activate(channel_.get(), | 59   mojo_application_host_->Activate(channel_.get(), | 
| 60                                    base::GetCurrentProcessHandle()); | 60                                    base::GetCurrentProcessHandle()); | 
| 61 } | 61 } | 
| 62 | 62 | 
| 63 scoped_refptr<base::SingleThreadTaskRunner> | 63 scoped_refptr<base::SingleThreadTaskRunner> | 
| 64 RenderThreadImplBrowserIPCTestHelper::GetIOTaskRunner() const { | 64 RenderThreadImplBrowserIPCTestHelper::GetIOTaskRunner() const { | 
| 65   return ipc_thread_->task_runner(); | 65   return ipc_thread_->task_runner(); | 
| 66 } | 66 } | 
| 67 | 67 | 
| 68 }  // namespace content | 68 }  // namespace content | 
| OLD | NEW | 
|---|