| 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/device/port_forwarding_controller.h" | 5 #include "chrome/browser/devtools/device/port_forwarding_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 const std::string& host, | 62 const std::string& host, |
| 63 int port) | 63 int port) |
| 64 : remote_socket_(std::move(socket)), | 64 : remote_socket_(std::move(socket)), |
| 65 pending_writes_(0), | 65 pending_writes_(0), |
| 66 pending_destruction_(false) { | 66 pending_destruction_(false) { |
| 67 host_resolver_ = net::HostResolver::CreateDefaultResolver(nullptr); | 67 host_resolver_ = net::HostResolver::CreateDefaultResolver(nullptr); |
| 68 net::HostResolver::RequestInfo request_info(net::HostPortPair(host, port)); | 68 net::HostResolver::RequestInfo request_info(net::HostPortPair(host, port)); |
| 69 int result = host_resolver_->Resolve( | 69 int result = host_resolver_->Resolve( |
| 70 request_info, net::DEFAULT_PRIORITY, &address_list_, | 70 request_info, net::DEFAULT_PRIORITY, &address_list_, |
| 71 base::Bind(&SocketTunnel::OnResolved, base::Unretained(this)), | 71 base::Bind(&SocketTunnel::OnResolved, base::Unretained(this)), |
| 72 &request_, net::BoundNetLog()); | 72 &request_, net::NetLogWithSource()); |
| 73 if (result != net::ERR_IO_PENDING) | 73 if (result != net::ERR_IO_PENDING) |
| 74 OnResolved(result); | 74 OnResolved(result); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void OnResolved(int result) { | 77 void OnResolved(int result) { |
| 78 if (result < 0) { | 78 if (result < 0) { |
| 79 SelfDestruct(); | 79 SelfDestruct(); |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 | 82 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 if (!forwarding_map_.empty()) | 489 if (!forwarding_map_.empty()) |
| 490 UpdateConnections(); | 490 UpdateConnections(); |
| 491 else | 491 else |
| 492 CloseAllConnections(); | 492 CloseAllConnections(); |
| 493 } | 493 } |
| 494 | 494 |
| 495 void PortForwardingController::UpdateConnections() { | 495 void PortForwardingController::UpdateConnections() { |
| 496 for (Registry::iterator it = registry_.begin(); it != registry_.end(); ++it) | 496 for (Registry::iterator it = registry_.begin(); it != registry_.end(); ++it) |
| 497 it->second->UpdateForwardingMap(forwarding_map_); | 497 it->second->UpdateForwardingMap(forwarding_map_); |
| 498 } | 498 } |
| OLD | NEW |