| Index: mojo/edk/system/raw_channel_posix.cc
|
| diff --git a/third_party/mojo/src/mojo/edk/system/raw_channel_posix.cc b/mojo/edk/system/raw_channel_posix.cc
|
| similarity index 89%
|
| copy from third_party/mojo/src/mojo/edk/system/raw_channel_posix.cc
|
| copy to mojo/edk/system/raw_channel_posix.cc
|
| index 47862a709f691120dc47b328439d295b09ebc147..4cfdbd74410bfdc56a8a5a28764fe6347334f6fc 100644
|
| --- a/third_party/mojo/src/mojo/edk/system/raw_channel_posix.cc
|
| +++ b/mojo/edk/system/raw_channel_posix.cc
|
| @@ -35,9 +35,6 @@ class RawChannelPosix final : public RawChannel,
|
| explicit RawChannelPosix(embedder::ScopedPlatformHandle handle);
|
| ~RawChannelPosix() override;
|
|
|
| - // |RawChannel| public methods:
|
| - size_t GetSerializedPlatformHandleSize() const override;
|
| -
|
| private:
|
| // |RawChannel| protected methods:
|
| // Actually override this so that we can send multiple messages with (only)
|
| @@ -46,6 +43,10 @@ class RawChannelPosix final : public RawChannel,
|
| // Override this to handle those extra FD-only messages.
|
| bool OnReadMessageForRawChannel(
|
| const MessageInTransit::View& message_view) override;
|
| +
|
| + embedder::ScopedPlatformHandle ReleaseHandleNoLock(
|
| + std::vector<char>* read_buffer_out) override;
|
| + embedder::PlatformHandle HandleForDebuggingNoLock() override;
|
| IOResult Read(size_t* bytes_read) override;
|
| IOResult ScheduleRead() override;
|
| embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles(
|
| @@ -114,11 +115,6 @@ RawChannelPosix::~RawChannelPosix() {
|
| embedder::CloseAllPlatformHandles(&read_platform_handles_);
|
| }
|
|
|
| -size_t RawChannelPosix::GetSerializedPlatformHandleSize() const {
|
| - // We don't actually need any space on POSIX (since we just send FDs).
|
| - return 0;
|
| -}
|
| -
|
| void RawChannelPosix::EnqueueMessageNoLock(
|
| scoped_ptr<MessageInTransit> message) {
|
| if (message->transport_data()) {
|
| @@ -134,9 +130,8 @@ void RawChannelPosix::EnqueueMessageNoLock(
|
| embedder::kPlatformChannelMaxNumHandles;
|
| i += embedder::kPlatformChannelMaxNumHandles) {
|
| scoped_ptr<MessageInTransit> fd_message(new MessageInTransit(
|
| - MessageInTransit::Type::RAW_CHANNEL,
|
| - MessageInTransit::Subtype::RAW_CHANNEL_POSIX_EXTRA_PLATFORM_HANDLES,
|
| - 0, nullptr));
|
| + MessageInTransit::Type::RAW_CHANNEL_POSIX_EXTRA_PLATFORM_HANDLES, 0,
|
| + nullptr));
|
| embedder::ScopedPlatformHandleVectorPtr fds(
|
| new embedder::PlatformHandleVector(
|
| platform_handles->begin() + i,
|
| @@ -158,10 +153,8 @@ void RawChannelPosix::EnqueueMessageNoLock(
|
|
|
| bool RawChannelPosix::OnReadMessageForRawChannel(
|
| const MessageInTransit::View& message_view) {
|
| - DCHECK_EQ(message_view.type(), MessageInTransit::Type::RAW_CHANNEL);
|
| -
|
| - if (message_view.subtype() ==
|
| - MessageInTransit::Subtype::RAW_CHANNEL_POSIX_EXTRA_PLATFORM_HANDLES) {
|
| + if (message_view.type() ==
|
| + MessageInTransit::Type::RAW_CHANNEL_POSIX_EXTRA_PLATFORM_HANDLES) {
|
| // We don't need to do anything. |RawChannel| won't extract the platform
|
| // handles, and they'll be accumulated in |Read()|.
|
| return true;
|
| @@ -170,6 +163,41 @@ bool RawChannelPosix::OnReadMessageForRawChannel(
|
| return RawChannel::OnReadMessageForRawChannel(message_view);
|
| }
|
|
|
| +
|
| +embedder::ScopedPlatformHandle RawChannelPosix::ReleaseHandleNoLock(
|
| + std::vector<char>* read_buffer_out) {
|
| + std::vector<WriteBuffer::Buffer> buffers;
|
| + write_buffer_no_lock()->GetBuffers(&buffers);
|
| + if (!buffers.empty()) {
|
| + // TODO(jam): copy code in OnShutdownNoLock
|
| + NOTREACHED() << "releasing handle with pending write buffer";
|
| + }
|
| +
|
| + NOTREACHED() << "TODO(jam) IMPLEMENT";/*
|
| + if (handle_.is_valid()) {
|
| + // SetInitialBuffer could have been called on main thread before OnInit
|
| + // is called on Io thread. and in meantime releasehandle called.
|
| + //DCHECK(read_buffer()->num_valid_bytes() == 0);
|
| + if (read_buffer()->num_valid_bytes()) {
|
| + read_buffer_out->resize(read_buffer()->num_valid_bytes());
|
| + memcpy(&(*read_buffer_out)[0], read_buffer()->buffer(),
|
| + read_buffer()->num_valid_bytes());
|
| + read_buffer()->Reset();
|
| + }
|
| + DCHECK(write_buffer_no_lock()->queue_size() == 0);
|
| + return embedder::ScopedPlatformHandle(
|
| + embedder::PlatformHandle(handle_.release().handle));
|
| + }
|
| +
|
| + return io_handler_->ReleaseHandle(read_buffer_out);
|
| + */
|
| + return fd_.Pass();
|
| +}
|
| +
|
| +embedder::PlatformHandle RawChannelPosix::HandleForDebuggingNoLock() {
|
| + return fd_.get();
|
| +}
|
| +
|
| RawChannel::IOResult RawChannelPosix::Read(size_t* bytes_read) {
|
| DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
|
| DCHECK(!pending_read_);
|
| @@ -470,9 +498,13 @@ void RawChannelPosix::WaitToWrite() {
|
|
|
| // Static factory method declared in raw_channel.h.
|
| // static
|
| -scoped_ptr<RawChannel> RawChannel::Create(
|
| - embedder::ScopedPlatformHandle handle) {
|
| - return make_scoped_ptr(new RawChannelPosix(handle.Pass()));
|
| +RawChannel* RawChannel::Create(embedder::ScopedPlatformHandle handle) {
|
| + return new RawChannelPosix(handle.Pass());
|
| +}
|
| +
|
| +size_t RawChannel::GetSerializedPlatformHandleSize() {
|
| + // We don't actually need any space on POSIX (since we just send FDs).
|
| + return 0;
|
| }
|
|
|
| } // namespace system
|
|
|