OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
sky
2016/01/21 22:59:20
nit: 2016
charliea (OOO until 10-5)
2016/01/22 16:11:03
Done.
| |
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 ""; | |
sky
2016/01/21 22:59:20
nit: std::string()
charliea (OOO until 10-5)
2016/01/22 16:11:03
Done.
| |
37 } | |
38 | |
39 } // namespace battor | |
OLD | NEW |