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 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "ipc/ipc_perftest_support.h" | 10 #include "ipc/ipc_perftest_support.h" |
11 #include "ipc/mojo/ipc_channel_mojo.h" | 11 #include "ipc/mojo/ipc_channel_mojo.h" |
12 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 12 #include "mojo/edk/embedder/embedder.h" |
13 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" | 13 #include "mojo/edk/embedder/platform_channel_pair.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // This is needed because we rely on //base/test:test_support_perf and | 17 // This is needed because we rely on //base/test:test_support_perf and |
18 // it provides main() which doesn't have Mojo initialization. We need | 18 // it provides main() which doesn't have Mojo initialization. We need |
19 // some way to call Init() only once before using Mojo. | 19 // some way to call Init() only once before using Mojo. |
20 struct MojoInitialier { | 20 struct MojoInitialier { |
21 MojoInitialier() { | 21 MojoInitialier() { |
22 mojo::embedder::Init(); | 22 mojo::edk::Init(); |
23 } | 23 } |
24 }; | 24 }; |
25 | 25 |
26 base::LazyInstance<MojoInitialier> g_mojo_initializer | 26 base::LazyInstance<MojoInitialier> g_mojo_initializer |
27 = LAZY_INSTANCE_INITIALIZER; | 27 = LAZY_INSTANCE_INITIALIZER; |
28 | 28 |
29 class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase { | 29 class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase { |
30 public: | 30 public: |
31 typedef IPC::test::IPCChannelPerfTestBase Super; | 31 typedef IPC::test::IPCChannelPerfTestBase Super; |
32 | 32 |
33 MojoChannelPerfTest(); | 33 MojoChannelPerfTest(); |
34 | 34 |
35 void TearDown() override { | 35 void TearDown() override { |
36 IPC::test::IPCChannelPerfTestBase::TearDown(); | 36 IPC::test::IPCChannelPerfTestBase::TearDown(); |
37 } | 37 } |
38 | 38 |
39 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( | 39 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
40 const IPC::ChannelHandle& handle, | 40 const IPC::ChannelHandle& handle, |
41 base::SequencedTaskRunner* runner) override { | 41 base::TaskRunner* runner) override { |
42 return IPC::ChannelMojo::CreateServerFactory(runner, handle); | 42 return IPC::ChannelMojo::CreateServerFactory(runner, handle); |
43 } | 43 } |
44 | 44 |
45 bool DidStartClient() override { | 45 bool DidStartClient() override { |
46 bool ok = IPCTestBase::DidStartClient(); | 46 bool ok = IPCTestBase::DidStartClient(); |
47 DCHECK(ok); | 47 DCHECK(ok); |
48 return ok; | 48 return ok; |
49 } | 49 } |
50 }; | 50 }; |
51 | 51 |
(...skipping 16 matching lines...) Expand all Loading... |
68 run_loop.RunUntilIdle(); | 68 run_loop.RunUntilIdle(); |
69 } | 69 } |
70 | 70 |
71 // Test to see how many channels we can create. | 71 // Test to see how many channels we can create. |
72 TEST_F(MojoChannelPerfTest, DISABLED_MaxChannelCount) { | 72 TEST_F(MojoChannelPerfTest, DISABLED_MaxChannelCount) { |
73 #if defined(OS_POSIX) | 73 #if defined(OS_POSIX) |
74 LOG(INFO) << "base::GetMaxFds " << base::GetMaxFds(); | 74 LOG(INFO) << "base::GetMaxFds " << base::GetMaxFds(); |
75 base::SetFdLimit(20000); | 75 base::SetFdLimit(20000); |
76 #endif | 76 #endif |
77 | 77 |
78 std::vector<mojo::embedder::PlatformChannelPair*> channels; | 78 std::vector<mojo::edk::PlatformChannelPair*> channels; |
79 for (size_t i = 0; i < 10000; ++i) { | 79 for (size_t i = 0; i < 10000; ++i) { |
80 LOG(INFO) << "channels size: " << channels.size(); | 80 LOG(INFO) << "channels size: " << channels.size(); |
81 channels.push_back(new mojo::embedder::PlatformChannelPair()); | 81 channels.push_back(new mojo::edk::PlatformChannelPair()); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 class MojoTestClient : public IPC::test::PingPongTestClient { | 85 class MojoTestClient : public IPC::test::PingPongTestClient { |
86 public: | 86 public: |
87 typedef IPC::test::PingPongTestClient SuperType; | 87 typedef IPC::test::PingPongTestClient SuperType; |
88 | 88 |
89 MojoTestClient(); | 89 MojoTestClient(); |
90 | 90 |
91 scoped_ptr<IPC::Channel> CreateChannel(IPC::Listener* listener) override; | 91 scoped_ptr<IPC::Channel> CreateChannel(IPC::Listener* listener) override; |
(...skipping 14 matching lines...) Expand all Loading... |
106 MojoTestClient client; | 106 MojoTestClient client; |
107 int rv = client.RunMain(); | 107 int rv = client.RunMain(); |
108 | 108 |
109 base::RunLoop run_loop; | 109 base::RunLoop run_loop; |
110 run_loop.RunUntilIdle(); | 110 run_loop.RunUntilIdle(); |
111 | 111 |
112 return rv; | 112 return rv; |
113 } | 113 } |
114 | 114 |
115 } // namespace | 115 } // namespace |
OLD | NEW |