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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 414 |
415 std::string location = it->second; | 415 std::string location = it->second; |
416 std::vector<std::string> tokens = base::SplitString( | 416 std::vector<std::string> tokens = base::SplitString( |
417 location, ":", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 417 location, ":", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
418 int destination_port = 0; | 418 int destination_port = 0; |
419 if (tokens.size() != 2 || !base::StringToInt(tokens[1], &destination_port)) | 419 if (tokens.size() != 2 || !base::StringToInt(tokens[1], &destination_port)) |
420 return; | 420 return; |
421 std::string destination_host = tokens[0]; | 421 std::string destination_host = tokens[0]; |
422 | 422 |
423 device_->OpenSocket( | 423 device_->OpenSocket( |
424 connection_id.c_str(), | 424 connection_id, |
425 base::Bind(&SocketTunnel::StartTunnel, | 425 base::Bind(&SocketTunnel::StartTunnel, |
426 destination_host, | 426 destination_host, |
427 destination_port)); | 427 destination_port)); |
428 } | 428 } |
429 | 429 |
430 PortForwardingController::PortForwardingController(Profile* profile) | 430 PortForwardingController::PortForwardingController(Profile* profile) |
431 : pref_service_(profile->GetPrefs()) { | 431 : pref_service_(profile->GetPrefs()) { |
432 pref_change_registrar_.Init(pref_service_); | 432 pref_change_registrar_.Init(pref_service_); |
433 base::Closure callback = base::Bind( | 433 base::Closure callback = base::Bind( |
434 &PortForwardingController::OnPrefsChange, base::Unretained(this)); | 434 &PortForwardingController::OnPrefsChange, base::Unretained(this)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 if (!forwarding_map_.empty()) | 491 if (!forwarding_map_.empty()) |
492 UpdateConnections(); | 492 UpdateConnections(); |
493 else | 493 else |
494 CloseAllConnections(); | 494 CloseAllConnections(); |
495 } | 495 } |
496 | 496 |
497 void PortForwardingController::UpdateConnections() { | 497 void PortForwardingController::UpdateConnections() { |
498 for (Registry::iterator it = registry_.begin(); it != registry_.end(); ++it) | 498 for (Registry::iterator it = registry_.begin(); it != registry_.end(); ++it) |
499 it->second->UpdateForwardingMap(forwarding_map_); | 499 it->second->UpdateForwardingMap(forwarding_map_); |
500 } | 500 } |
OLD | NEW |