Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: tools/battor_agent/battor_finder.cc

Issue 1611533002: tools/battor_agent: Adds a tool to find connected BattOrs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW
« tools/battor_agent/battor_finder.h ('K') | « tools/battor_agent/battor_finder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698