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

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

Issue 536213002: Add ipc_mojo_perftests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed garbage Created 6 years, 3 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.gyp ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/lazy_instance.h"
6 #include "ipc/ipc_perftest_support.h"
7 #include "ipc/mojo/ipc_channel_mojo.h"
8 #include "mojo/embedder/test_embedder.h"
9
10 namespace {
11
12 // 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 // some way to call InitWithSimplePlatformSupport() only once before
15 // using Mojo.
16 struct MojoInitialier {
17 MojoInitialier() {
18 mojo::embedder::test::InitWithSimplePlatformSupport();
19 }
20 };
21
22 base::LazyInstance<MojoInitialier> g_mojo_initializer
23 = LAZY_INSTANCE_INITIALIZER;
24
25 class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase {
26 public:
27 typedef IPC::test::IPCChannelPerfTestBase Super;
28
29 MojoChannelPerfTest();
30
31 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
32 const IPC::ChannelHandle& handle,
33 base::TaskRunner* runner) OVERRIDE {
34 return IPC::ChannelMojo::CreateFactory(
35 handle, IPC::Channel::MODE_SERVER, runner);
36 }
37
38 void set_io_thread_task_runner(base::TaskRunner* runner) {
39 io_thread_task_runner_ = runner;
40 }
41
42 private:
43 base::TaskRunner* io_thread_task_runner_;
44 };
45
46 MojoChannelPerfTest::MojoChannelPerfTest()
47 : io_thread_task_runner_() {
48 g_mojo_initializer.Get();
49 }
50
51
52 TEST_F(MojoChannelPerfTest, ChannelPingPong) {
53 RunTestChannelPingPong(GetDefaultTestParams());
54 }
55
56 TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) {
57 RunTestChannelProxyPingPong(GetDefaultTestParams());
58 }
59
60 class MojoTestClient : public IPC::test::PingPongTestClient {
61 public:
62 typedef IPC::test::PingPongTestClient SuperType;
63
64 MojoTestClient();
65
66 virtual scoped_ptr<IPC::Channel> CreateChannel(
67 IPC::Listener* listener) OVERRIDE;
68 };
69
70 MojoTestClient::MojoTestClient() {
71 g_mojo_initializer.Get();
72 }
73
74 scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel(
75 IPC::Listener* listener) {
76 return scoped_ptr<IPC::Channel>(IPC::ChannelMojo::Create(
77 IPCTestBase::GetChannelName("PerformanceClient"),
78 IPC::Channel::MODE_CLIENT, listener,
79 task_runner()));
80 }
81
82 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) {
83 MojoTestClient client;
84 return client.RunMain();
85 }
86
87 } // namespace
OLDNEW
« no previous file with comments | « ipc/mojo/ipc_mojo.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698