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

Unified Diff: mojo/edk/system/message_pipe_perftest.cc

Issue 1350023003: Add a Mojo EDK for Chrome that uses one OS pipe per message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanup Created 5 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 side-by-side diff with in-line comments
Download patch
Index: mojo/edk/system/message_pipe_perftest.cc
diff --git a/third_party/mojo/src/mojo/edk/system/message_pipe_perftest.cc b/mojo/edk/system/message_pipe_perftest.cc
similarity index 58%
copy from third_party/mojo/src/mojo/edk/system/message_pipe_perftest.cc
copy to mojo/edk/system/message_pipe_perftest.cc
index 3d2b90c1bcb9d954e53122b60feb19b49bfc1d4e..5d59e6566083d9a0e2b358b5f03c6f3f43b45f15 100644
--- a/third_party/mojo/src/mojo/edk/system/message_pipe_perftest.cc
+++ b/mojo/edk/system/message_pipe_perftest.cc
@@ -2,37 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <string>
-#include <vector>
-
#include "base/bind.h"
-#include "base/location.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "base/test/perf_time_logger.h"
+#include "mojo/edk/embedder/embedder.h"
+#include "mojo/edk/embedder/scoped_platform_handle.h"
+#include "mojo/edk/system/handle_signals_state.h"
+#include "mojo/edk/system/message_pipe_test_utils.h"
+#include "mojo/edk/system/test_utils.h"
+#include "mojo/edk/test/test_utils.h"
+#include "mojo/public/c/system/functions.h"
+#include "mojo/public/cpp/system/message_pipe.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h"
-#include "third_party/mojo/src/mojo/edk/system/channel.h"
-#include "third_party/mojo/src/mojo/edk/system/local_message_pipe_endpoint.h"
-#include "third_party/mojo/src/mojo/edk/system/message_pipe.h"
-#include "third_party/mojo/src/mojo/edk/system/message_pipe_test_utils.h"
-#include "third_party/mojo/src/mojo/edk/system/proxy_message_pipe_endpoint.h"
-#include "third_party/mojo/src/mojo/edk/system/raw_channel.h"
-#include "third_party/mojo/src/mojo/edk/system/test_utils.h"
-#include "third_party/mojo/src/mojo/edk/test/test_utils.h"
namespace mojo {
-namespace system {
+namespace edk {
namespace {
class MultiprocessMessagePipePerfTest
: public test::MultiprocessMessagePipeTestBase {
public:
- MultiprocessMessagePipePerfTest() : message_count_(0), message_size_(0) {}
+ MultiprocessMessagePipePerfTest()
+ : test::MultiprocessMessagePipeTestBase(base::MessageLoop::TYPE_IO),
+ message_count_(0),
+ message_size_(0) {}
void SetUpMeasurement(int message_count, size_t message_size) {
message_count_ = message_count;
@@ -42,29 +36,29 @@ class MultiprocessMessagePipePerfTest
}
protected:
- void WriteWaitThenRead(scoped_refptr<MessagePipe> mp) {
- CHECK_EQ(mp->WriteMessage(0, UserPointer<const void>(payload_.data()),
+ void WriteWaitThenRead(MojoHandle mp) {
+ CHECK_EQ(MojoWriteMessage(mp, payload_.data(),
static_cast<uint32_t>(payload_.size()), nullptr,
- MOJO_WRITE_MESSAGE_FLAG_NONE),
+ 0, MOJO_WRITE_MESSAGE_FLAG_NONE),
MOJO_RESULT_OK);
HandleSignalsState hss;
- CHECK_EQ(test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss),
+ CHECK_EQ(MojoWait(mp, MOJO_HANDLE_SIGNAL_READABLE, MOJO_DEADLINE_INDEFINITE,
+ &hss),
MOJO_RESULT_OK);
uint32_t read_buffer_size = static_cast<uint32_t>(read_buffer_.size());
- CHECK_EQ(mp->ReadMessage(0, UserPointer<void>(&read_buffer_[0]),
- MakeUserPointer(&read_buffer_size), nullptr,
+ CHECK_EQ(MojoReadMessage(mp, &read_buffer_[0], &read_buffer_size, nullptr,
nullptr, MOJO_READ_MESSAGE_FLAG_NONE),
MOJO_RESULT_OK);
CHECK_EQ(read_buffer_size, static_cast<uint32_t>(payload_.size()));
}
- void SendQuitMessage(scoped_refptr<MessagePipe> mp) {
- CHECK_EQ(mp->WriteMessage(0, UserPointer<const void>(""), 0, nullptr,
+ void SendQuitMessage(MojoHandle mp) {
+ CHECK_EQ(MojoWriteMessage(mp, "", 0, nullptr, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE),
MOJO_RESULT_OK);
}
- void Measure(scoped_refptr<MessagePipe> mp) {
+ void Measure(MojoHandle mp) {
// Have one ping-pong to ensure channel being established.
WriteWaitThenRead(mp);
@@ -92,14 +86,16 @@ class MultiprocessMessagePipePerfTest
// (which it doesn't reply to). It'll return the number of messages received,
// not including any "quitquitquit" message, modulo 100.
MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PingPongClient) {
- embedder::SimplePlatformSupport platform_support;
- test::ChannelThread channel_thread(&platform_support);
- embedder::ScopedPlatformHandle client_platform_handle =
- mojo::test::MultiprocessTestHelper::client_platform_handle.Pass();
+ SimplePlatformSupport platform_support;
+ base::MessageLoop message_loop(base::MessageLoop::TYPE_IO);
+ base::TestIOThread test_io_thread(base::TestIOThread::kAutoStart);
+ test::ScopedIPCSupport ipc_support(test_io_thread.task_runner());
+
+ ScopedPlatformHandle client_platform_handle =
+ test::MultiprocessTestHelper::client_platform_handle.Pass();
CHECK(client_platform_handle.is_valid());
- scoped_refptr<ChannelEndpoint> ep;
- scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep));
- channel_thread.Start(client_platform_handle.Pass(), ep);
+ ScopedMessagePipeHandle mp =
+ CreateMessagePipe(client_platform_handle.Pass());
std::string buffer(1000000, '\0');
int rv = 0;
@@ -107,29 +103,29 @@ MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PingPongClient) {
// Wait for our end of the message pipe to be readable.
HandleSignalsState hss;
MojoResult result =
- test::WaitIfNecessary(mp, MOJO_HANDLE_SIGNAL_READABLE, &hss);
+ MojoWait(mp.get().value(), MOJO_HANDLE_SIGNAL_READABLE,
+ MOJO_DEADLINE_INDEFINITE, &hss);
if (result != MOJO_RESULT_OK) {
rv = result;
break;
}
uint32_t read_size = static_cast<uint32_t>(buffer.size());
- CHECK_EQ(mp->ReadMessage(0, UserPointer<void>(&buffer[0]),
- MakeUserPointer(&read_size), nullptr, nullptr,
- MOJO_READ_MESSAGE_FLAG_NONE),
+ CHECK_EQ(MojoReadMessage(mp.get().value(), &buffer[0],
+ &read_size, nullptr,
+ 0, MOJO_READ_MESSAGE_FLAG_NONE),
MOJO_RESULT_OK);
// Empty message indicates quit.
if (read_size == 0)
break;
- CHECK_EQ(mp->WriteMessage(0, UserPointer<const void>(&buffer[0]),
- static_cast<uint32_t>(read_size), nullptr,
- MOJO_WRITE_MESSAGE_FLAG_NONE),
+ CHECK_EQ(MojoWriteMessage(mp.get().value(), &buffer[0],
+ read_size,
+ nullptr, 0, MOJO_WRITE_MESSAGE_FLAG_NONE),
MOJO_RESULT_OK);
}
- mp->Close(0);
return rv;
}
@@ -145,9 +141,8 @@ MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PingPongClient) {
TEST_F(MultiprocessMessagePipePerfTest, MAYBE_PingPong) {
helper()->StartChild("PingPongClient");
- scoped_refptr<ChannelEndpoint> ep;
- scoped_refptr<MessagePipe> mp(MessagePipe::CreateLocalProxy(&ep));
- Init(ep);
+ ScopedMessagePipeHandle mp = CreateMessagePipe(
+ helper()->server_platform_handle.Pass());
// This values are set to align with one at ipc_pertests.cc for comparison.
const size_t kMsgSize[5] = {12, 144, 1728, 20736, 248832};
@@ -155,14 +150,13 @@ TEST_F(MultiprocessMessagePipePerfTest, MAYBE_PingPong) {
for (size_t i = 0; i < 5; i++) {
SetUpMeasurement(kMessageCount[i], kMsgSize[i]);
- Measure(mp);
+ Measure(mp.get().value());
}
- SendQuitMessage(mp);
- mp->Close(0);
+ SendQuitMessage(mp.get().value());
EXPECT_EQ(0, helper()->WaitForChildShutdown());
}
} // namespace
-} // namespace system
+} // namespace edk
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698