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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 accepted_socket_->Send(buffer_->data(), result); | 103 accepted_socket_->Send(buffer_->data(), result); |
104 result = client_socket_->Read( | 104 result = client_socket_->Read( |
105 buffer_.get(), | 105 buffer_.get(), |
106 kBufferSize, | 106 kBufferSize, |
107 base::Bind(&SocketPump::OnClientRead, base::Unretained(this))); | 107 base::Bind(&SocketPump::OnClientRead, base::Unretained(this))); |
108 if (result != net::ERR_IO_PENDING) | 108 if (result != net::ERR_IO_PENDING) |
109 OnClientRead(result); | 109 OnClientRead(result); |
110 } | 110 } |
111 | 111 |
112 void OnClientWrite(int result) { | 112 void OnClientWrite(int result) { |
113 if (result < 0) | 113 if (result < 0) { |
114 SelfDestruct(); | 114 SelfDestruct(); |
| 115 return; |
| 116 } |
115 | 117 |
116 wire_buffer_->set_offset(wire_buffer_->offset() + result); | 118 wire_buffer_->set_offset(wire_buffer_->offset() + result); |
117 | 119 |
118 int remaining = wire_buffer_size_ - wire_buffer_->offset(); | 120 int remaining = wire_buffer_size_ - wire_buffer_->offset(); |
119 if (remaining == 0) { | 121 if (remaining == 0) { |
120 if (pending_destruction_) | 122 if (pending_destruction_) |
121 SelfDestruct(); | 123 SelfDestruct(); |
122 return; | 124 return; |
123 } | 125 } |
124 | 126 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 BoundSockets::iterator it = bound_sockets_.find(port); | 300 BoundSockets::iterator it = bound_sockets_.find(port); |
299 if (it == bound_sockets_.end()) | 301 if (it == bound_sockets_.end()) |
300 return command->InternalErrorResponse("Port is not bound"); | 302 return command->InternalErrorResponse("Port is not bound"); |
301 | 303 |
302 delete it->second; | 304 delete it->second; |
303 bound_sockets_.erase(it); | 305 bound_sockets_.erase(it); |
304 return command->SuccessResponse(NULL); | 306 return command->SuccessResponse(NULL); |
305 } | 307 } |
306 | 308 |
307 } // namespace content | 309 } // namespace content |
OLD | NEW |