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 <stddef.h> | 5 #include <stddef.h> |
6 #include <memory> | 6 #include <memory> |
7 | 7 |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/process/process_metrics.h" | 9 #include "base/process/process_metrics.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "ipc/ipc_channel_mojo.h" | 13 #include "ipc/ipc_channel_mojo.h" |
14 #include "ipc/ipc_perftest_support.h" | 14 #include "ipc/ipc_perftest_support.h" |
15 #include "mojo/edk/embedder/embedder.h" | 15 #include "mojo/edk/embedder/embedder.h" |
16 #include "mojo/edk/embedder/platform_channel_pair.h" | 16 #include "mojo/edk/embedder/platform_channel_pair.h" |
17 #include "mojo/edk/test/multiprocess_test_helper.h" | 17 #include "mojo/edk/test/multiprocess_test_helper.h" |
18 #include "mojo/edk/test/scoped_ipc_support.h" | 18 #include "mojo/edk/test/scoped_ipc_support.h" |
19 | 19 |
20 namespace IPC { | 20 namespace IPC { |
21 namespace { | 21 namespace { |
22 | 22 |
23 class MojoChannelPerfTest : public test::IPCChannelPerfTestBase { | 23 class MojoChannelPerfTest : public test::IPCChannelPerfTestBase { |
24 public: | 24 public: |
25 void TearDown() override { | 25 void TearDown() override { |
26 ipc_support_.reset(); | |
27 test::IPCChannelPerfTestBase::TearDown(); | 26 test::IPCChannelPerfTestBase::TearDown(); |
28 } | 27 } |
29 | 28 |
30 std::unique_ptr<ChannelFactory> CreateChannelFactory( | |
31 const ChannelHandle& handle, | |
32 base::SingleThreadTaskRunner* runner) override { | |
33 ipc_support_.reset(new mojo::edk::test::ScopedIPCSupport(io_task_runner())); | |
34 return ChannelMojo::CreateServerFactory( | |
35 helper_.StartChild("MojoPerfTestClient"), runner); | |
36 } | |
37 | |
38 bool StartClient() override { | |
39 return true; | |
40 } | |
41 | |
42 bool WaitForClientShutdown() override { | |
43 return helper_.WaitForChildTestShutdown(); | |
44 } | |
45 | |
46 mojo::edk::test::MultiprocessTestHelper helper_; | 29 mojo::edk::test::MultiprocessTestHelper helper_; |
47 std::unique_ptr<mojo::edk::test::ScopedIPCSupport> ipc_support_; | |
48 }; | 30 }; |
49 | 31 |
50 TEST_F(MojoChannelPerfTest, ChannelPingPong) { | 32 TEST_F(MojoChannelPerfTest, ChannelPingPong) { |
51 RunTestChannelPingPong(GetDefaultTestParams()); | 33 RunTestChannelPingPong(GetDefaultTestParams()); |
52 | 34 |
53 base::RunLoop run_loop; | 35 base::RunLoop run_loop; |
54 run_loop.RunUntilIdle(); | 36 run_loop.RunUntilIdle(); |
55 } | 37 } |
56 | 38 |
57 TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) { | 39 TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 base::Bind(&MojoPerfTestClient::Run, base::Unretained(&client))); | 93 base::Bind(&MojoPerfTestClient::Run, base::Unretained(&client))); |
112 | 94 |
113 base::RunLoop run_loop; | 95 base::RunLoop run_loop; |
114 run_loop.RunUntilIdle(); | 96 run_loop.RunUntilIdle(); |
115 | 97 |
116 return rv; | 98 return rv; |
117 } | 99 } |
118 | 100 |
119 } // namespace | 101 } // namespace |
120 } // namespace IPC | 102 } // namespace IPC |
OLD | NEW |