Commit 894661c0 authored by Fabrice de Gans-Riberi's avatar Fabrice de Gans-Riberi Committed by Commit Bot

Fuchsia: Include some Posix-only code paths in ipc.

Some Posix-only instances were missed when disabling the OS_POSIX
macro for the Fuchsia build.

Bug: 836416
Change-Id: I291465a50813e984bdca223b1e533c2ad624062c
Reviewed-on: https://chromium-review.googlesource.com/1070625Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Fabrice de Gans-Riberi <fdegans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561569}
parent eb41198f
......@@ -47,7 +47,7 @@
#include "mojo/public/cpp/system/wait.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
#include "base/file_descriptor_posix.h"
#include "ipc/ipc_platform_file_attachment_posix.h"
#endif
......@@ -283,7 +283,7 @@ class HandleSendingHelper {
GetSendingFileContent());
}
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
static base::FilePath GetSendingFilePath(const base::FilePath& dir_path) {
return dir_path.Append("ListenerThatExpectsFile.txt");
}
......@@ -1500,7 +1500,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(
}
#endif // !defined(OS_MACOSX)
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
class ListenerThatExpectsFile : public TestListenerBase {
public:
......@@ -1599,7 +1599,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(
Close();
}
#endif // defined(OS_POSIX)
#endif // defined(OS_POSIX) || defined(OS_FUCHSIA)
#if defined(OS_LINUX)
......
......@@ -442,7 +442,7 @@ ChannelProxy::~ChannelProxy() {
void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle,
Channel::Mode mode,
bool create_pipe_now) {
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
// When we are creating a server on POSIX, we need its file descriptor
// to be created immediately so that it can be accessed and passed
// to other processes. Forcing it to be created immediately avoids
......@@ -450,7 +450,7 @@ void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle,
if (mode & Channel::MODE_SERVER_FLAG) {
create_pipe_now = true;
}
#endif // defined(OS_POSIX)
#endif // defined(OS_POSIX) || defined(OS_FUCHSIA)
Init(
ChannelFactory::Create(channel_handle, mode, context_->ipc_task_runner()),
create_pipe_now);
......
......@@ -41,7 +41,7 @@ class COMPONENT_EXPORT(IPC) Listener {
const std::string& interface_name,
mojo::ScopedInterfaceEndpointHandle handle) {}
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
// Called on the server side when a channel that listens for connections
// denies an attempt to connect.
virtual void OnChannelDenied() {}
......@@ -49,7 +49,7 @@ class COMPONENT_EXPORT(IPC) Listener {
// Called on the server side when a channel that listens for connections
// has an error that causes the listening channel to close.
virtual void OnChannelListenError() {}
#endif // OS_POSIX
#endif // OS_POSIX || OS_FUCHSIA
protected:
virtual ~Listener() {}
......
......@@ -49,7 +49,7 @@ Message::~Message() = default;
Message::Message() : base::Pickle(sizeof(Header)) {
header()->routing = header()->type = 0;
header()->flags = GetRefNumUpper24();
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
header()->num_fds = 0;
header()->pad = 0;
#endif
......@@ -62,7 +62,7 @@ Message::Message(int32_t routing_id, uint32_t type, PriorityValue priority)
header()->type = type;
DCHECK((priority & 0xffffff00) == 0);
header()->flags = priority | GetRefNumUpper24();
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
header()->num_fds = 0;
header()->pad = 0;
#endif
......
......@@ -249,7 +249,7 @@ class IPC_MESSAGE_SUPPORT_EXPORT Message : public base::Pickle {
int32_t routing; // ID of the view that this message is destined for
uint32_t type; // specifies the user-defined message type
uint32_t flags; // specifies control flags for the message
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
uint16_t num_fds; // the number of descriptors included with this message
uint16_t pad; // explicitly initialize this to appease valgrind
#endif
......
......@@ -9,7 +9,7 @@
#include "ipc/ipc_mojo_handle_attachment.h"
#include "mojo/public/cpp/system/platform_handle.h"
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
#include "base/posix/eintr_wrapper.h"
#include "ipc/ipc_platform_file_attachment_posix.h"
#endif
......@@ -30,13 +30,13 @@ namespace IPC {
namespace {
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
base::ScopedFD TakeOrDupFile(internal::PlatformFileAttachment* attachment) {
return attachment->Owns()
? base::ScopedFD(attachment->TakePlatformFile())
: base::ScopedFD(HANDLE_EINTR(dup(attachment->file())));
}
#endif // defined(OS_POSIX)
#endif // defined(OS_POSIX) || defined(OS_FUCHSIA)
} // namespace
......@@ -49,7 +49,7 @@ mojo::ScopedHandle MessageAttachment::TakeMojoHandle() {
case Type::MOJO_HANDLE:
return static_cast<internal::MojoHandleAttachment*>(this)->TakeHandle();
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
case Type::PLATFORM_FILE: {
// We dup() the handles in IPC::Message to transmit.
// IPC::MessageAttachmentSet has intricate lifetime semantics for FDs, so
......@@ -62,7 +62,7 @@ mojo::ScopedHandle MessageAttachment::TakeMojoHandle() {
}
return mojo::WrapPlatformFile(file.release());
}
#endif // defined(OS_POSIX)
#endif // defined(OS_POSIX) || defined(OS_FUCHSIA)
#if defined(OS_MACOSX) && !defined(OS_IOS)
case Type::MACH_PORT: {
......@@ -116,14 +116,14 @@ scoped_refptr<MessageAttachment> MessageAttachment::CreateFromMojoHandle(
if (unwrap_result != MOJO_RESULT_OK)
return nullptr;
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
if (type == Type::PLATFORM_FILE) {
base::PlatformFile file = base::kInvalidPlatformFile;
if (platform_handle.type == MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR)
file = static_cast<base::PlatformFile>(platform_handle.value);
return new internal::PlatformFileAttachment(file);
}
#endif // defined(OS_POSIX)
#endif // defined(OS_POSIX) || defined(OS_FUCHSIA)
#if defined(OS_MACOSX) && !defined(OS_IOS)
if (type == Type::MACH_PORT) {
......
......@@ -47,7 +47,7 @@ const unsigned kNumFDsToSend = 7; // per message
const unsigned kNumMessages = 20;
const char* kDevZeroPath = "/dev/zero";
#if defined(OS_POSIX)
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
static_assert(kNumFDsToSend ==
IPC::MessageAttachmentSet::kMaxDescriptorsPerMessage,
"The number of FDs to send must be kMaxDescriptorsPerMessage.");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment