Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: ipc/mojo/ipc_mojo_perftest.cc

Issue 1054253005: ChannelMojo: Ensure that it always has ScopedIPCSupport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the ipc_fuzzer breakage Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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();
35 IPC::test::IPCChannelPerfTestBase::TearDown(); 34 IPC::test::IPCChannelPerfTestBase::TearDown();
36 } 35 }
37 36
38 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( 37 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
39 const IPC::ChannelHandle& handle, 38 const IPC::ChannelHandle& handle,
40 base::SequencedTaskRunner* runner) override { 39 base::SequencedTaskRunner* runner) override {
41 ipc_support_.reset(new IPC::ScopedIPCSupport(runner));
42 host_.reset(new IPC::ChannelMojoHost(runner)); 40 host_.reset(new IPC::ChannelMojoHost(runner));
43 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), 41 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
44 handle); 42 runner, handle);
45 } 43 }
46 44
47 bool DidStartClient() override { 45 bool DidStartClient() override {
48 bool ok = IPCTestBase::DidStartClient(); 46 bool ok = IPCTestBase::DidStartClient();
49 DCHECK(ok); 47 DCHECK(ok);
50 host_->OnClientLaunched(client_process().Handle()); 48 host_->OnClientLaunched(client_process().Handle());
51 return ok; 49 return ok;
52 } 50 }
53 51
54 private: 52 private:
55 scoped_ptr<IPC::ScopedIPCSupport> ipc_support_;
56 scoped_ptr<IPC::ChannelMojoHost> host_; 53 scoped_ptr<IPC::ChannelMojoHost> host_;
57 }; 54 };
58 55
59 MojoChannelPerfTest::MojoChannelPerfTest() { 56 MojoChannelPerfTest::MojoChannelPerfTest() {
60 g_mojo_initializer.Get(); 57 g_mojo_initializer.Get();
61 } 58 }
62 59
63 60
64 TEST_F(MojoChannelPerfTest, ChannelPingPong) { 61 TEST_F(MojoChannelPerfTest, ChannelPingPong) {
65 RunTestChannelPingPong(GetDefaultTestParams()); 62 RunTestChannelPingPong(GetDefaultTestParams());
66 63
67 base::RunLoop run_loop; 64 base::RunLoop run_loop;
68 run_loop.RunUntilIdle(); 65 run_loop.RunUntilIdle();
69 } 66 }
70 67
71 TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) { 68 TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) {
72 RunTestChannelProxyPingPong(GetDefaultTestParams()); 69 RunTestChannelProxyPingPong(GetDefaultTestParams());
73 70
74 base::RunLoop run_loop; 71 base::RunLoop run_loop;
75 run_loop.RunUntilIdle(); 72 run_loop.RunUntilIdle();
76 } 73 }
77 74
78 class MojoTestClient : public IPC::test::PingPongTestClient { 75 class MojoTestClient : public IPC::test::PingPongTestClient {
79 public: 76 public:
80 typedef IPC::test::PingPongTestClient SuperType; 77 typedef IPC::test::PingPongTestClient SuperType;
81 78
82 MojoTestClient(); 79 MojoTestClient();
83 80
84 scoped_ptr<IPC::Channel> CreateChannel(IPC::Listener* listener) override; 81 scoped_ptr<IPC::Channel> CreateChannel(IPC::Listener* listener) override;
85
86 private:
87 scoped_ptr<IPC::ScopedIPCSupport> ipc_support_;
88 }; 82 };
89 83
90 MojoTestClient::MojoTestClient() { 84 MojoTestClient::MojoTestClient() {
91 g_mojo_initializer.Get(); 85 g_mojo_initializer.Get();
92 } 86 }
93 87
94 scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel( 88 scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel(
95 IPC::Listener* listener) { 89 IPC::Listener* listener) {
96 ipc_support_.reset(new IPC::ScopedIPCSupport(task_runner())); 90 return scoped_ptr<IPC::Channel>(IPC::ChannelMojo::Create(
97 return scoped_ptr<IPC::Channel>( 91 NULL, task_runner(), IPCTestBase::GetChannelName("PerformanceClient"),
98 IPC::ChannelMojo::Create(NULL, 92 IPC::Channel::MODE_CLIENT, listener));
99 IPCTestBase::GetChannelName("PerformanceClient"),
100 IPC::Channel::MODE_CLIENT,
101 listener));
102 } 93 }
103 94
104 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) { 95 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) {
105 MojoTestClient client; 96 MojoTestClient client;
106 int rv = client.RunMain(); 97 int rv = client.RunMain();
107 98
108 base::RunLoop run_loop; 99 base::RunLoop run_loop;
109 run_loop.RunUntilIdle(); 100 run_loop.RunUntilIdle();
110 101
111 return rv; 102 return rv;
112 } 103 }
113 104
114 } // namespace 105 } // namespace
OLDNEW
« no previous file with comments | « ipc/mojo/ipc_channel_mojo_unittest.cc ('k') | tools/ipc_fuzzer/message_replay/replay_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698