| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "apps/moterm/moterm_driver.h" | 5 #include "apps/moterm/moterm_driver.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 HandleOutput(&ch, 1); | 127 HandleOutput(&ch, 1); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void MotermDriver::CompletePendingReads() { | 130 void MotermDriver::CompletePendingReads() { |
| 131 while (send_data_queue_.size() && pending_read_queue_.size()) { | 131 while (send_data_queue_.size() && pending_read_queue_.size()) { |
| 132 PendingRead pending_read = pending_read_queue_.front(); | 132 PendingRead pending_read = pending_read_queue_.front(); |
| 133 pending_read_queue_.pop_front(); | 133 pending_read_queue_.pop_front(); |
| 134 | 134 |
| 135 size_t data_size = std::min(static_cast<size_t>(pending_read.num_bytes), | 135 size_t data_size = std::min(static_cast<size_t>(pending_read.num_bytes), |
| 136 send_data_queue_.size()); | 136 send_data_queue_.size()); |
| 137 mojo::Array<uint8_t> data(data_size); | 137 auto data = mojo::Array<uint8_t>::New(data_size); |
| 138 for (size_t i = 0; i < data_size; i++) { | 138 for (size_t i = 0; i < data_size; i++) { |
| 139 data[i] = send_data_queue_[i]; | 139 data[i] = send_data_queue_[i]; |
| 140 // In canonical mode, each read only gets a single line. | 140 // In canonical mode, each read only gets a single line. |
| 141 if (icanon_ && data[i] == kNL) { | 141 if (icanon_ && data[i] == kNL) { |
| 142 data_size = i + 1; | 142 data_size = i + 1; |
| 143 data.resize(data_size); | 143 data.resize(data_size); |
| 144 break; | 144 break; |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 send_data_queue_.erase(send_data_queue_.begin(), | 147 send_data_queue_.erase(send_data_queue_.begin(), |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 } | 482 } |
| 483 if (1 + kVEOFIdx < in_values.size()) { | 483 if (1 + kVEOFIdx < in_values.size()) { |
| 484 uint32_t value = in_values[1 + kVEOFIdx]; | 484 uint32_t value = in_values[1 + kVEOFIdx]; |
| 485 if (value > std::numeric_limits<uint8_t>::max()) | 485 if (value > std::numeric_limits<uint8_t>::max()) |
| 486 return mojo::files::Error::INVALID_ARGUMENT; | 486 return mojo::files::Error::INVALID_ARGUMENT; |
| 487 veof_ = static_cast<uint8_t>(value); | 487 veof_ = static_cast<uint8_t>(value); |
| 488 } | 488 } |
| 489 | 489 |
| 490 return mojo::files::Error::OK; | 490 return mojo::files::Error::OK; |
| 491 } | 491 } |
| OLD | NEW |