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

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

Issue 2607063002: Remove mojo::Array. (Closed)
Patch Set: rebase Created 3 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 "tools/battor_agent/battor_finder.h" 5 #include "tools/battor_agent/battor_finder.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "device/serial/serial.mojom.h" 9 #include "device/serial/serial.mojom.h"
10 #include "device/serial/serial_device_enumerator.h" 10 #include "device/serial/serial_device_enumerator.h"
11 #include "mojo/public/cpp/bindings/array.h"
12 11
13 namespace battor { 12 namespace battor {
14 13
15 namespace { 14 namespace {
16 15
17 // The USB display name prefix that all BattOrs have. 16 // The USB display name prefix that all BattOrs have.
18 const char kBattOrDisplayNamePrefix[] = "BattOr"; 17 const char kBattOrDisplayNamePrefix[] = "BattOr";
19 18
20 // The command line switch used to hard-code a BattOr path. Hard-coding 19 // The command line switch used to hard-code a BattOr path. Hard-coding
21 // this path disables the normal method of finding a BattOr, which is to 20 // this path disables the normal method of finding a BattOr, which is to
22 // search through serial devices for one with a matching display name. 21 // search through serial devices for one with a matching display name.
23 const char kBattOrPathSwitch[] = "battor-path"; 22 const char kBattOrPathSwitch[] = "battor-path";
24 23
25 } // namespace 24 } // namespace
26 25
27 std::string BattOrFinder::FindBattOr() { 26 std::string BattOrFinder::FindBattOr() {
28 std::unique_ptr<device::SerialDeviceEnumerator> serial_device_enumerator = 27 std::unique_ptr<device::SerialDeviceEnumerator> serial_device_enumerator =
29 device::SerialDeviceEnumerator::Create(); 28 device::SerialDeviceEnumerator::Create();
30 29
31 mojo::Array<device::serial::DeviceInfoPtr> devices = 30 std::vector<device::serial::DeviceInfoPtr> devices =
32 serial_device_enumerator->GetDevices(); 31 serial_device_enumerator->GetDevices();
33 32
34 std::string switch_specified_path = 33 std::string switch_specified_path =
35 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 34 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
36 kBattOrPathSwitch); 35 kBattOrPathSwitch);
37 if (switch_specified_path.empty()) { 36 if (switch_specified_path.empty()) {
38 // If we have no switch-specified path, look for a device with the right 37 // If we have no switch-specified path, look for a device with the right
39 // display name. 38 // display name.
40 for (size_t i = 0; i < devices.size(); i++) { 39 for (size_t i = 0; i < devices.size(); i++) {
41 if (!devices[i]->display_name) 40 if (!devices[i]->display_name)
(...skipping 11 matching lines...) Expand all
53 for (size_t i = 0; i < devices.size(); i++) { 52 for (size_t i = 0; i < devices.size(); i++) {
54 if (devices[i]->path == switch_specified_path) 53 if (devices[i]->path == switch_specified_path)
55 return switch_specified_path; 54 return switch_specified_path;
56 } 55 }
57 } 56 }
58 57
59 return std::string(); 58 return std::string();
60 } 59 }
61 60
62 } // namespace battor 61 } // namespace battor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698