OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/system/raw_channel.h" | 5 #include "mojo/system/raw_channel.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sys/uio.h> | 8 #include <sys/uio.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // the message. Send as many control messages as needed first with FDs | 131 // the message. Send as many control messages as needed first with FDs |
132 // attached (and no data). | 132 // attached (and no data). |
133 size_t i = 0; | 133 size_t i = 0; |
134 for (; platform_handles->size() - i > | 134 for (; platform_handles->size() - i > |
135 embedder::kPlatformChannelMaxNumHandles; | 135 embedder::kPlatformChannelMaxNumHandles; |
136 i += embedder::kPlatformChannelMaxNumHandles) { | 136 i += embedder::kPlatformChannelMaxNumHandles) { |
137 scoped_ptr<MessageInTransit> fd_message(new MessageInTransit( | 137 scoped_ptr<MessageInTransit> fd_message(new MessageInTransit( |
138 MessageInTransit::kTypeRawChannel, | 138 MessageInTransit::kTypeRawChannel, |
139 MessageInTransit::kSubtypeRawChannelPosixExtraPlatformHandles, | 139 MessageInTransit::kSubtypeRawChannelPosixExtraPlatformHandles, |
140 0, | 140 0, |
141 NULL)); | 141 nullptr)); |
142 embedder::ScopedPlatformHandleVectorPtr fds( | 142 embedder::ScopedPlatformHandleVectorPtr fds( |
143 new embedder::PlatformHandleVector( | 143 new embedder::PlatformHandleVector( |
144 platform_handles->begin() + i, | 144 platform_handles->begin() + i, |
145 platform_handles->begin() + i + | 145 platform_handles->begin() + i + |
146 embedder::kPlatformChannelMaxNumHandles)); | 146 embedder::kPlatformChannelMaxNumHandles)); |
147 fd_message->SetTransportData( | 147 fd_message->SetTransportData( |
148 make_scoped_ptr(new TransportData(fds.Pass()))); | 148 make_scoped_ptr(new TransportData(fds.Pass()))); |
149 RawChannel::EnqueueMessageNoLock(fd_message.Pass()); | 149 RawChannel::EnqueueMessageNoLock(fd_message.Pass()); |
150 } | 150 } |
151 | 151 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 398 |
399 pending_write_ = false; | 399 pending_write_ = false; |
400 io_result = WriteNoLock(&platform_handles_written, &bytes_written); | 400 io_result = WriteNoLock(&platform_handles_written, &bytes_written); |
401 } | 401 } |
402 | 402 |
403 if (io_result != IO_PENDING) | 403 if (io_result != IO_PENDING) |
404 OnWriteCompleted(io_result, platform_handles_written, bytes_written); | 404 OnWriteCompleted(io_result, platform_handles_written, bytes_written); |
405 } | 405 } |
406 | 406 |
407 RawChannel::IOResult RawChannelPosix::ReadImpl(size_t* bytes_read) { | 407 RawChannel::IOResult RawChannelPosix::ReadImpl(size_t* bytes_read) { |
408 char* buffer = NULL; | 408 char* buffer = nullptr; |
409 size_t bytes_to_read = 0; | 409 size_t bytes_to_read = 0; |
410 read_buffer()->GetBuffer(&buffer, &bytes_to_read); | 410 read_buffer()->GetBuffer(&buffer, &bytes_to_read); |
411 | 411 |
412 size_t old_num_platform_handles = read_platform_handles_.size(); | 412 size_t old_num_platform_handles = read_platform_handles_.size(); |
413 ssize_t read_result = embedder::PlatformChannelRecvmsg( | 413 ssize_t read_result = embedder::PlatformChannelRecvmsg( |
414 fd_.get(), buffer, bytes_to_read, &read_platform_handles_); | 414 fd_.get(), buffer, bytes_to_read, &read_platform_handles_); |
415 if (read_platform_handles_.size() > old_num_platform_handles) { | 415 if (read_platform_handles_.size() > old_num_platform_handles) { |
416 DCHECK_LE(read_platform_handles_.size() - old_num_platform_handles, | 416 DCHECK_LE(read_platform_handles_.size() - old_num_platform_handles, |
417 embedder::kPlatformChannelMaxNumHandles); | 417 embedder::kPlatformChannelMaxNumHandles); |
418 | 418 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 477 |
478 // Static factory method declared in raw_channel.h. | 478 // Static factory method declared in raw_channel.h. |
479 // static | 479 // static |
480 scoped_ptr<RawChannel> RawChannel::Create( | 480 scoped_ptr<RawChannel> RawChannel::Create( |
481 embedder::ScopedPlatformHandle handle) { | 481 embedder::ScopedPlatformHandle handle) { |
482 return scoped_ptr<RawChannel>(new RawChannelPosix(handle.Pass())); | 482 return scoped_ptr<RawChannel>(new RawChannelPosix(handle.Pass())); |
483 } | 483 } |
484 | 484 |
485 } // namespace system | 485 } // namespace system |
486 } // namespace mojo | 486 } // namespace mojo |
OLD | NEW |