OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/adb_client_socket.h" | 5 #include "chrome/browser/devtools/adb_client_socket.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "net/base/address_list.h" | 12 #include "net/base/address_list.h" |
13 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
16 #include "net/socket/tcp_client_socket.h" | 16 #include "net/socket/tcp_client_socket.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const int kBufferSize = 16 * 1024; | 20 const int kBufferSize = 16 * 1024; |
21 const int kResponseBufferSize = 16; | |
22 const char kOkayResponse[] = "OKAY"; | 21 const char kOkayResponse[] = "OKAY"; |
23 const char kHostTransportCommand[] = "host:transport:%s"; | 22 const char kHostTransportCommand[] = "host:transport:%s"; |
24 const char kLocalhost[] = "127.0.0.1"; | 23 const char kLocalhost[] = "127.0.0.1"; |
25 | 24 |
26 typedef base::Callback<void(int, const std::string&)> CommandCallback; | 25 typedef base::Callback<void(int, const std::string&)> CommandCallback; |
27 typedef base::Callback<void(int, net::StreamSocket*)> SocketCallback; | 26 typedef base::Callback<void(int, net::StreamSocket*)> SocketCallback; |
28 | 27 |
29 std::string EncodeMessage(const std::string& message) { | 28 std::string EncodeMessage(const std::string& message) { |
30 static const char kHexChars[] = "0123456789ABCDEF"; | 29 static const char kHexChars[] = "0123456789ABCDEF"; |
31 | 30 |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 base::Unretained(this), | 453 base::Unretained(this), |
455 callback, | 454 callback, |
456 new_response, | 455 new_response, |
457 response_buffer, | 456 response_buffer, |
458 bytes_left)); | 457 bytes_left)); |
459 if (result > 0) | 458 if (result > 0) |
460 OnResponseData(callback, new_response, response_buffer, bytes_left, result); | 459 OnResponseData(callback, new_response, response_buffer, bytes_left, result); |
461 else if (result != net::ERR_IO_PENDING) | 460 else if (result != net::ERR_IO_PENDING) |
462 callback.Run(net::OK, new_response); | 461 callback.Run(net::OK, new_response); |
463 } | 462 } |
OLD | NEW |