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/edk/system/raw_channel.h" | 5 #include "mojo/edk/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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 std::unique_ptr<MessageInTransit> fd_message(new MessageInTransit( | 136 std::unique_ptr<MessageInTransit> fd_message(new MessageInTransit( |
137 MessageInTransit::Type::RAW_CHANNEL, | 137 MessageInTransit::Type::RAW_CHANNEL, |
138 MessageInTransit::Subtype::RAW_CHANNEL_POSIX_EXTRA_PLATFORM_HANDLES, | 138 MessageInTransit::Subtype::RAW_CHANNEL_POSIX_EXTRA_PLATFORM_HANDLES, |
139 0, nullptr)); | 139 0, nullptr)); |
140 embedder::ScopedPlatformHandleVectorPtr fds( | 140 embedder::ScopedPlatformHandleVectorPtr fds( |
141 new embedder::PlatformHandleVector( | 141 new embedder::PlatformHandleVector( |
142 platform_handles->begin() + i, | 142 platform_handles->begin() + i, |
143 platform_handles->begin() + i + | 143 platform_handles->begin() + i + |
144 embedder::kPlatformChannelMaxNumHandles)); | 144 embedder::kPlatformChannelMaxNumHandles)); |
145 fd_message->SetTransportData(util::MakeUnique<TransportData>( | 145 fd_message->SetTransportData(util::MakeUnique<TransportData>( |
146 fds.Pass(), GetSerializedPlatformHandleSize())); | 146 std::move(fds), GetSerializedPlatformHandleSize())); |
147 RawChannel::EnqueueMessageNoLock(std::move(fd_message)); | 147 RawChannel::EnqueueMessageNoLock(std::move(fd_message)); |
148 } | 148 } |
149 | 149 |
150 // Remove the handles that we "moved" into the other messages. | 150 // Remove the handles that we "moved" into the other messages. |
151 platform_handles->erase(platform_handles->begin(), | 151 platform_handles->erase(platform_handles->begin(), |
152 platform_handles->begin() + i); | 152 platform_handles->begin() + i); |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 RawChannel::EnqueueMessageNoLock(std::move(message)); | 156 RawChannel::EnqueueMessageNoLock(std::move(message)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 return embedder::ScopedPlatformHandleVectorPtr(); | 202 return embedder::ScopedPlatformHandleVectorPtr(); |
203 } | 203 } |
204 | 204 |
205 embedder::ScopedPlatformHandleVectorPtr rv( | 205 embedder::ScopedPlatformHandleVectorPtr rv( |
206 new embedder::PlatformHandleVector(num_platform_handles)); | 206 new embedder::PlatformHandleVector(num_platform_handles)); |
207 rv->assign(read_platform_handles_.begin(), | 207 rv->assign(read_platform_handles_.begin(), |
208 read_platform_handles_.begin() + num_platform_handles); | 208 read_platform_handles_.begin() + num_platform_handles); |
209 read_platform_handles_.erase( | 209 read_platform_handles_.erase( |
210 read_platform_handles_.begin(), | 210 read_platform_handles_.begin(), |
211 read_platform_handles_.begin() + num_platform_handles); | 211 read_platform_handles_.begin() + num_platform_handles); |
212 return rv.Pass(); | 212 return rv; |
213 } | 213 } |
214 | 214 |
215 RawChannel::IOResult RawChannelPosix::WriteNoLock( | 215 RawChannel::IOResult RawChannelPosix::WriteNoLock( |
216 size_t* platform_handles_written, | 216 size_t* platform_handles_written, |
217 size_t* bytes_written) { | 217 size_t* bytes_written) { |
218 write_mutex().AssertHeld(); | 218 write_mutex().AssertHeld(); |
219 | 219 |
220 DCHECK(!pending_write_); | 220 DCHECK(!pending_write_); |
221 | 221 |
222 size_t num_platform_handles = 0; | 222 size_t num_platform_handles = 0; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 | 470 |
471 // Static factory method declared in raw_channel.h. | 471 // Static factory method declared in raw_channel.h. |
472 // static | 472 // static |
473 std::unique_ptr<RawChannel> RawChannel::Create( | 473 std::unique_ptr<RawChannel> RawChannel::Create( |
474 embedder::ScopedPlatformHandle handle) { | 474 embedder::ScopedPlatformHandle handle) { |
475 return util::MakeUnique<RawChannelPosix>(handle.Pass()); | 475 return util::MakeUnique<RawChannelPosix>(handle.Pass()); |
476 } | 476 } |
477 | 477 |
478 } // namespace system | 478 } // namespace system |
479 } // namespace mojo | 479 } // namespace mojo |
OLD | NEW |