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

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

Issue 1478503003: EDK: Convert most uses of PlatformHandleVector to std::vector<ScopedPlatformHandle>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « mojo/edk/system/raw_channel_posix.cc ('k') | mojo/edk/system/remote_consumer_data_pipe_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/raw_channel_unittest.cc
diff --git a/mojo/edk/system/raw_channel_unittest.cc b/mojo/edk/system/raw_channel_unittest.cc
index 202c152dcaa5cf71734a04606bd62542d2e6aaee..a5278cbe3a50026dc5a444a869c5fdaab78677e8 100644
--- a/mojo/edk/system/raw_channel_unittest.cc
+++ b/mojo/edk/system/raw_channel_unittest.cc
@@ -31,7 +31,9 @@
#include "mojo/public/cpp/system/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
+using mojo::embedder::ScopedPlatformHandle;
using mojo::util::AutoResetWaitableEvent;
+using mojo::util::MakeUnique;
using mojo::util::Mutex;
using mojo::util::MutexLocker;
@@ -95,7 +97,7 @@ class RawChannelTest : public testing::Test {
protected:
test::TestIOThread* io_thread() { return &io_thread_; }
- embedder::ScopedPlatformHandle handles[2];
+ ScopedPlatformHandle handles[2];
private:
test::TestIOThread io_thread_;
@@ -111,9 +113,9 @@ class WriteOnlyRawChannelDelegate : public RawChannel::Delegate {
~WriteOnlyRawChannelDelegate() override {}
// |RawChannel::Delegate| implementation:
- void OnReadMessage(
- const MessageInTransit::View& /*message_view*/,
- embedder::ScopedPlatformHandleVectorPtr /*platform_handles*/) override {
+ void OnReadMessage(const MessageInTransit::View& /*message_view*/,
+ std::unique_ptr<std::vector<ScopedPlatformHandle>>
+ /*platform_handles*/) override {
CHECK(false); // Should not get called.
}
void OnError(Error error) override {
@@ -224,9 +226,9 @@ class ReadCheckerRawChannelDelegate : public RawChannel::Delegate {
~ReadCheckerRawChannelDelegate() override {}
// |RawChannel::Delegate| implementation (called on the I/O thread):
- void OnReadMessage(
- const MessageInTransit::View& message_view,
- embedder::ScopedPlatformHandleVectorPtr platform_handles) override {
+ void OnReadMessage(const MessageInTransit::View& message_view,
+ std::unique_ptr<std::vector<ScopedPlatformHandle>>
+ platform_handles) override {
EXPECT_FALSE(platform_handles);
size_t position;
@@ -339,9 +341,9 @@ class ReadCountdownRawChannelDelegate : public RawChannel::Delegate {
~ReadCountdownRawChannelDelegate() override {}
// |RawChannel::Delegate| implementation (called on the I/O thread):
- void OnReadMessage(
- const MessageInTransit::View& message_view,
- embedder::ScopedPlatformHandleVectorPtr platform_handles) override {
+ void OnReadMessage(const MessageInTransit::View& message_view,
+ std::unique_ptr<std::vector<ScopedPlatformHandle>>
+ platform_handles) override {
EXPECT_FALSE(platform_handles);
EXPECT_LT(count_, expected_count_);
@@ -553,9 +555,9 @@ class ShutdownOnReadMessageRawChannelDelegate : public RawChannel::Delegate {
~ShutdownOnReadMessageRawChannelDelegate() override {}
// |RawChannel::Delegate| implementation (called on the I/O thread):
- void OnReadMessage(
- const MessageInTransit::View& message_view,
- embedder::ScopedPlatformHandleVectorPtr platform_handles) override {
+ void OnReadMessage(const MessageInTransit::View& message_view,
+ std::unique_ptr<std::vector<ScopedPlatformHandle>>
+ platform_handles) override {
EXPECT_FALSE(platform_handles);
EXPECT_FALSE(did_shutdown_);
EXPECT_TRUE(
@@ -629,7 +631,8 @@ class ShutdownOnErrorRawChannelDelegate : public RawChannel::Delegate {
// |RawChannel::Delegate| implementation (called on the I/O thread):
void OnReadMessage(
const MessageInTransit::View& /*message_view*/,
- embedder::ScopedPlatformHandleVectorPtr /*platform_handles*/) override {
+ std::unique_ptr<std::vector<ScopedPlatformHandle>> /*platform_handles*/)
+ override {
CHECK(false); // Should not get called.
}
void OnError(Error error) override {
@@ -728,9 +731,9 @@ class ReadPlatformHandlesCheckerRawChannelDelegate
~ReadPlatformHandlesCheckerRawChannelDelegate() override {}
// |RawChannel::Delegate| implementation (called on the I/O thread):
- void OnReadMessage(
- const MessageInTransit::View& message_view,
- embedder::ScopedPlatformHandleVectorPtr platform_handles) override {
+ void OnReadMessage(const MessageInTransit::View& message_view,
+ std::unique_ptr<std::vector<ScopedPlatformHandle>>
+ platform_handles) override {
const char kHello[] = "hello";
EXPECT_EQ(sizeof(kHello), message_view.num_bytes());
@@ -738,9 +741,9 @@ class ReadPlatformHandlesCheckerRawChannelDelegate
ASSERT_TRUE(platform_handles);
ASSERT_EQ(2u, platform_handles->size());
- embedder::ScopedPlatformHandle h1(platform_handles->at(0));
+ ScopedPlatformHandle h1(std::move(platform_handles->at(0)));
EXPECT_TRUE(h1.is_valid());
- embedder::ScopedPlatformHandle h2(platform_handles->at(1));
+ ScopedPlatformHandle h2(std::move(platform_handles->at(1)));
EXPECT_TRUE(h2.is_valid());
platform_handles->clear();
@@ -798,12 +801,11 @@ TEST_F(RawChannelTest, ReadWritePlatformHandles) {
{
const char kHello[] = "hello";
- embedder::ScopedPlatformHandleVectorPtr platform_handles(
- new embedder::PlatformHandleVector());
+ auto platform_handles = MakeUnique<std::vector<ScopedPlatformHandle>>();
platform_handles->push_back(
- mojo::test::PlatformHandleFromFILE(std::move(fp1)).release());
+ mojo::test::PlatformHandleFromFILE(std::move(fp1)));
platform_handles->push_back(
- mojo::test::PlatformHandleFromFILE(std::move(fp2)).release());
+ mojo::test::PlatformHandleFromFILE(std::move(fp2)));
std::unique_ptr<MessageInTransit> message(
new MessageInTransit(MessageInTransit::Type::ENDPOINT_CLIENT,
« no previous file with comments | « mojo/edk/system/raw_channel_posix.cc ('k') | mojo/edk/system/remote_consumer_data_pipe_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698