| 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 "content/browser/devtools/tethering_handler.h" | 5 #include "content/browser/devtools/tethering_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 const char kTetheringAccepted[] = "Tethering.accepted"; | 28 const char kTetheringAccepted[] = "Tethering.accepted"; |
| 29 | 29 |
| 30 const char kPortParam[] = "port"; | 30 const char kPortParam[] = "port"; |
| 31 const char kConnectionIdParam[] = "connectionId"; | 31 const char kConnectionIdParam[] = "connectionId"; |
| 32 | 32 |
| 33 const char kLocalhost[] = "127.0.0.1"; | 33 const char kLocalhost[] = "127.0.0.1"; |
| 34 | 34 |
| 35 const int kListenBacklog = 5; | 35 const int kListenBacklog = 5; |
| 36 const int kBufferSize = 16 * 1024; | 36 const int kBufferSize = 16 * 1024; |
| 37 | 37 |
| 38 const int kMinTetheringPort = 5000; | 38 const int kMinTetheringPort = 1024; |
| 39 const int kMaxTetheringPort = 10000; | 39 const int kMaxTetheringPort = 32767; |
| 40 | 40 |
| 41 class SocketPump : public net::StreamListenSocket::Delegate { | 41 class SocketPump : public net::StreamListenSocket::Delegate { |
| 42 public: | 42 public: |
| 43 SocketPump(DevToolsHttpHandlerDelegate* delegate, | 43 SocketPump(DevToolsHttpHandlerDelegate* delegate, |
| 44 net::StreamSocket* client_socket) | 44 net::StreamSocket* client_socket) |
| 45 : client_socket_(client_socket), | 45 : client_socket_(client_socket), |
| 46 delegate_(delegate), | 46 delegate_(delegate), |
| 47 wire_buffer_size_(0), | 47 wire_buffer_size_(0), |
| 48 pending_destruction_(false) { | 48 pending_destruction_(false) { |
| 49 } | 49 } |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 BoundSockets::iterator it = bound_sockets_.find(port); | 300 BoundSockets::iterator it = bound_sockets_.find(port); |
| 301 if (it == bound_sockets_.end()) | 301 if (it == bound_sockets_.end()) |
| 302 return command->InternalErrorResponse("Port is not bound"); | 302 return command->InternalErrorResponse("Port is not bound"); |
| 303 | 303 |
| 304 delete it->second; | 304 delete it->second; |
| 305 bound_sockets_.erase(it); | 305 bound_sockets_.erase(it); |
| 306 return command->SuccessResponse(NULL); | 306 return command->SuccessResponse(NULL); |
| 307 } | 307 } |
| 308 | 308 |
| 309 } // namespace content | 309 } // namespace content |
| OLD | NEW |