summaryrefslogtreecommitdiffstats
path: root/mojo/common
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-14 16:30:43 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-14 16:30:43 +0000
commit544076a74bd174d28984d7becb77e607eb37098c (patch)
treee4a1edae7c386e325471fdd1ab6dc4ce9c012ef1 /mojo/common
parentd629cf0ee9accda8464490d917e2b594489f2146 (diff)
downloadchromium_src-544076a74bd174d28984d7becb77e607eb37098c.zip
chromium_src-544076a74bd174d28984d7becb77e607eb37098c.tar.gz
chromium_src-544076a74bd174d28984d7becb77e607eb37098c.tar.bz2
Mojo: Rename PlatformChannelHandle to PlatformHandle, etc.
We're going to need handles to things other than "channels", so rename PlatformChannelHandle to PlatformHandle. Rename/refactor PlatformChannel to ScopedPlatformHandle (because that's what it really was), and make it move-only. Adapt everything else to fit this model. R=darin@chromium.org Review URL: https://codereview.chromium.org/137273003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244742 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/common')
-rw-r--r--mojo/common/test/multiprocess_test_base.cc21
-rw-r--r--mojo/common/test/multiprocess_test_base.h6
-rw-r--r--mojo/common/test/multiprocess_test_base_unittest.cc32
3 files changed, 23 insertions, 36 deletions
diff --git a/mojo/common/test/multiprocess_test_base.cc b/mojo/common/test/multiprocess_test_base.cc
index 1ff9d95..9a1b8b3 100644
--- a/mojo/common/test/multiprocess_test_base.cc
+++ b/mojo/common/test/multiprocess_test_base.cc
@@ -10,7 +10,6 @@
#include "base/process/process_handle.h"
// TODO(vtl): Remove build_config.h include when fully implemented on Windows.
#include "build/build_config.h"
-#include "mojo/system/platform_channel.h"
#include "mojo/system/platform_channel_pair.h"
namespace mojo {
@@ -32,14 +31,14 @@ void MultiprocessTestBase::SetUp() {
// TODO(vtl): Not implemented on Windows yet.
#if defined(OS_POSIX)
platform_channel_pair_.reset(new system::PlatformChannelPair());
- server_platform_channel = platform_channel_pair_->CreateServerChannel();
+ server_platform_handle = platform_channel_pair_->PassServerHandle();
#endif
}
void MultiprocessTestBase::TearDown() {
CHECK_EQ(test_child_handle_, base::kNullProcessHandle);
- server_platform_channel.reset();
+ server_platform_handle.reset();
platform_channel_pair_.reset();
MultiProcessTest::TearDown();
@@ -55,8 +54,8 @@ void MultiprocessTestBase::StartChild(const std::string& test_child_name) {
#if defined(OS_POSIX)
CommandLine unused(CommandLine::NO_PROGRAM);
base::FileHandleMappingVector fds_to_map;
- platform_channel_pair_->PrepareToPassClientChannelToChildProcess(&unused,
- &fds_to_map);
+ platform_channel_pair_->PrepareToPassClientHandleToChildProcess(&unused,
+ &fds_to_map);
test_child_handle_ = SpawnChild(test_child_main, fds_to_map, false);
#elif defined(OS_WIN)
test_child_handle_ = SpawnChild(test_child_main, false);
@@ -92,8 +91,8 @@ CommandLine MultiprocessTestBase::MakeCmdLine(const std::string& procname,
// TODO(vtl): Not implemented on Windows yet.
#if defined(OS_POSIX)
base::FileHandleMappingVector unused;
- platform_channel_pair_->PrepareToPassClientChannelToChildProcess(
- &command_line, &unused);
+ platform_channel_pair_->PrepareToPassClientHandleToChildProcess(&command_line,
+ &unused);
#endif
return command_line;
}
@@ -103,16 +102,14 @@ void MultiprocessTestBase::ChildSetup() {
CHECK(CommandLine::InitializedForCurrentProcess());
// TODO(vtl): Not implemented on Windows yet.
#if defined(OS_POSIX)
- client_platform_channel =
- system::PlatformChannelPair::CreateClientChannelFromParentProcess(
+ client_platform_handle =
+ system::PlatformChannelPair::PassClientHandleFromParentProcess(
*CommandLine::ForCurrentProcess());
- CHECK(client_platform_channel.get());
#endif
}
// static
-scoped_ptr<system::PlatformChannel>
- MultiprocessTestBase::client_platform_channel;
+system::ScopedPlatformHandle MultiprocessTestBase::client_platform_handle;
} // namespace test
} // namespace mojo
diff --git a/mojo/common/test/multiprocess_test_base.h b/mojo/common/test/multiprocess_test_base.h
index d86c61a..9b233f0 100644
--- a/mojo/common/test/multiprocess_test_base.h
+++ b/mojo/common/test/multiprocess_test_base.h
@@ -11,12 +11,12 @@
#include "base/compiler_specific.h"
#include "base/process/process_handle.h"
#include "base/test/multiprocess_test.h"
+#include "mojo/system/scoped_platform_handle.h"
#include "testing/multiprocess_func_list.h"
namespace mojo {
namespace system {
-class PlatformChannel;
class PlatformChannelPair;
}
@@ -45,10 +45,10 @@ class MultiprocessTestBase : public base::MultiProcessTest {
static void ChildSetup();
// For use in the main process:
- scoped_ptr<system::PlatformChannel> server_platform_channel;
+ system::ScopedPlatformHandle server_platform_handle;
// For use (and only valid) in the child process:
- static scoped_ptr<system::PlatformChannel> client_platform_channel;
+ static system::ScopedPlatformHandle client_platform_handle;
private:
virtual CommandLine MakeCmdLine(const std::string& procname,
diff --git a/mojo/common/test/multiprocess_test_base_unittest.cc b/mojo/common/test/multiprocess_test_base_unittest.cc
index e2c1903..6c8d756 100644
--- a/mojo/common/test/multiprocess_test_base_unittest.cc
+++ b/mojo/common/test/multiprocess_test_base_unittest.cc
@@ -6,8 +6,7 @@
#include "base/logging.h"
#include "build/build_config.h"
-#include "mojo/system/platform_channel.h"
-#include "mojo/system/platform_channel_handle.h"
+#include "mojo/system/scoped_platform_handle.h"
#if defined(OS_POSIX)
#include <fcntl.h>
@@ -25,8 +24,7 @@ class MultiprocessTestBaseTest : public test::MultiprocessTestBase {
TEST_F(MultiprocessTestBaseTest, RunChild) {
// TODO(vtl): Not implemented on Windows yet.
#if defined(OS_POSIX)
- EXPECT_TRUE(server_platform_channel.get());
- EXPECT_TRUE(server_platform_channel->is_valid());
+ EXPECT_TRUE(server_platform_handle.is_valid());
#endif
StartChild("RunChild");
EXPECT_EQ(123, WaitForChildShutdown());
@@ -35,8 +33,7 @@ TEST_F(MultiprocessTestBaseTest, RunChild) {
MOJO_MULTIPROCESS_TEST_CHILD_MAIN(RunChild) {
// TODO(vtl): Not implemented on Windows yet.
#if defined(OS_POSIX)
- CHECK(MultiprocessTestBaseTest::client_platform_channel.get());
- CHECK(MultiprocessTestBaseTest::client_platform_channel->is_valid());
+ CHECK(MultiprocessTestBaseTest::client_platform_handle.is_valid());
#endif
return 123;
}
@@ -47,19 +44,16 @@ TEST_F(MultiprocessTestBaseTest, TestChildMainNotFound) {
EXPECT_FALSE(result >= 0 && result <= 127);
}
-// POSIX-specific test of passed channel ---------------------------------------
+// POSIX-specific test of passed handle ----------------------------------------
#if defined(OS_POSIX)
TEST_F(MultiprocessTestBaseTest, PassedChannelPosix) {
- EXPECT_TRUE(server_platform_channel.get());
- EXPECT_TRUE(server_platform_channel->is_valid());
+ EXPECT_TRUE(server_platform_handle.is_valid());
StartChild("PassedChannelPosix");
// Take ownership of the FD.
- mojo::system::PlatformChannelHandle channel =
- server_platform_channel->PassHandle();
- server_platform_channel.reset();
- int fd = channel.fd;
+ system::ScopedPlatformHandle handle = server_platform_handle.Pass();
+ int fd = handle.get().fd;
// The FD should be non-blocking. Check this.
CHECK((fcntl(fd, F_GETFL) & O_NONBLOCK));
@@ -82,14 +76,12 @@ TEST_F(MultiprocessTestBaseTest, PassedChannelPosix) {
}
MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PassedChannelPosix) {
- CHECK(MultiprocessTestBaseTest::client_platform_channel.get());
- CHECK(MultiprocessTestBaseTest::client_platform_channel->is_valid());
+ CHECK(MultiprocessTestBaseTest::client_platform_handle.is_valid());
// Take ownership of the FD.
- mojo::system::PlatformChannelHandle channel =
- MultiprocessTestBaseTest::client_platform_channel->PassHandle();
- MultiprocessTestBaseTest::client_platform_channel.reset();
- int fd = channel.fd;
+ system::ScopedPlatformHandle handle =
+ MultiprocessTestBaseTest::client_platform_handle.Pass();
+ int fd = handle.get().fd;
// The FD should still be non-blocking. Check this.
CHECK((fcntl(fd, F_GETFL) & O_NONBLOCK));
@@ -106,8 +98,6 @@ MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PassedChannelPosix) {
ssize_t write_size = HANDLE_EINTR(write(fd, &c, 1));
CHECK_EQ(write_size, 1);
- PCHECK(close(fd) == 0);
-
// And return it, incremented again.
c++;
return static_cast<int>(c);