summaryrefslogtreecommitdiffstats
path: root/ipc/mojo
diff options
context:
space:
mode:
authormorrita <morrita@chromium.org>2014-09-09 12:35:24 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-09 19:41:40 +0000
commit373af03b7c0e1932c7ea3b832918b7767d47ff89 (patch)
tree5be2bbc870238a11e54e650434ddcf09472a9600 /ipc/mojo
parent182520b878bee21aad3500391cd51d486e37bf1e (diff)
downloadchromium_src-373af03b7c0e1932c7ea3b832918b7767d47ff89.zip
chromium_src-373af03b7c0e1932c7ea3b832918b7767d47ff89.tar.gz
chromium_src-373af03b7c0e1932c7ea3b832918b7767d47ff89.tar.bz2
Add ipc_mojo_perftests
This change adds ipc_mojo_perftests that runs the same benchmark as of ipc_perftests. Now head-to-head comparison becomes possible. For this change, whole ipc_perftests logic is extracted to ipc_perftest_support.cc to make it reusable by ipc_mojo_perftests. TEST=none BUG=none R=jam@chromium.org, darin@chromium.org, yuzhu@chromium.org Review URL: https://codereview.chromium.org/536213002 Cr-Commit-Position: refs/heads/master@{#293988}
Diffstat (limited to 'ipc/mojo')
-rw-r--r--ipc/mojo/BUILD.gn19
-rw-r--r--ipc/mojo/ipc_channel_mojo.cc12
-rw-r--r--ipc/mojo/ipc_channel_mojo.h5
-rw-r--r--ipc/mojo/ipc_channel_mojo_unittest.cc49
-rw-r--r--ipc/mojo/ipc_mojo.gyp25
-rw-r--r--ipc/mojo/ipc_mojo_perftest.cc87
6 files changed, 141 insertions, 56 deletions
diff --git a/ipc/mojo/BUILD.gn b/ipc/mojo/BUILD.gn
index d059b48..58c1f03 100644
--- a/ipc/mojo/BUILD.gn
+++ b/ipc/mojo/BUILD.gn
@@ -40,3 +40,22 @@ test("ipc_mojo_unittests") {
"//url",
]
}
+
+test("ipc_mojo_perftests") {
+ sources = [
+ "ipc_mojo_perftest.cc",
+ ]
+
+ deps = [
+ "//base",
+ "//base/test:test_support",
+ "//base/test:test_support_perf",
+ "//base/third_party/dynamic_annotations",
+ "//ipc",
+ "//ipc:test_support",
+ "//ipc/mojo",
+ "//mojo/environment:chromium",
+ "//mojo/system",
+ "//url",
+ ]
+}
diff --git a/ipc/mojo/ipc_channel_mojo.cc b/ipc/mojo/ipc_channel_mojo.cc
index 88034f1..cdb9281 100644
--- a/ipc/mojo/ipc_channel_mojo.cc
+++ b/ipc/mojo/ipc_channel_mojo.cc
@@ -456,19 +456,11 @@ void ChannelMojo::ChannelInfoDeleter::operator()(
// static
scoped_ptr<ChannelMojo> ChannelMojo::Create(
- scoped_ptr<Channel> bootstrap, Mode mode, Listener* listener,
- scoped_refptr<base::TaskRunner> io_thread_task_runner) {
- return make_scoped_ptr(new ChannelMojo(
- bootstrap.Pass(), mode, listener, io_thread_task_runner));
-}
-
-// static
-scoped_ptr<ChannelMojo> ChannelMojo::Create(
const ChannelHandle &channel_handle, Mode mode, Listener* listener,
scoped_refptr<base::TaskRunner> io_thread_task_runner) {
- return Create(
+ return make_scoped_ptr(new ChannelMojo(
Channel::Create(channel_handle, mode, g_null_listener.Pointer()),
- mode, listener, io_thread_task_runner);
+ mode, listener, io_thread_task_runner));
}
// static
diff --git a/ipc/mojo/ipc_channel_mojo.h b/ipc/mojo/ipc_channel_mojo.h
index 4d4df63..dd57bc8 100644
--- a/ipc/mojo/ipc_channel_mojo.h
+++ b/ipc/mojo/ipc_channel_mojo.h
@@ -50,11 +50,6 @@ namespace IPC {
//
class IPC_MOJO_EXPORT ChannelMojo : public Channel {
public:
- // Create ChannelMojo on top of given |bootstrap| channel.
- static scoped_ptr<ChannelMojo> Create(
- scoped_ptr<Channel> bootstrap, Mode mode, Listener* listener,
- scoped_refptr<base::TaskRunner> io_thread_task_runner);
-
// Create ChannelMojo. A bootstrap channel is created as well.
static scoped_ptr<ChannelMojo> Create(
const ChannelHandle &channel_handle, Mode mode, Listener* listener,
diff --git a/ipc/mojo/ipc_channel_mojo_unittest.cc b/ipc/mojo/ipc_channel_mojo_unittest.cc
index 60069b7..8ea828f 100644
--- a/ipc/mojo/ipc_channel_mojo_unittest.cc
+++ b/ipc/mojo/ipc_channel_mojo_unittest.cc
@@ -55,33 +55,11 @@ class ListenerThatExpectsOK : public IPC::Listener {
bool received_ok_;
};
-class ListenerThatShouldBeNeverCalled : public IPC::Listener {
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
- NOTREACHED();
- return true;
- }
-
- virtual void OnChannelError() OVERRIDE {
- NOTREACHED();
- }
-
- virtual void OnChannelConnected(int32 peer_pid) OVERRIDE {
- NOTREACHED();
- }
-
- virtual void OnBadMessageReceived(const IPC::Message& message) OVERRIDE {
- NOTREACHED();
- }
-};
-
class ChannelClient {
public:
explicit ChannelClient(IPC::Listener* listener, const char* name) {
- scoped_ptr<IPC::Channel> bootstrap(IPC::Channel::CreateClient(
- IPCTestBase::GetChannelName(name),
- &never_called_));
channel_ = IPC::ChannelMojo::Create(
- bootstrap.Pass(), IPC::Channel::MODE_CLIENT, listener,
+ IPCTestBase::GetChannelName(name), IPC::Channel::MODE_CLIENT, listener,
main_message_loop_.message_loop_proxy());
}
@@ -93,31 +71,20 @@ class ChannelClient {
private:
scoped_ptr<IPC::ChannelMojo> channel_;
- ListenerThatShouldBeNeverCalled never_called_;
base::MessageLoopForIO main_message_loop_;
};
class IPCChannelMojoTest : public IPCTestBase {
- public:
- void CreateMojoChannel(IPC::Listener* listener);
-
protected:
- virtual void SetUp() OVERRIDE {
- IPCTestBase::SetUp();
+ virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
+ const IPC::ChannelHandle& handle,
+ base::TaskRunner* runner) OVERRIDE {
+ return IPC::ChannelMojo::CreateFactory(
+ handle, IPC::Channel::MODE_SERVER, runner);
}
-
- ListenerThatShouldBeNeverCalled never_called_;
};
-void IPCChannelMojoTest::CreateMojoChannel(IPC::Listener* listener) {
- CreateChannel(&never_called_);
- scoped_ptr<IPC::Channel> mojo_channel = IPC::ChannelMojo::Create(
- ReleaseChannel(), IPC::Channel::MODE_SERVER, listener,
- task_runner()).PassAs<IPC::Channel>();
- SetChannel(mojo_channel.PassAs<IPC::Channel>());
-}
-
class TestChannelListenerWithExtraExpectations
: public IPC::TestChannelListener {
public:
@@ -142,7 +109,7 @@ TEST_F(IPCChannelMojoTest, ConnectedFromClient) {
// Set up IPC channel and start client.
TestChannelListenerWithExtraExpectations listener;
- CreateMojoChannel(&listener);
+ CreateChannel(&listener);
listener.Init(sender());
ASSERT_TRUE(ConnectChannel());
ASSERT_TRUE(StartClient());
@@ -236,7 +203,7 @@ TEST_F(IPCChannelMojoTest, SendPlatformHandle) {
Init("IPCChannelMojoTestSendPlatformHandleClient");
ListenerThatExpectsOK listener;
- CreateMojoChannel(&listener);
+ CreateChannel(&listener);
ASSERT_TRUE(ConnectChannel());
ASSERT_TRUE(StartClient());
diff --git a/ipc/mojo/ipc_mojo.gyp b/ipc/mojo/ipc_mojo.gyp
index c408a17..f01d48f 100644
--- a/ipc/mojo/ipc_mojo.gyp
+++ b/ipc/mojo/ipc_mojo.gyp
@@ -64,5 +64,30 @@
'conditions': [
],
},
+ {
+ 'target_name': 'ipc_mojo_perftests',
+ 'type': '<(gtest_target_type)',
+ 'dependencies': [
+ '../ipc.gyp:ipc',
+ '../ipc.gyp:test_support_ipc',
+ '../../base/base.gyp:base',
+ '../../base/base.gyp:base_i18n',
+ '../../base/base.gyp:test_support_base',
+ '../../base/base.gyp:test_support_perf',
+ '../../mojo/mojo_base.gyp:mojo_cpp_bindings',
+ '../../mojo/mojo_base.gyp:mojo_environment_chromium',
+ '../../mojo/mojo_base.gyp:mojo_system_impl',
+ '../../testing/gtest.gyp:gtest',
+ 'ipc_mojo',
+ ],
+ 'include_dirs': [
+ '..'
+ ],
+ 'sources': [
+ 'ipc_mojo_perftest.cc',
+ ],
+ 'conditions': [
+ ],
+ },
],
}
diff --git a/ipc/mojo/ipc_mojo_perftest.cc b/ipc/mojo/ipc_mojo_perftest.cc
new file mode 100644
index 0000000..d433703
--- /dev/null
+++ b/ipc/mojo/ipc_mojo_perftest.cc
@@ -0,0 +1,87 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/lazy_instance.h"
+#include "ipc/ipc_perftest_support.h"
+#include "ipc/mojo/ipc_channel_mojo.h"
+#include "mojo/embedder/test_embedder.h"
+
+namespace {
+
+// This is needed because we rely on //base/test:test_support_perf and
+// it provides main() which doesn't have Mojo initialization. We need
+// some way to call InitWithSimplePlatformSupport() only once before
+// using Mojo.
+struct MojoInitialier {
+ MojoInitialier() {
+ mojo::embedder::test::InitWithSimplePlatformSupport();
+ }
+};
+
+base::LazyInstance<MojoInitialier> g_mojo_initializer
+ = LAZY_INSTANCE_INITIALIZER;
+
+class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase {
+public:
+ typedef IPC::test::IPCChannelPerfTestBase Super;
+
+ MojoChannelPerfTest();
+
+ virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
+ const IPC::ChannelHandle& handle,
+ base::TaskRunner* runner) OVERRIDE {
+ return IPC::ChannelMojo::CreateFactory(
+ handle, IPC::Channel::MODE_SERVER, runner);
+ }
+
+ void set_io_thread_task_runner(base::TaskRunner* runner) {
+ io_thread_task_runner_ = runner;
+ }
+
+ private:
+ base::TaskRunner* io_thread_task_runner_;
+};
+
+MojoChannelPerfTest::MojoChannelPerfTest()
+ : io_thread_task_runner_() {
+ g_mojo_initializer.Get();
+}
+
+
+TEST_F(MojoChannelPerfTest, ChannelPingPong) {
+ RunTestChannelPingPong(GetDefaultTestParams());
+}
+
+TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) {
+ RunTestChannelProxyPingPong(GetDefaultTestParams());
+}
+
+class MojoTestClient : public IPC::test::PingPongTestClient {
+ public:
+ typedef IPC::test::PingPongTestClient SuperType;
+
+ MojoTestClient();
+
+ virtual scoped_ptr<IPC::Channel> CreateChannel(
+ IPC::Listener* listener) OVERRIDE;
+};
+
+MojoTestClient::MojoTestClient() {
+ g_mojo_initializer.Get();
+}
+
+scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel(
+ IPC::Listener* listener) {
+ return scoped_ptr<IPC::Channel>(IPC::ChannelMojo::Create(
+ IPCTestBase::GetChannelName("PerformanceClient"),
+ IPC::Channel::MODE_CLIENT, listener,
+ task_runner()));
+}
+
+MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) {
+ MojoTestClient client;
+ return client.RunMain();
+}
+
+} // namespace