| 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/usb/android_usb_socket.h" | 5 #include "chrome/browser/devtools/device/usb/android_usb_socket.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 | 10 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 net::NextProto AndroidUsbSocket::GetNegotiatedProtocol() const { | 228 net::NextProto AndroidUsbSocket::GetNegotiatedProtocol() const { |
| 229 NOTIMPLEMENTED(); | 229 NOTIMPLEMENTED(); |
| 230 return net::kProtoUnknown; | 230 return net::kProtoUnknown; |
| 231 } | 231 } |
| 232 | 232 |
| 233 bool AndroidUsbSocket::GetSSLInfo(net::SSLInfo* ssl_info) { | 233 bool AndroidUsbSocket::GetSSLInfo(net::SSLInfo* ssl_info) { |
| 234 return false; | 234 return false; |
| 235 } | 235 } |
| 236 | 236 |
| 237 void AndroidUsbSocket::GetConnectionAttempts( |
| 238 net::ConnectionAttempts* out) const { |
| 239 out->clear(); |
| 240 } |
| 241 |
| 237 void AndroidUsbSocket::RespondToReader(bool disconnect) { | 242 void AndroidUsbSocket::RespondToReader(bool disconnect) { |
| 238 if (read_callback_.is_null() || (read_buffer_.empty() && !disconnect)) | 243 if (read_callback_.is_null() || (read_buffer_.empty() && !disconnect)) |
| 239 return; | 244 return; |
| 240 size_t bytes_to_copy = | 245 size_t bytes_to_copy = |
| 241 static_cast<size_t>(read_length_) > read_buffer_.length() ? | 246 static_cast<size_t>(read_length_) > read_buffer_.length() ? |
| 242 read_buffer_.length() : static_cast<size_t>(read_length_); | 247 read_buffer_.length() : static_cast<size_t>(read_length_); |
| 243 memcpy(read_io_buffer_->data(), read_buffer_.data(), bytes_to_copy); | 248 memcpy(read_io_buffer_->data(), read_buffer_.data(), bytes_to_copy); |
| 244 if (read_buffer_.length() > bytes_to_copy) | 249 if (read_buffer_.length() > bytes_to_copy) |
| 245 read_buffer_ = read_buffer_.substr(bytes_to_copy); | 250 read_buffer_ = read_buffer_.substr(bytes_to_copy); |
| 246 else | 251 else |
| 247 read_buffer_ = std::string(); | 252 read_buffer_ = std::string(); |
| 248 base::ResetAndReturn(&read_callback_).Run(bytes_to_copy); | 253 base::ResetAndReturn(&read_callback_).Run(bytes_to_copy); |
| 249 } | 254 } |
| 250 | 255 |
| 251 void AndroidUsbSocket::RespondToWriter(int result) { | 256 void AndroidUsbSocket::RespondToWriter(int result) { |
| 252 if (!write_callback_.is_null()) | 257 if (!write_callback_.is_null()) |
| 253 base::ResetAndReturn(&write_callback_).Run(result); | 258 base::ResetAndReturn(&write_callback_).Run(result); |
| 254 } | 259 } |
| OLD | NEW |