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

Side by Side Diff: chrome/test/chromedriver/chrome/device_manager.cc

Issue 2230203002: chrome: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed accidental components/ change Created 4 years, 4 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/test/chromedriver/chrome/device_manager.h" 5 #include "chrome/test/chromedriver/chrome/device_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return status; 176 return status;
177 } 177 }
178 178
179 Status DeviceManager::AcquireSpecificDevice(const std::string& device_serial, 179 Status DeviceManager::AcquireSpecificDevice(const std::string& device_serial,
180 std::unique_ptr<Device>* device) { 180 std::unique_ptr<Device>* device) {
181 std::vector<std::string> devices; 181 std::vector<std::string> devices;
182 Status status = adb_->GetDevices(&devices); 182 Status status = adb_->GetDevices(&devices);
183 if (status.IsError()) 183 if (status.IsError())
184 return status; 184 return status;
185 185
186 if (!ContainsValue(devices, device_serial)) 186 if (!base::ContainsValue(devices, device_serial))
187 return Status(kUnknownError, 187 return Status(kUnknownError,
188 "Device " + device_serial + " is not online"); 188 "Device " + device_serial + " is not online");
189 189
190 base::AutoLock lock(devices_lock_); 190 base::AutoLock lock(devices_lock_);
191 if (IsDeviceLocked(device_serial)) { 191 if (IsDeviceLocked(device_serial)) {
192 status = Status(kUnknownError, 192 status = Status(kUnknownError,
193 "Device " + device_serial + " is already in use"); 193 "Device " + device_serial + " is already in use");
194 } else { 194 } else {
195 device->reset(LockDevice(device_serial)); 195 device->reset(LockDevice(device_serial));
196 status = Status(kOk); 196 status = Status(kOk);
197 } 197 }
198 return status; 198 return status;
199 } 199 }
200 200
201 void DeviceManager::ReleaseDevice(const std::string& device_serial) { 201 void DeviceManager::ReleaseDevice(const std::string& device_serial) {
202 base::AutoLock lock(devices_lock_); 202 base::AutoLock lock(devices_lock_);
203 active_devices_.remove(device_serial); 203 active_devices_.remove(device_serial);
204 } 204 }
205 205
206 Device* DeviceManager::LockDevice(const std::string& device_serial) { 206 Device* DeviceManager::LockDevice(const std::string& device_serial) {
207 active_devices_.push_back(device_serial); 207 active_devices_.push_back(device_serial);
208 return new Device(device_serial, adb_, 208 return new Device(device_serial, adb_,
209 base::Bind(&DeviceManager::ReleaseDevice, base::Unretained(this), 209 base::Bind(&DeviceManager::ReleaseDevice, base::Unretained(this),
210 device_serial)); 210 device_serial));
211 } 211 }
212 212
213 bool DeviceManager::IsDeviceLocked(const std::string& device_serial) { 213 bool DeviceManager::IsDeviceLocked(const std::string& device_serial) {
214 return ContainsValue(active_devices_, device_serial); 214 return base::ContainsValue(active_devices_, device_serial);
215 } 215 }
OLDNEW
« no previous file with comments | « chrome/test/base/ui_test_utils.cc ('k') | chrome/test/chromedriver/chrome/devtools_http_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698