| 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" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "device/serial/serial_device_enumerator.h" | 12 #include "device/serial/serial_device_enumerator.h" |
| 13 #include "extensions/browser/api/serial/serial_connection.h" | 13 #include "extensions/browser/api/serial/serial_connection.h" |
| 14 #include "extensions/browser/api/serial/serial_event_dispatcher.h" | 14 #include "extensions/browser/api/serial/serial_event_dispatcher.h" |
| 15 #include "extensions/common/api/serial.h" | 15 #include "extensions/common/api/serial.h" |
| 16 | 16 |
| 17 using content::BrowserThread; | 17 using content::BrowserThread; |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 | 20 |
| 21 namespace core_api { | 21 namespace api { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // It's a fool's errand to come up with a default bitrate, because we don't get | 25 // It's a fool's errand to come up with a default bitrate, because we don't get |
| 26 // to control both sides of the communication. Unless the other side has | 26 // to control both sides of the communication. Unless the other side has |
| 27 // implemented auto-bitrate detection (rare), if we pick the wrong rate, then | 27 // implemented auto-bitrate detection (rare), if we pick the wrong rate, then |
| 28 // you're gonna have a bad time. Close doesn't count. | 28 // you're gonna have a bad time. Close doesn't count. |
| 29 // | 29 // |
| 30 // But we'd like to pick something that has a chance of working, and 9600 is a | 30 // But we'd like to pick something that has a chance of working, and 9600 is a |
| 31 // good balance between popularity and speed. So 9600 it is. | 31 // good balance between popularity and speed. So 9600 it is. |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 SerialConnection* connection = GetSerialConnection(params_->connection_id); | 462 SerialConnection* connection = GetSerialConnection(params_->connection_id); |
| 463 if (!connection) { | 463 if (!connection) { |
| 464 error_ = kErrorSerialConnectionNotFound; | 464 error_ = kErrorSerialConnectionNotFound; |
| 465 return; | 465 return; |
| 466 } | 466 } |
| 467 | 467 |
| 468 bool success = connection->ClearBreak(); | 468 bool success = connection->ClearBreak(); |
| 469 results_ = serial::ClearBreak::Results::Create(success); | 469 results_ = serial::ClearBreak::Results::Create(success); |
| 470 } | 470 } |
| 471 | 471 |
| 472 } // namespace core_api | 472 } // namespace api |
| 473 | 473 |
| 474 } // namespace extensions | 474 } // namespace extensions |
| 475 | 475 |
| 476 namespace mojo { | 476 namespace mojo { |
| 477 | 477 |
| 478 // static | 478 // static |
| 479 linked_ptr<extensions::core_api::serial::DeviceInfo> TypeConverter< | 479 linked_ptr<extensions::api::serial::DeviceInfo> TypeConverter< |
| 480 linked_ptr<extensions::core_api::serial::DeviceInfo>, | 480 linked_ptr<extensions::api::serial::DeviceInfo>, |
| 481 device::serial::DeviceInfoPtr>::Convert(const device::serial::DeviceInfoPtr& | 481 device::serial::DeviceInfoPtr>::Convert(const device::serial::DeviceInfoPtr& |
| 482 device) { | 482 device) { |
| 483 linked_ptr<extensions::core_api::serial::DeviceInfo> info( | 483 linked_ptr<extensions::api::serial::DeviceInfo> info( |
| 484 new extensions::core_api::serial::DeviceInfo); | 484 new extensions::api::serial::DeviceInfo); |
| 485 info->path = device->path; | 485 info->path = device->path; |
| 486 if (device->has_vendor_id) | 486 if (device->has_vendor_id) |
| 487 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))); |
| 488 if (device->has_product_id) | 488 if (device->has_product_id) |
| 489 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))); |
| 490 if (device->display_name) | 490 if (device->display_name) |
| 491 info->display_name.reset(new std::string(device->display_name)); | 491 info->display_name.reset(new std::string(device->display_name)); |
| 492 return info; | 492 return info; |
| 493 } | 493 } |
| 494 | 494 |
| 495 } // namespace mojo | 495 } // namespace mojo |
| OLD | NEW |