| OLD | NEW |
| 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/chrome_devtools_manager_delegate.h" | 5 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/devtools/device/android_device_manager.h" | 10 #include "chrome/browser/devtools/device/android_device_manager.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 base::Unretained(this)))); | 237 base::Unretained(this)))); |
| 238 } | 238 } |
| 239 remote_locations_.swap(remote_locations); | 239 remote_locations_.swap(remote_locations); |
| 240 } | 240 } |
| 241 | 241 |
| 242 std::unique_ptr<base::DictionaryValue> | 242 std::unique_ptr<base::DictionaryValue> |
| 243 ChromeDevToolsManagerDelegate::SetRemoteLocations( | 243 ChromeDevToolsManagerDelegate::SetRemoteLocations( |
| 244 content::DevToolsAgentHost* agent_host, | 244 content::DevToolsAgentHost* agent_host, |
| 245 int command_id, | 245 int command_id, |
| 246 base::DictionaryValue* params) { | 246 base::DictionaryValue* params) { |
| 247 if (host_data_.find(agent_host) == host_data_.end()) { | 247 // Could have been created late. |
| 248 return DevToolsProtocol::CreateInvalidParamsResponse( | 248 if (host_data_.find(agent_host) == host_data_.end()) |
| 249 command_id, "Cannot find agent host"); | 249 DevToolsAgentHostAttached(agent_host); |
| 250 } | |
| 251 | 250 |
| 252 std::set<net::HostPortPair> tcp_locations; | 251 std::set<net::HostPortPair> tcp_locations; |
| 253 base::ListValue* locations; | 252 base::ListValue* locations; |
| 254 if (!params->GetList(kLocationsParam, &locations)) | 253 if (!params->GetList(kLocationsParam, &locations)) |
| 255 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, | 254 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, |
| 256 kLocationsParam); | 255 kLocationsParam); |
| 257 for (const auto& item : *locations) { | 256 for (const auto& item : *locations) { |
| 258 if (!item->IsType(base::Value::Type::DICTIONARY)) { | 257 if (!item->IsType(base::Value::Type::DICTIONARY)) { |
| 259 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, | 258 return DevToolsProtocol::CreateInvalidParamsResponse(command_id, |
| 260 kLocationsParam); | 259 kLocationsParam); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 274 tcp_locations.insert(net::HostPortPair(host, port)); | 273 tcp_locations.insert(net::HostPortPair(host, port)); |
| 275 } | 274 } |
| 276 | 275 |
| 277 host_data_[agent_host]->set_remote_locations(tcp_locations); | 276 host_data_[agent_host]->set_remote_locations(tcp_locations); |
| 278 UpdateDeviceDiscovery(); | 277 UpdateDeviceDiscovery(); |
| 279 | 278 |
| 280 std::unique_ptr<base::DictionaryValue> result( | 279 std::unique_ptr<base::DictionaryValue> result( |
| 281 base::MakeUnique<base::DictionaryValue>()); | 280 base::MakeUnique<base::DictionaryValue>()); |
| 282 return DevToolsProtocol::CreateSuccessResponse(command_id, std::move(result)); | 281 return DevToolsProtocol::CreateSuccessResponse(command_id, std::move(result)); |
| 283 } | 282 } |
| OLD | NEW |