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

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

Issue 553283002: IPC::ChannelMojo: Introduce IPC::MojoBootstrap for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed build error Created 6 years, 2 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
« no previous file with comments | « ipc/mojo/ipc_mojo_bootstrap_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ipc/ipc_perftest_support.h" 6 #include "ipc/ipc_perftest_support.h"
7 #include "ipc/mojo/ipc_channel_mojo.h" 7 #include "ipc/mojo/ipc_channel_mojo.h"
8 #include "ipc/mojo/ipc_channel_mojo_host.h"
8 #include "mojo/embedder/test_embedder.h" 9 #include "mojo/embedder/test_embedder.h"
9 10
10 namespace { 11 namespace {
11 12
12 // This is needed because we rely on //base/test:test_support_perf and 13 // This is needed because we rely on //base/test:test_support_perf and
13 // it provides main() which doesn't have Mojo initialization. We need 14 // it provides main() which doesn't have Mojo initialization. We need
14 // some way to call InitWithSimplePlatformSupport() only once before 15 // some way to call InitWithSimplePlatformSupport() only once before
15 // using Mojo. 16 // using Mojo.
16 struct MojoInitialier { 17 struct MojoInitialier {
17 MojoInitialier() { 18 MojoInitialier() {
18 mojo::embedder::test::InitWithSimplePlatformSupport(); 19 mojo::embedder::test::InitWithSimplePlatformSupport();
19 } 20 }
20 }; 21 };
21 22
22 base::LazyInstance<MojoInitialier> g_mojo_initializer 23 base::LazyInstance<MojoInitialier> g_mojo_initializer
23 = LAZY_INSTANCE_INITIALIZER; 24 = LAZY_INSTANCE_INITIALIZER;
24 25
25 class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase { 26 class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase {
26 public: 27 public:
27 typedef IPC::test::IPCChannelPerfTestBase Super; 28 typedef IPC::test::IPCChannelPerfTestBase Super;
28 29
29 MojoChannelPerfTest(); 30 MojoChannelPerfTest();
30 31
31 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( 32 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
32 const IPC::ChannelHandle& handle, 33 const IPC::ChannelHandle& handle,
33 base::TaskRunner* runner) OVERRIDE { 34 base::TaskRunner* runner) OVERRIDE {
34 return IPC::ChannelMojo::CreateFactory( 35 host_.reset(new IPC::ChannelMojoHost(task_runner()));
35 handle, IPC::Channel::MODE_SERVER, runner); 36 return IPC::ChannelMojo::CreateServerFactory(host_.get(), handle);
37 }
38
39 virtual bool DidStartClient() OVERRIDE {
40 bool ok = IPCTestBase::DidStartClient();
41 DCHECK(ok);
42 host_->OnClientLaunched(client_process());
43 return ok;
36 } 44 }
37 45
38 void set_io_thread_task_runner(base::TaskRunner* runner) { 46 void set_io_thread_task_runner(base::TaskRunner* runner) {
39 io_thread_task_runner_ = runner; 47 io_thread_task_runner_ = runner;
40 } 48 }
41 49
42 private: 50 private:
43 base::TaskRunner* io_thread_task_runner_; 51 base::TaskRunner* io_thread_task_runner_;
52 scoped_ptr<IPC::ChannelMojoHost> host_;
44 }; 53 };
45 54
46 MojoChannelPerfTest::MojoChannelPerfTest() 55 MojoChannelPerfTest::MojoChannelPerfTest()
47 : io_thread_task_runner_() { 56 : io_thread_task_runner_() {
48 g_mojo_initializer.Get(); 57 g_mojo_initializer.Get();
49 } 58 }
50 59
51 60
52 TEST_F(MojoChannelPerfTest, ChannelPingPong) { 61 TEST_F(MojoChannelPerfTest, ChannelPingPong) {
53 RunTestChannelPingPong(GetDefaultTestParams()); 62 RunTestChannelPingPong(GetDefaultTestParams());
(...skipping 12 matching lines...) Expand all
66 virtual scoped_ptr<IPC::Channel> CreateChannel( 75 virtual scoped_ptr<IPC::Channel> CreateChannel(
67 IPC::Listener* listener) OVERRIDE; 76 IPC::Listener* listener) OVERRIDE;
68 }; 77 };
69 78
70 MojoTestClient::MojoTestClient() { 79 MojoTestClient::MojoTestClient() {
71 g_mojo_initializer.Get(); 80 g_mojo_initializer.Get();
72 } 81 }
73 82
74 scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel( 83 scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel(
75 IPC::Listener* listener) { 84 IPC::Listener* listener) {
76 return scoped_ptr<IPC::Channel>(IPC::ChannelMojo::Create( 85 return scoped_ptr<IPC::Channel>(
77 IPCTestBase::GetChannelName("PerformanceClient"), 86 IPC::ChannelMojo::Create(NULL,
78 IPC::Channel::MODE_CLIENT, listener, 87 IPCTestBase::GetChannelName("PerformanceClient"),
79 task_runner())); 88 IPC::Channel::MODE_CLIENT,
89 listener));
80 } 90 }
81 91
82 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) { 92 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) {
83 MojoTestClient client; 93 MojoTestClient client;
84 return client.RunMain(); 94 return client.RunMain();
85 } 95 }
86 96
87 } // namespace 97 } // namespace
OLDNEW
« no previous file with comments | « ipc/mojo/ipc_mojo_bootstrap_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698