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

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

Issue 1869503004: Convert //tools to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, change iwyu fixes for converted directories to include <memory> Created 4 years, 8 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" 11 #include "mojo/public/cpp/bindings/array.h"
12 12
13 namespace battor { 13 namespace battor {
14 14
15 namespace { 15 namespace {
16 16
17 // The USB display name prefix that all BattOrs have. 17 // The USB display name prefix that all BattOrs have.
18 const char kBattOrDisplayNamePrefix[] = "BattOr"; 18 const char kBattOrDisplayNamePrefix[] = "BattOr";
19 19
20 // The command line switch used to hard-code a BattOr path. Hard-coding 20 // 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 21 // 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. 22 // search through serial devices for one with a matching display name.
23 const char kBattOrPathSwitch[] = "battor-path"; 23 const char kBattOrPathSwitch[] = "battor-path";
24 24
25 } // namespace 25 } // namespace
26 26
27 std::string BattOrFinder::FindBattOr() { 27 std::string BattOrFinder::FindBattOr() {
28 scoped_ptr<device::SerialDeviceEnumerator> serial_device_enumerator = 28 std::unique_ptr<device::SerialDeviceEnumerator> serial_device_enumerator =
29 device::SerialDeviceEnumerator::Create(); 29 device::SerialDeviceEnumerator::Create();
30 30
31 mojo::Array<device::serial::DeviceInfoPtr> devices = 31 mojo::Array<device::serial::DeviceInfoPtr> devices =
32 serial_device_enumerator->GetDevices(); 32 serial_device_enumerator->GetDevices();
33 33
34 std::string switch_specified_path = 34 std::string switch_specified_path =
35 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 35 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
36 kBattOrPathSwitch); 36 kBattOrPathSwitch);
37 if (switch_specified_path.empty()) { 37 if (switch_specified_path.empty()) {
38 // If we have no switch-specified path, look for a device with the right 38 // If we have no switch-specified path, look for a device with the right
(...skipping 12 matching lines...) Expand all
51 for (size_t i = 0; i < devices.size(); i++) { 51 for (size_t i = 0; i < devices.size(); i++) {
52 if (devices[i]->path == switch_specified_path) 52 if (devices[i]->path == switch_specified_path)
53 return switch_specified_path; 53 return switch_specified_path;
54 } 54 }
55 } 55 }
56 56
57 return std::string(); 57 return std::string();
58 } 58 }
59 59
60 } // namespace battor 60 } // namespace battor
OLDNEW
« no previous file with comments | « tools/battor_agent/battor_connection_impl_unittest.cc ('k') | tools/clang/plugins/FindBadConstructsConsumer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698