| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 } // namespace | 252 } // namespace |
| 253 | 253 |
| 254 class PortForwardingController::Connection | 254 class PortForwardingController::Connection |
| 255 : public AndroidDeviceManager::AndroidWebSocket::Delegate { | 255 : public AndroidDeviceManager::AndroidWebSocket::Delegate { |
| 256 public: | 256 public: |
| 257 Connection(Registry* registry, | 257 Connection(Registry* registry, |
| 258 scoped_refptr<AndroidDeviceManager::Device> device, | 258 scoped_refptr<AndroidDeviceManager::Device> device, |
| 259 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser, | 259 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser, |
| 260 const ForwardingMap& forwarding_map); | 260 const ForwardingMap& forwarding_map); |
| 261 virtual ~Connection(); | 261 ~Connection() override; |
| 262 | 262 |
| 263 const PortStatusMap& GetPortStatusMap(); | 263 const PortStatusMap& GetPortStatusMap(); |
| 264 | 264 |
| 265 void UpdateForwardingMap(const ForwardingMap& new_forwarding_map); | 265 void UpdateForwardingMap(const ForwardingMap& new_forwarding_map); |
| 266 | 266 |
| 267 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser() { | 267 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser() { |
| 268 return browser_; | 268 return browser_; |
| 269 } | 269 } |
| 270 | 270 |
| 271 private: | 271 private: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 287 bool ProcessResponse(const std::string& json); | 287 bool ProcessResponse(const std::string& json); |
| 288 | 288 |
| 289 void ProcessBindResponse(int port, PortStatus status); | 289 void ProcessBindResponse(int port, PortStatus status); |
| 290 void ProcessUnbindResponse(int port, PortStatus status); | 290 void ProcessUnbindResponse(int port, PortStatus status); |
| 291 | 291 |
| 292 static void UpdateSocketCountOnHandlerThread( | 292 static void UpdateSocketCountOnHandlerThread( |
| 293 base::WeakPtr<Connection> weak_connection, int port, int increment); | 293 base::WeakPtr<Connection> weak_connection, int port, int increment); |
| 294 void UpdateSocketCount(int port, int increment); | 294 void UpdateSocketCount(int port, int increment); |
| 295 | 295 |
| 296 // DevToolsAndroidBridge::AndroidWebSocket::Delegate implementation: | 296 // DevToolsAndroidBridge::AndroidWebSocket::Delegate implementation: |
| 297 virtual void OnSocketOpened() override; | 297 void OnSocketOpened() override; |
| 298 virtual void OnFrameRead(const std::string& message) override; | 298 void OnFrameRead(const std::string& message) override; |
| 299 virtual void OnSocketClosed() override; | 299 void OnSocketClosed() override; |
| 300 | 300 |
| 301 PortForwardingController::Registry* registry_; | 301 PortForwardingController::Registry* registry_; |
| 302 scoped_refptr<AndroidDeviceManager::Device> device_; | 302 scoped_refptr<AndroidDeviceManager::Device> device_; |
| 303 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser_; | 303 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser_; |
| 304 scoped_ptr<AndroidDeviceManager::AndroidWebSocket> web_socket_; | 304 scoped_ptr<AndroidDeviceManager::AndroidWebSocket> web_socket_; |
| 305 int command_id_; | 305 int command_id_; |
| 306 bool connected_; | 306 bool connected_; |
| 307 ForwardingMap forwarding_map_; | 307 ForwardingMap forwarding_map_; |
| 308 CommandCallbackMap pending_responses_; | 308 CommandCallbackMap pending_responses_; |
| 309 PortStatusMap port_status_; | 309 PortStatusMap port_status_; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 registry_copy.push_back(it->second); | 588 registry_copy.push_back(it->second); |
| 589 } | 589 } |
| 590 STLDeleteElements(®istry_copy); | 590 STLDeleteElements(®istry_copy); |
| 591 } | 591 } |
| 592 } | 592 } |
| 593 | 593 |
| 594 void PortForwardingController::UpdateConnections() { | 594 void PortForwardingController::UpdateConnections() { |
| 595 for (Registry::iterator it = registry_.begin(); it != registry_.end(); ++it) | 595 for (Registry::iterator it = registry_.begin(); it != registry_.end(); ++it) |
| 596 it->second->UpdateForwardingMap(forwarding_map_); | 596 it->second->UpdateForwardingMap(forwarding_map_); |
| 597 } | 597 } |
| OLD | NEW |