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

Side by Side Diff: extensions/browser/api/serial/serial_connection.cc

Issue 873903002: Set serial connection parameters immediately on connect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a comment explaing the "set" notation. Created 5 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/serial/serial_connection.h" 5 #include "extensions/browser/api/serial/serial_connection.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 send_timeout_ = send_timeout; 232 send_timeout_ = send_timeout;
233 } 233 }
234 234
235 void SerialConnection::set_paused(bool paused) { 235 void SerialConnection::set_paused(bool paused) {
236 paused_ = paused; 236 paused_ = paused;
237 if (paused) { 237 if (paused) {
238 io_handler_->CancelRead(device::serial::RECEIVE_ERROR_NONE); 238 io_handler_->CancelRead(device::serial::RECEIVE_ERROR_NONE);
239 } 239 }
240 } 240 }
241 241
242 void SerialConnection::Open(const OpenCompleteCallback& callback) { 242 void SerialConnection::Open(const core_api::serial::ConnectionOptions& options,
243 const OpenCompleteCallback& callback) {
243 DCHECK_CURRENTLY_ON(BrowserThread::IO); 244 DCHECK_CURRENTLY_ON(BrowserThread::IO);
244 io_handler_->Open(port_, callback); 245 if (options.persistent.get())
246 set_persistent(*options.persistent);
247 if (options.name.get())
248 set_name(*options.name);
249 if (options.buffer_size.get())
250 set_buffer_size(*options.buffer_size);
251 if (options.receive_timeout.get())
252 set_receive_timeout(*options.receive_timeout);
253 if (options.send_timeout.get())
254 set_send_timeout(*options.send_timeout);
255 io_handler_->Open(port_, *device::serial::ConnectionOptions::From(options),
256 callback);
245 } 257 }
246 258
247 bool SerialConnection::Receive(const ReceiveCompleteCallback& callback) { 259 bool SerialConnection::Receive(const ReceiveCompleteCallback& callback) {
248 DCHECK_CURRENTLY_ON(BrowserThread::IO); 260 DCHECK_CURRENTLY_ON(BrowserThread::IO);
249 if (!receive_complete_.is_null()) 261 if (!receive_complete_.is_null())
250 return false; 262 return false;
251 receive_complete_ = callback; 263 receive_complete_ = callback;
252 receive_buffer_ = new net::IOBuffer(buffer_size_); 264 receive_buffer_ = new net::IOBuffer(buffer_size_);
253 io_handler_->Read(scoped_ptr<device::WritableBuffer>(new ReceiveBuffer( 265 io_handler_->Read(scoped_ptr<device::WritableBuffer>(new ReceiveBuffer(
254 receive_buffer_, 266 receive_buffer_,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 output->parity_bit = extensions::ConvertParityBitToMojo(input.parity_bit); 444 output->parity_bit = extensions::ConvertParityBitToMojo(input.parity_bit);
433 output->stop_bits = extensions::ConvertStopBitsToMojo(input.stop_bits); 445 output->stop_bits = extensions::ConvertStopBitsToMojo(input.stop_bits);
434 if (input.cts_flow_control.get()) { 446 if (input.cts_flow_control.get()) {
435 output->has_cts_flow_control = true; 447 output->has_cts_flow_control = true;
436 output->cts_flow_control = *input.cts_flow_control; 448 output->cts_flow_control = *input.cts_flow_control;
437 } 449 }
438 return output.Pass(); 450 return output.Pass();
439 } 451 }
440 452
441 } // namespace mojo 453 } // namespace mojo
OLDNEW
« no previous file with comments | « extensions/browser/api/serial/serial_connection.h ('k') | extensions/renderer/api/serial/serial_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698