| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/channel.h" | 5 #include "mojo/edk/system/channel.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sys/uio.h> | 8 #include <sys/uio.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 if (write_error) { | 127 if (write_error) { |
| 128 // Do not synchronously invoke OnError(). Write() may have been called by | 128 // Do not synchronously invoke OnError(). Write() may have been called by |
| 129 // the delegate and we don't want to re-enter it. | 129 // the delegate and we don't want to re-enter it. |
| 130 io_task_runner_->PostTask(FROM_HERE, | 130 io_task_runner_->PostTask(FROM_HERE, |
| 131 base::Bind(&ChannelPosix::OnError, this)); | 131 base::Bind(&ChannelPosix::OnError, this)); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 ScopedPlatformHandleVectorPtr GetReadPlatformHandles( | 135 ScopedPlatformHandleVectorPtr GetReadPlatformHandles( |
| 136 size_t num_handles, | 136 size_t num_handles, |
| 137 void** payload, | 137 const void* extra_header, |
| 138 size_t* payload_size) override { | 138 size_t extra_header_size) override { |
| 139 if (incoming_platform_handles_.size() < num_handles) | 139 if (incoming_platform_handles_.size() < num_handles) |
| 140 return nullptr; | 140 return nullptr; |
| 141 |
| 141 ScopedPlatformHandleVectorPtr handles( | 142 ScopedPlatformHandleVectorPtr handles( |
| 142 new PlatformHandleVector(num_handles)); | 143 new PlatformHandleVector(num_handles)); |
| 143 for (size_t i = 0; i < num_handles; ++i) { | 144 for (size_t i = 0; i < num_handles; ++i) { |
| 144 (*handles)[i] = incoming_platform_handles_.front(); | 145 (*handles)[i] = incoming_platform_handles_.front(); |
| 145 incoming_platform_handles_.pop_front(); | 146 incoming_platform_handles_.pop_front(); |
| 146 } | 147 } |
| 148 |
| 147 return handles; | 149 return handles; |
| 148 } | 150 } |
| 149 | 151 |
| 150 private: | 152 private: |
| 151 ~ChannelPosix() override { | 153 ~ChannelPosix() override { |
| 152 DCHECK(!read_watcher_); | 154 DCHECK(!read_watcher_); |
| 153 DCHECK(!write_watcher_); | 155 DCHECK(!write_watcher_); |
| 154 for (auto handle : incoming_platform_handles_) | 156 for (auto handle : incoming_platform_handles_) |
| 155 handle.CloseIfNecessary(); | 157 handle.CloseIfNecessary(); |
| 156 } | 158 } |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 // static | 450 // static |
| 449 scoped_refptr<Channel> Channel::Create( | 451 scoped_refptr<Channel> Channel::Create( |
| 450 Delegate* delegate, | 452 Delegate* delegate, |
| 451 ScopedPlatformHandle platform_handle, | 453 ScopedPlatformHandle platform_handle, |
| 452 scoped_refptr<base::TaskRunner> io_task_runner) { | 454 scoped_refptr<base::TaskRunner> io_task_runner) { |
| 453 return new ChannelPosix(delegate, std::move(platform_handle), io_task_runner); | 455 return new ChannelPosix(delegate, std::move(platform_handle), io_task_runner); |
| 454 } | 456 } |
| 455 | 457 |
| 456 } // namespace edk | 458 } // namespace edk |
| 457 } // namespace mojo | 459 } // namespace mojo |
| OLD | NEW |