| 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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/threading/non_thread_safe.h" | |
| 19 #include "chrome/browser/devtools/devtools_protocol.h" | 18 #include "chrome/browser/devtools/devtools_protocol.h" |
| 20 #include "chrome/browser/devtools/devtools_protocol_constants.h" | 19 #include "chrome/browser/devtools/devtools_protocol_constants.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 23 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 22 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 24 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
| 25 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 26 #include "net/base/address_list.h" | 25 #include "net/base/address_list.h" |
| 27 #include "net/base/io_buffer.h" | 26 #include "net/base/io_buffer.h" |
| 28 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 42 kStatusError = -3, | 41 kStatusError = -3, |
| 43 kStatusDisconnecting = -2, | 42 kStatusDisconnecting = -2, |
| 44 kStatusConnecting = -1, | 43 kStatusConnecting = -1, |
| 45 kStatusOK = 0, | 44 kStatusOK = 0, |
| 46 }; | 45 }; |
| 47 | 46 |
| 48 namespace tethering = ::chrome::devtools::Tethering; | 47 namespace tethering = ::chrome::devtools::Tethering; |
| 49 | 48 |
| 50 static const char kDevToolsRemoteBrowserTarget[] = "/devtools/browser"; | 49 static const char kDevToolsRemoteBrowserTarget[] = "/devtools/browser"; |
| 51 | 50 |
| 52 class SocketTunnel : public base::NonThreadSafe { | 51 class SocketTunnel { |
| 53 public: | 52 public: |
| 54 static void StartTunnel(const std::string& host, | 53 static void StartTunnel(const std::string& host, |
| 55 int port, | 54 int port, |
| 56 int result, | 55 int result, |
| 57 std::unique_ptr<net::StreamSocket> socket) { | 56 std::unique_ptr<net::StreamSocket> socket) { |
| 58 if (result == net::OK) | 57 if (result == net::OK) |
| 59 new SocketTunnel(std::move(socket), host, port); | 58 new SocketTunnel(std::move(socket), host, port); |
| 60 } | 59 } |
| 61 | 60 |
| 62 private: | 61 private: |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 if (!forwarding_map_.empty()) | 490 if (!forwarding_map_.empty()) |
| 492 UpdateConnections(); | 491 UpdateConnections(); |
| 493 else | 492 else |
| 494 CloseAllConnections(); | 493 CloseAllConnections(); |
| 495 } | 494 } |
| 496 | 495 |
| 497 void PortForwardingController::UpdateConnections() { | 496 void PortForwardingController::UpdateConnections() { |
| 498 for (Registry::iterator it = registry_.begin(); it != registry_.end(); ++it) | 497 for (Registry::iterator it = registry_.begin(); it != registry_.end(); ++it) |
| 499 it->second->UpdateForwardingMap(forwarding_map_); | 498 it->second->UpdateForwardingMap(forwarding_map_); |
| 500 } | 499 } |
| OLD | NEW |