Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: apps/moterm/moterm_driver.cc

Issue 1321253010: Add a "native_support" service. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fix android? Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | examples/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 client_->OnDataReceived(translated_bytes.data(), 180 client_->OnDataReceived(translated_bytes.data(),
181 static_cast<uint32_t>(translated_bytes.size())); 181 static_cast<uint32_t>(translated_bytes.size()));
182 } 182 }
183 183
184 void MotermDriver::Close(const CloseCallback& callback) { 184 void MotermDriver::Close(const CloseCallback& callback) {
185 if (is_closed_) { 185 if (is_closed_) {
186 callback.Run(mojo::files::ERROR_CLOSED); 186 callback.Run(mojo::files::ERROR_CLOSED);
187 return; 187 return;
188 } 188 }
189 189
190 // TODO(vtl): Call pending read callbacks?
191
190 is_closed_ = true; 192 is_closed_ = true;
191 callback.Run(mojo::files::ERROR_OK); 193 callback.Run(mojo::files::ERROR_OK);
192 194
193 // TODO(vtl): Call pending read callbacks?
194
195 client_->OnClosed(); 195 client_->OnClosed();
196 } 196 }
197 197
198 void MotermDriver::Read(uint32_t num_bytes_to_read, 198 void MotermDriver::Read(uint32_t num_bytes_to_read,
199 int64_t offset, 199 int64_t offset,
200 mojo::files::Whence whence, 200 mojo::files::Whence whence,
201 const ReadCallback& callback) { 201 const ReadCallback& callback) {
202 if (is_closed_) { 202 if (is_closed_) {
203 callback.Run(mojo::files::ERROR_CLOSED, mojo::Array<uint8_t>()); 203 callback.Run(mojo::files::ERROR_CLOSED, mojo::Array<uint8_t>());
204 return; 204 return;
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « no previous file | examples/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698