Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 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 |
| 39 // display name. | 39 // display name. |
| 40 for (size_t i = 0; i < devices.size(); i++) { | 40 for (size_t i = 0; i < devices.size(); i++) { |
| 41 std::string display_name = devices[i]->display_name.get(); | 41 if (!devices[i]->display_name) |
| 42 continue; | |
| 43 auto& display_name = devices[i]->display_name.value(); | |
|
scottmg
2016/11/14 17:22:48
Sorry, I couldn't figure out what type display_nam
yzshen1
2016/11/14 17:27:55
Its type is now base::Optional<std::string>.
Cha
| |
| 42 if (display_name.find(kBattOrDisplayNamePrefix) != std::string::npos) { | 44 if (display_name.find(kBattOrDisplayNamePrefix) != std::string::npos) { |
| 43 LOG(INFO) << "Found BattOr with display name " << display_name | 45 LOG(INFO) << "Found BattOr with display name " << display_name |
| 44 << " at path " << devices[i]->path; | 46 << " at path " << devices[i]->path; |
| 45 return devices[i]->path; | 47 return devices[i]->path; |
| 46 } | 48 } |
| 47 } | 49 } |
| 48 } else { | 50 } else { |
| 49 // If we have a switch-specified path, make sure it actually exists before | 51 // If we have a switch-specified path, make sure it actually exists before |
| 50 // returning it. | 52 // returning it. |
| 51 for (size_t i = 0; i < devices.size(); i++) { | 53 for (size_t i = 0; i < devices.size(); i++) { |
| 52 if (devices[i]->path == switch_specified_path) | 54 if (devices[i]->path == switch_specified_path) |
| 53 return switch_specified_path; | 55 return switch_specified_path; |
| 54 } | 56 } |
| 55 } | 57 } |
| 56 | 58 |
| 57 return std::string(); | 59 return std::string(); |
| 58 } | 60 } |
| 59 | 61 |
| 60 } // namespace battor | 62 } // namespace battor |
| OLD | NEW |