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 "base/lazy_instance.h" | 5 #include "base/lazy_instance.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "ipc/ipc_perftest_support.h" | 7 #include "ipc/ipc_perftest_support.h" |
8 #include "ipc/mojo/ipc_channel_mojo.h" | 8 #include "ipc/mojo/ipc_channel_mojo.h" |
9 #include "ipc/mojo/ipc_channel_mojo_host.h" | 9 #include "ipc/mojo/ipc_channel_mojo_host.h" |
10 #include "third_party/mojo/src/mojo/edk/embedder/test_embedder.h" | 10 #include "third_party/mojo/src/mojo/edk/embedder/test_embedder.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 base::LazyInstance<MojoInitialier> g_mojo_initializer | 24 base::LazyInstance<MojoInitialier> g_mojo_initializer |
25 = LAZY_INSTANCE_INITIALIZER; | 25 = LAZY_INSTANCE_INITIALIZER; |
26 | 26 |
27 class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase { | 27 class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase { |
28 public: | 28 public: |
29 typedef IPC::test::IPCChannelPerfTestBase Super; | 29 typedef IPC::test::IPCChannelPerfTestBase Super; |
30 | 30 |
31 MojoChannelPerfTest(); | 31 MojoChannelPerfTest(); |
32 | 32 |
33 void TearDown() override { | 33 void TearDown() override { |
| 34 ipc_support_.reset(); |
34 IPC::test::IPCChannelPerfTestBase::TearDown(); | 35 IPC::test::IPCChannelPerfTestBase::TearDown(); |
35 } | 36 } |
36 | 37 |
37 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( | 38 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
38 const IPC::ChannelHandle& handle, | 39 const IPC::ChannelHandle& handle, |
39 base::SequencedTaskRunner* runner) override { | 40 base::SequencedTaskRunner* runner) override { |
| 41 ipc_support_.reset(new IPC::ScopedIPCSupport(runner)); |
40 host_.reset(new IPC::ChannelMojoHost(runner)); | 42 host_.reset(new IPC::ChannelMojoHost(runner)); |
41 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), | 43 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), |
42 runner, handle); | 44 handle); |
43 } | 45 } |
44 | 46 |
45 bool DidStartClient() override { | 47 bool DidStartClient() override { |
46 bool ok = IPCTestBase::DidStartClient(); | 48 bool ok = IPCTestBase::DidStartClient(); |
47 DCHECK(ok); | 49 DCHECK(ok); |
48 host_->OnClientLaunched(client_process().Handle()); | 50 host_->OnClientLaunched(client_process().Handle()); |
49 return ok; | 51 return ok; |
50 } | 52 } |
51 | 53 |
52 private: | 54 private: |
| 55 scoped_ptr<IPC::ScopedIPCSupport> ipc_support_; |
53 scoped_ptr<IPC::ChannelMojoHost> host_; | 56 scoped_ptr<IPC::ChannelMojoHost> host_; |
54 }; | 57 }; |
55 | 58 |
56 MojoChannelPerfTest::MojoChannelPerfTest() { | 59 MojoChannelPerfTest::MojoChannelPerfTest() { |
57 g_mojo_initializer.Get(); | 60 g_mojo_initializer.Get(); |
58 } | 61 } |
59 | 62 |
60 | 63 |
61 TEST_F(MojoChannelPerfTest, ChannelPingPong) { | 64 TEST_F(MojoChannelPerfTest, ChannelPingPong) { |
62 RunTestChannelPingPong(GetDefaultTestParams()); | 65 RunTestChannelPingPong(GetDefaultTestParams()); |
63 | 66 |
64 base::RunLoop run_loop; | 67 base::RunLoop run_loop; |
65 run_loop.RunUntilIdle(); | 68 run_loop.RunUntilIdle(); |
66 } | 69 } |
67 | 70 |
68 TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) { | 71 TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) { |
69 RunTestChannelProxyPingPong(GetDefaultTestParams()); | 72 RunTestChannelProxyPingPong(GetDefaultTestParams()); |
70 | 73 |
71 base::RunLoop run_loop; | 74 base::RunLoop run_loop; |
72 run_loop.RunUntilIdle(); | 75 run_loop.RunUntilIdle(); |
73 } | 76 } |
74 | 77 |
75 class MojoTestClient : public IPC::test::PingPongTestClient { | 78 class MojoTestClient : public IPC::test::PingPongTestClient { |
76 public: | 79 public: |
77 typedef IPC::test::PingPongTestClient SuperType; | 80 typedef IPC::test::PingPongTestClient SuperType; |
78 | 81 |
79 MojoTestClient(); | 82 MojoTestClient(); |
80 | 83 |
81 scoped_ptr<IPC::Channel> CreateChannel(IPC::Listener* listener) override; | 84 scoped_ptr<IPC::Channel> CreateChannel(IPC::Listener* listener) override; |
| 85 |
| 86 private: |
| 87 scoped_ptr<IPC::ScopedIPCSupport> ipc_support_; |
82 }; | 88 }; |
83 | 89 |
84 MojoTestClient::MojoTestClient() { | 90 MojoTestClient::MojoTestClient() { |
85 g_mojo_initializer.Get(); | 91 g_mojo_initializer.Get(); |
86 } | 92 } |
87 | 93 |
88 scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel( | 94 scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel( |
89 IPC::Listener* listener) { | 95 IPC::Listener* listener) { |
90 return scoped_ptr<IPC::Channel>(IPC::ChannelMojo::Create( | 96 ipc_support_.reset(new IPC::ScopedIPCSupport(task_runner())); |
91 NULL, task_runner(), IPCTestBase::GetChannelName("PerformanceClient"), | 97 return scoped_ptr<IPC::Channel>( |
92 IPC::Channel::MODE_CLIENT, listener)); | 98 IPC::ChannelMojo::Create(NULL, |
| 99 IPCTestBase::GetChannelName("PerformanceClient"), |
| 100 IPC::Channel::MODE_CLIENT, |
| 101 listener)); |
93 } | 102 } |
94 | 103 |
95 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) { | 104 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) { |
96 MojoTestClient client; | 105 MojoTestClient client; |
97 int rv = client.RunMain(); | 106 int rv = client.RunMain(); |
98 | 107 |
99 base::RunLoop run_loop; | 108 base::RunLoop run_loop; |
100 run_loop.RunUntilIdle(); | 109 run_loop.RunUntilIdle(); |
101 | 110 |
102 return rv; | 111 return rv; |
103 } | 112 } |
104 | 113 |
105 } // namespace | 114 } // namespace |
OLD | NEW |