| 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(ConnectionAttempts* out) const { |
| 238 out->clear(); |
| 239 } |
| 240 |
| 237 void AndroidUsbSocket::RespondToReader(bool disconnect) { | 241 void AndroidUsbSocket::RespondToReader(bool disconnect) { |
| 238 if (read_callback_.is_null() || (read_buffer_.empty() && !disconnect)) | 242 if (read_callback_.is_null() || (read_buffer_.empty() && !disconnect)) |
| 239 return; | 243 return; |
| 240 size_t bytes_to_copy = | 244 size_t bytes_to_copy = |
| 241 static_cast<size_t>(read_length_) > read_buffer_.length() ? | 245 static_cast<size_t>(read_length_) > read_buffer_.length() ? |
| 242 read_buffer_.length() : static_cast<size_t>(read_length_); | 246 read_buffer_.length() : static_cast<size_t>(read_length_); |
| 243 memcpy(read_io_buffer_->data(), read_buffer_.data(), bytes_to_copy); | 247 memcpy(read_io_buffer_->data(), read_buffer_.data(), bytes_to_copy); |
| 244 if (read_buffer_.length() > bytes_to_copy) | 248 if (read_buffer_.length() > bytes_to_copy) |
| 245 read_buffer_ = read_buffer_.substr(bytes_to_copy); | 249 read_buffer_ = read_buffer_.substr(bytes_to_copy); |
| 246 else | 250 else |
| 247 read_buffer_ = std::string(); | 251 read_buffer_ = std::string(); |
| 248 base::ResetAndReturn(&read_callback_).Run(bytes_to_copy); | 252 base::ResetAndReturn(&read_callback_).Run(bytes_to_copy); |
| 249 } | 253 } |
| 250 | 254 |
| 251 void AndroidUsbSocket::RespondToWriter(int result) { | 255 void AndroidUsbSocket::RespondToWriter(int result) { |
| 252 if (!write_callback_.is_null()) | 256 if (!write_callback_.is_null()) |
| 253 base::ResetAndReturn(&write_callback_).Run(result); | 257 base::ResetAndReturn(&write_callback_).Run(result); |
| 254 } | 258 } |
| OLD | NEW |