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

Side by Side Diff: chrome/browser/devtools/device/tcp_device_provider.cc

Issue 1715683002: chrome: Use base's ContainsValue helper function instead of std::find (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated as per latest code 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/devtools/device/tcp_device_provider.h" 5 #include "chrome/browser/devtools/device/tcp_device_provider.h"
6 6
7 #include <algorithm>
8 #include <utility> 7 #include <utility>
9 8
10 #include "base/location.h" 9 #include "base/location.h"
11 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
15 #include "chrome/browser/devtools/device/adb/adb_client_socket.h" 15 #include "chrome/browser/devtools/device/adb/adb_client_socket.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/dns/host_resolver.h" 17 #include "net/dns/host_resolver.h"
18 #include "net/socket/tcp_client_socket.h" 18 #include "net/socket/tcp_client_socket.h"
19 19
20 namespace { 20 namespace {
21 21
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 TCPDeviceProvider::TCPDeviceProvider(const HostPortSet& targets) 76 TCPDeviceProvider::TCPDeviceProvider(const HostPortSet& targets)
77 : targets_(targets) { 77 : targets_(targets) {
78 } 78 }
79 79
80 void TCPDeviceProvider::QueryDevices(const SerialsCallback& callback) { 80 void TCPDeviceProvider::QueryDevices(const SerialsCallback& callback) {
81 std::vector<std::string> result; 81 std::vector<std::string> result;
82 for (const net::HostPortPair& target : targets_) { 82 for (const net::HostPortPair& target : targets_) {
83 const std::string& host = target.host(); 83 const std::string& host = target.host();
84 if (std::find(result.begin(), result.end(), host) != result.end()) 84 if (ContainsValue(result, host))
85 continue; 85 continue;
86 result.push_back(host); 86 result.push_back(host);
87 } 87 }
88 callback.Run(result); 88 callback.Run(result);
89 } 89 }
90 90
91 void TCPDeviceProvider::QueryDeviceInfo(const std::string& serial, 91 void TCPDeviceProvider::QueryDeviceInfo(const std::string& serial,
92 const DeviceInfoCallback& callback) { 92 const DeviceInfoCallback& callback) {
93 AndroidDeviceManager::DeviceInfo device_info; 93 AndroidDeviceManager::DeviceInfo device_info;
94 device_info.model = kDeviceModel; 94 device_info.model = kDeviceModel;
(...skipping 30 matching lines...) Expand all
125 release_callback_.Run(); 125 release_callback_.Run();
126 } 126 }
127 127
128 void TCPDeviceProvider::set_release_callback_for_test( 128 void TCPDeviceProvider::set_release_callback_for_test(
129 const base::Closure& callback) { 129 const base::Closure& callback) {
130 release_callback_ = callback; 130 release_callback_ = callback;
131 } 131 }
132 132
133 TCPDeviceProvider::~TCPDeviceProvider() { 133 TCPDeviceProvider::~TCPDeviceProvider() {
134 } 134 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/platform_keys/platform_keys_service.cc ('k') | chrome/browser/extensions/external_provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698