OLD | NEW |
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 return status; | 114 return status; |
115 } | 115 } |
116 | 116 |
117 Status Device::ForwardDevtoolsPort(const std::string& package, | 117 Status Device::ForwardDevtoolsPort(const std::string& package, |
118 const std::string& process, | 118 const std::string& process, |
119 int port, | 119 int port, |
120 std::string* device_socket) { | 120 std::string* device_socket) { |
121 if (device_socket->empty()) { | 121 if (device_socket->empty()) { |
122 // Assume this is a WebView app. | 122 // Assume this is a WebView app. |
123 int pid; | 123 Status status = adb_->GetDevtoolsRemoteSocket(serial_, |
124 Status status = adb_->GetPidByName(serial_, | 124 process.empty() ? package : |
125 process.empty() ? package : process, | 125 process, device_socket); |
126 &pid); | |
127 if (status.IsError()) { | 126 if (status.IsError()) { |
128 if (process.empty()) | 127 if (process.empty()) |
129 status.AddDetails( | 128 status.AddDetails( |
130 "process name must be specified if not equal to package name"); | 129 "process name must be specified if not equal to package name"); |
131 return status; | 130 return status; |
132 } | 131 } |
133 *device_socket = base::StringPrintf("webview_devtools_remote_%d", pid); | |
134 } | 132 } |
135 | 133 |
136 return adb_->ForwardPort(serial_, port, *device_socket); | 134 return adb_->ForwardPort(serial_, port, *device_socket); |
137 } | 135 } |
138 | 136 |
139 Status Device::TearDown() { | 137 Status Device::TearDown() { |
140 if (!active_package_.empty()) { | 138 if (!active_package_.empty()) { |
141 std::string response; | 139 std::string response; |
142 Status status = adb_->ForceStop(serial_, active_package_); | 140 Status status = adb_->ForceStop(serial_, active_package_); |
143 if (status.IsError()) | 141 if (status.IsError()) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 Device* DeviceManager::LockDevice(const std::string& device_serial) { | 204 Device* DeviceManager::LockDevice(const std::string& device_serial) { |
207 active_devices_.push_back(device_serial); | 205 active_devices_.push_back(device_serial); |
208 return new Device(device_serial, adb_, | 206 return new Device(device_serial, adb_, |
209 base::Bind(&DeviceManager::ReleaseDevice, base::Unretained(this), | 207 base::Bind(&DeviceManager::ReleaseDevice, base::Unretained(this), |
210 device_serial)); | 208 device_serial)); |
211 } | 209 } |
212 | 210 |
213 bool DeviceManager::IsDeviceLocked(const std::string& device_serial) { | 211 bool DeviceManager::IsDeviceLocked(const std::string& device_serial) { |
214 return base::ContainsValue(active_devices_, device_serial); | 212 return base::ContainsValue(active_devices_, device_serial); |
215 } | 213 } |
OLD | NEW |