| 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 67%
|
| copy from third_party/mojo/src/mojo/edk/system/message_pipe_perftest.cc
|
| copy to mojo/edk/system/message_pipe_perftest.cc
|
| index 562acbd9f8a816a1a7067e359401eb0c7b5dbce1..62114cce8931f4cb19f4f2ba2db850fe13e33b11 100644
|
| --- a/third_party/mojo/src/mojo/edk/system/message_pipe_perftest.cc
|
| +++ b/mojo/edk/system/message_pipe_perftest.cc
|
| @@ -2,27 +2,18 @@
|
| // 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/channel.h"
|
| -#include "mojo/edk/system/local_message_pipe_endpoint.h"
|
| -#include "mojo/edk/system/message_pipe.h"
|
| +#include "mojo/edk/system/handle_signals_state.h"
|
| #include "mojo/edk/system/message_pipe_test_utils.h"
|
| -#include "mojo/edk/system/proxy_message_pipe_endpoint.h"
|
| -#include "mojo/edk/system/raw_channel.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"
|
|
|
| namespace mojo {
|
| @@ -32,7 +23,10 @@ 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);
|
|
|
| @@ -93,13 +87,15 @@ class MultiprocessMessagePipePerfTest
|
| // not including any "quitquitquit" message, modulo 100.
|
| MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PingPongClient) {
|
| embedder::SimplePlatformSupport platform_support;
|
| - test::ChannelThread channel_thread(&platform_support);
|
| + base::MessageLoop message_loop(base::MessageLoop::TYPE_IO);
|
| + base::TestIOThread test_io_thread(base::TestIOThread::kAutoStart);
|
| + mojo::test::ScopedIPCSupport ipc_support(test_io_thread.task_runner());
|
| +
|
| embedder::ScopedPlatformHandle client_platform_handle =
|
| mojo::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 =
|
| + mojo::embedder::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 = mojo::embedder::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,11 +150,10 @@ 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());
|
| }
|
|
|
|
|