| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "tools/android/forwarder2/device_controller.h" | 5 #include "tools/android/forwarder2/device_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 LOG(ERROR) << "Data Connection command received, but " | 112 LOG(ERROR) << "Data Connection command received, but " |
| 113 << "listener has not been set up yet for port " << port; | 113 << "listener has not been set up yet for port " << port; |
| 114 // After this point it is assumed that, once we close our Adb Data | 114 // After this point it is assumed that, once we close our Adb Data |
| 115 // socket, the Adb forwarder command will propagate the closing of | 115 // socket, the Adb forwarder command will propagate the closing of |
| 116 // sockets all the way to the host side. | 116 // sockets all the way to the host side. |
| 117 break; | 117 break; |
| 118 } | 118 } |
| 119 listener->SetAdbDataSocket(socket.Pass()); | 119 listener->SetAdbDataSocket(socket.Pass()); |
| 120 break; | 120 break; |
| 121 case command::UNLISTEN: | 121 case command::UNLISTEN: |
| 122 LOG(INFO) << "Unmapping port " << port; |
| 122 if (!listener) { | 123 if (!listener) { |
| 124 LOG(ERROR) << "No listener found for port " << port; |
| 123 SendCommand(command::UNLISTEN_ERROR, port, socket.get()); | 125 SendCommand(command::UNLISTEN_ERROR, port, socket.get()); |
| 124 break; | 126 break; |
| 125 } | 127 } |
| 126 listeners_.erase(listener_it); | 128 listeners_.erase(listener_it); |
| 127 SendCommand(command::UNLISTEN_SUCCESS, port, socket.get()); | 129 SendCommand(command::UNLISTEN_SUCCESS, port, socket.get()); |
| 128 break; | 130 break; |
| 129 default: | 131 default: |
| 130 // TODO(felipeg): add a KillAllListeners command. | 132 // TODO(felipeg): add a KillAllListeners command. |
| 131 LOG(ERROR) << "Invalid command received. Port: " << port | 133 LOG(ERROR) << "Invalid command received. Port: " << port |
| 132 << " Command: " << command; | 134 << " Command: " << command; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 145 listener_port); | 147 listener_port); |
| 146 if (listener_it == controller->listeners_.end()) | 148 if (listener_it == controller->listeners_.end()) |
| 147 return; | 149 return; |
| 148 const linked_ptr<DeviceListener> listener = listener_it->second; | 150 const linked_ptr<DeviceListener> listener = listener_it->second; |
| 149 // Note that the listener is removed from the map before it gets destroyed in | 151 // Note that the listener is removed from the map before it gets destroyed in |
| 150 // case its destructor would access the map. | 152 // case its destructor would access the map. |
| 151 controller->listeners_.erase(listener_it); | 153 controller->listeners_.erase(listener_it); |
| 152 } | 154 } |
| 153 | 155 |
| 154 } // namespace forwarder | 156 } // namespace forwarder |
| OLD | NEW |