Chromium Code Reviews| 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 "ipc/mojo/ipc_channel_mojo_host.h" | 7 #include "ipc/mojo/ipc_channel_mojo_host.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 { |
| 11 | 11 |
| 12 class RenderThreadImplBrowserIPCTestHelper::DummyListener | 12 class RenderThreadImplBrowserIPCTestHelper::DummyListener |
| 13 : public IPC::Listener { | 13 : public IPC::Listener { |
| 14 public: | 14 public: |
| 15 bool OnMessageReceived(const IPC::Message& message) override { return true; } | 15 bool OnMessageReceived(const IPC::Message& message) override { return true; } |
| 16 }; | 16 }; |
| 17 | 17 |
| 18 RenderThreadImplBrowserIPCTestHelper::RenderThreadImplBrowserIPCTestHelper() { | 18 RenderThreadImplBrowserIPCTestHelper::RenderThreadImplBrowserIPCTestHelper() { |
| 19 message_loop_.reset(new base::MessageLoopForIO()); | 19 message_loop_.reset(new base::MessageLoopForIO()); |
| 20 | 20 |
| 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 // TODO(crbug.com/451221): Mojo should be used here even for Android. |
| 27 // Currently SetupMojo() calls InitializeMojo() which can be called at most | |
| 28 // once for each process. This implices that every test case using | |
| 29 // RenderThreadImplBrowserIPCTestHelper has to run in a dedicated process, but | |
| 30 // that is false on OS_ANDROID. There is no way to call InitializeMojo() only | |
| 31 // if it isn't initialized yet. | |
| 32 #if defined(OS_ANDROID) | |
|
sky
2015/01/23 00:43:49
Is there some other switch you can use rather than
| |
| 33 bool use_mojo_channel = false; | |
| 34 #else | |
| 35 bool use_mojo_channel = IPC::ChannelMojo::ShouldBeUsed(); | |
| 36 #endif | |
| 37 if (use_mojo_channel) { | |
| 27 SetupMojo(); | 38 SetupMojo(); |
| 28 } else { | 39 } else { |
| 29 channel_ = IPC::ChannelProxy::Create(channel_id_, IPC::Channel::MODE_SERVER, | 40 channel_ = IPC::ChannelProxy::Create(channel_id_, IPC::Channel::MODE_SERVER, |
| 30 dummy_listener_.get(), | 41 dummy_listener_.get(), |
| 31 ipc_thread_->task_runner()); | 42 ipc_thread_->task_runner()); |
| 32 } | 43 } |
| 33 } | 44 } |
| 34 | 45 |
| 35 RenderThreadImplBrowserIPCTestHelper::~RenderThreadImplBrowserIPCTestHelper() { | 46 RenderThreadImplBrowserIPCTestHelper::~RenderThreadImplBrowserIPCTestHelper() { |
| 36 } | 47 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 53 channel_id_), | 64 channel_id_), |
| 54 dummy_listener_.get(), ipc_thread_->task_runner()); | 65 dummy_listener_.get(), ipc_thread_->task_runner()); |
| 55 | 66 |
| 56 mojo_application_host_->Init(); | 67 mojo_application_host_->Init(); |
| 57 mojo_application_host_->Activate(channel_.get(), | 68 mojo_application_host_->Activate(channel_.get(), |
| 58 base::GetCurrentProcessHandle()); | 69 base::GetCurrentProcessHandle()); |
| 59 mojo_host_->OnClientLaunched(base::GetCurrentProcessHandle()); | 70 mojo_host_->OnClientLaunched(base::GetCurrentProcessHandle()); |
| 60 } | 71 } |
| 61 | 72 |
| 62 } // namespace content | 73 } // namespace content |
| OLD | NEW |