Chromium Code Reviews| Index: chrome/browser/extensions/api/serial/serial_api.cc |
| =================================================================== |
| --- chrome/browser/extensions/api/serial/serial_api.cc (revision 218161) |
| +++ chrome/browser/extensions/api/serial/serial_api.cc (working copy) |
| @@ -12,6 +12,8 @@ |
| using content::BrowserThread; |
| +namespace serial = extensions::api::serial; |
| + |
| namespace extensions { |
| const char kConnectionIdKey[] = "connectionId"; |
| @@ -19,6 +21,9 @@ |
| const char kBytesReadKey[] = "bytesRead"; |
| const char kBytesWrittenKey[] = "bytesWritten"; |
| const char kBitrateKey[] = "bitrate"; |
| +const char kDataBitKey[] = "dataBit"; |
| +const char kParityKey[] = "parityBit"; |
| +const char kStopBitKey[] = "stopBit"; |
| const char kSuccessKey[] = "success"; |
| const char kDcdKey[] = "dcd"; |
| const char kCtsKey[] = "cts"; |
| @@ -83,7 +88,9 @@ |
| // But we'd like to pick something that has a chance of working, and 9600 is a |
| // good balance between popularity and speed. So 9600 it is. |
| SerialOpenFunction::SerialOpenFunction() |
| - : bitrate_(9600) { |
| + : bitrate_(9600), databit_(serial::DATA_BIT_EIGHTBIT), |
| + parity_(serial::PARITY_BIT_NOPARITY), |
| + stopbit_(serial::STOP_BIT_ONESTOPBIT) { |
| } |
| SerialOpenFunction::~SerialOpenFunction() { |
| @@ -99,6 +106,27 @@ |
| scoped_ptr<base::DictionaryValue> options = params_->options->ToValue(); |
| if (options->HasKey(kBitrateKey)) |
| EXTENSION_FUNCTION_VALIDATE(options->GetInteger(kBitrateKey, &bitrate_)); |
| + if (options->HasKey(kDataBitKey)) { |
| + std::string data; |
| + EXTENSION_FUNCTION_VALIDATE(options->GetString(kDataBitKey, &data)); |
|
miket_OOO
2013/08/21 19:43:44
What exactly does E_F_V do here? You've checked th
limasdf
2013/08/24 15:46:24
It seems unnecessary. Removed.
|
| + if (!data.empty()) { |
| + databit_ = serial::ParseDataBit(data); |
|
miket_OOO
2013/08/21 19:43:44
no braces needed around these one-line blocks.
|
| + } |
| + } |
| + if (options->HasKey(kParityKey)) { |
| + std::string parity; |
| + EXTENSION_FUNCTION_VALIDATE(options->GetString(kParityKey, &parity)); |
| + if (!parity.empty()) { |
| + parity_ = serial::ParseParityBit(parity); |
| + } |
| + } |
| + if (options->HasKey(kStopBitKey)) { |
| + std::string stopbit; |
| + EXTENSION_FUNCTION_VALIDATE(options->GetString(kStopBitKey, &stopbit)); |
| + if (!stopbit.empty()) { |
| + stopbit_ = serial::ParseStopBit(stopbit); |
| + } |
| + } |
| } |
| return true; |
| @@ -116,6 +144,9 @@ |
| SerialConnection* serial_connection = CreateSerialConnection( |
| params_->port, |
| bitrate_, |
| + databit_, |
| + parity_, |
| + stopbit_, |
| extension_->id()); |
| CHECK(serial_connection); |
| int id = manager_->Add(serial_connection); |
| @@ -143,8 +174,12 @@ |
| SerialConnection* SerialOpenFunction::CreateSerialConnection( |
| const std::string& port, |
| int bitrate, |
| + serial::DataBit databit, |
| + serial::ParityBit parity, |
| + serial::StopBit stopbit, |
| const std::string& owner_extension_id) { |
| - return new SerialConnection(port, bitrate, owner_extension_id); |
| + return new SerialConnection(port, bitrate, databit, parity, stopbit, |
| + owner_extension_id); |
| } |
| bool SerialOpenFunction::DoesPortExist(const std::string& port) { |