| OLD | NEW |
| 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_api.h" | 5 #include "extensions/browser/api/serial/serial_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 SerialConnection* connection = GetSerialConnection(params_->connection_id); | 415 SerialConnection* connection = GetSerialConnection(params_->connection_id); |
| 416 if (!connection) { | 416 if (!connection) { |
| 417 error_ = kErrorSerialConnectionNotFound; | 417 error_ = kErrorSerialConnectionNotFound; |
| 418 return; | 418 return; |
| 419 } | 419 } |
| 420 | 420 |
| 421 bool success = connection->SetControlSignals(params_->signals); | 421 bool success = connection->SetControlSignals(params_->signals); |
| 422 results_ = serial::SetControlSignals::Results::Create(success); | 422 results_ = serial::SetControlSignals::Results::Create(success); |
| 423 } | 423 } |
| 424 | 424 |
| 425 SerialSetBreakFunction::SerialSetBreakFunction() { |
| 426 } |
| 427 |
| 428 SerialSetBreakFunction::~SerialSetBreakFunction() { |
| 429 } |
| 430 |
| 431 bool SerialSetBreakFunction::Prepare() { |
| 432 params_ = serial::SetBreak::Params::Create(*args_); |
| 433 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 434 |
| 435 return true; |
| 436 } |
| 437 |
| 438 void SerialSetBreakFunction::Work() { |
| 439 SerialConnection* connection = GetSerialConnection(params_->connection_id); |
| 440 if (!connection) { |
| 441 error_ = kErrorSerialConnectionNotFound; |
| 442 return; |
| 443 } |
| 444 bool success = connection->SetBreak(); |
| 445 results_ = serial::SetBreak::Results::Create(success); |
| 446 } |
| 447 |
| 448 SerialClearBreakFunction::SerialClearBreakFunction() { |
| 449 } |
| 450 |
| 451 SerialClearBreakFunction::~SerialClearBreakFunction() { |
| 452 } |
| 453 |
| 454 bool SerialClearBreakFunction::Prepare() { |
| 455 params_ = serial::ClearBreak::Params::Create(*args_); |
| 456 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 457 |
| 458 return true; |
| 459 } |
| 460 |
| 461 void SerialClearBreakFunction::Work() { |
| 462 SerialConnection* connection = GetSerialConnection(params_->connection_id); |
| 463 if (!connection) { |
| 464 error_ = kErrorSerialConnectionNotFound; |
| 465 return; |
| 466 } |
| 467 |
| 468 bool success = connection->ClearBreak(); |
| 469 results_ = serial::ClearBreak::Results::Create(success); |
| 470 } |
| 471 |
| 425 } // namespace core_api | 472 } // namespace core_api |
| 426 | 473 |
| 427 } // namespace extensions | 474 } // namespace extensions |
| 428 | 475 |
| 429 namespace mojo { | 476 namespace mojo { |
| 430 | 477 |
| 431 // static | 478 // static |
| 432 linked_ptr<extensions::core_api::serial::DeviceInfo> TypeConverter< | 479 linked_ptr<extensions::core_api::serial::DeviceInfo> TypeConverter< |
| 433 linked_ptr<extensions::core_api::serial::DeviceInfo>, | 480 linked_ptr<extensions::core_api::serial::DeviceInfo>, |
| 434 device::serial::DeviceInfoPtr>::Convert(const device::serial::DeviceInfoPtr& | 481 device::serial::DeviceInfoPtr>::Convert(const device::serial::DeviceInfoPtr& |
| 435 device) { | 482 device) { |
| 436 linked_ptr<extensions::core_api::serial::DeviceInfo> info( | 483 linked_ptr<extensions::core_api::serial::DeviceInfo> info( |
| 437 new extensions::core_api::serial::DeviceInfo); | 484 new extensions::core_api::serial::DeviceInfo); |
| 438 info->path = device->path; | 485 info->path = device->path; |
| 439 if (device->has_vendor_id) | 486 if (device->has_vendor_id) |
| 440 info->vendor_id.reset(new int(static_cast<int>(device->vendor_id))); | 487 info->vendor_id.reset(new int(static_cast<int>(device->vendor_id))); |
| 441 if (device->has_product_id) | 488 if (device->has_product_id) |
| 442 info->product_id.reset(new int(static_cast<int>(device->product_id))); | 489 info->product_id.reset(new int(static_cast<int>(device->product_id))); |
| 443 if (device->display_name) | 490 if (device->display_name) |
| 444 info->display_name.reset(new std::string(device->display_name)); | 491 info->display_name.reset(new std::string(device->display_name)); |
| 445 return info; | 492 return info; |
| 446 } | 493 } |
| 447 | 494 |
| 448 } // namespace mojo | 495 } // namespace mojo |
| OLD | NEW |