OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "tools/battor_agent/battor_finder.h" |
| 6 |
| 7 #include "device/serial/serial.mojom.h" |
| 8 #include "device/serial/serial_device_enumerator.h" |
| 9 #include "mojo/public/cpp/bindings/array.h" |
| 10 |
| 11 namespace battor { |
| 12 |
| 13 namespace { |
| 14 |
| 15 // The USB display name prefix that all BattOrs have. |
| 16 const char kBattOrDisplayNamePrefix[] = "BattOr"; |
| 17 |
| 18 } // namespace |
| 19 |
| 20 // Returns the path of the first BattOr that we find. |
| 21 std::string BattOrFinder::FindBattOr() { |
| 22 scoped_ptr<device::SerialDeviceEnumerator> serial_device_enumerator = |
| 23 device::SerialDeviceEnumerator::Create(); |
| 24 |
| 25 mojo::Array<device::serial::DeviceInfoPtr> devices = |
| 26 serial_device_enumerator->GetDevices(); |
| 27 |
| 28 for (size_t i = 0; i < devices.size(); i++) { |
| 29 std::string display_name = devices[i]->display_name.get(); |
| 30 |
| 31 if (display_name.find(kBattOrDisplayNamePrefix) != std::string::npos) { |
| 32 return devices[i]->path; |
| 33 } |
| 34 } |
| 35 |
| 36 return std::string(); |
| 37 } |
| 38 |
| 39 } // namespace battor |
OLD | NEW |