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/test/chromedriver/net/adb_client_socket.h" | 5 #include "chrome/test/chromedriver/net/adb_client_socket.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 if (!CheckNetResultOrDie(result)) | 264 if (!CheckNetResultOrDie(result)) |
265 return; | 265 return; |
266 std::string query = queries_[current_query_]; | 266 std::string query = queries_[current_query_]; |
267 if (query.length() > 0xFFFF) { | 267 if (query.length() > 0xFFFF) { |
268 CheckNetResultOrDie(net::ERR_MSG_TOO_BIG); | 268 CheckNetResultOrDie(net::ERR_MSG_TOO_BIG); |
269 return; | 269 return; |
270 } | 270 } |
271 bool is_void = current_query_ < queries_.size() - 1; | 271 bool is_void = current_query_ < queries_.size() - 1; |
272 // The |shell| command is a special case because it is the only command that | 272 // The |shell| command is a special case because it is the only command that |
273 // doesn't include a length at the beginning of the data stream. | 273 // doesn't include a length at the beginning of the data stream. |
274 bool has_length = | 274 bool has_length = query.find("shell:") != 0; |
275 !base::StartsWith(query, "shell:", base::CompareCase::SENSITIVE); | |
276 SendCommand(query, is_void, has_length, | 275 SendCommand(query, is_void, has_length, |
277 base::Bind(&AdbQuerySocket::OnResponse, base::Unretained(this))); | 276 base::Bind(&AdbQuerySocket::OnResponse, base::Unretained(this))); |
278 } | 277 } |
279 | 278 |
280 void OnResponse(int result, const std::string& response) { | 279 void OnResponse(int result, const std::string& response) { |
281 if (++current_query_ < queries_.size()) { | 280 if (++current_query_ < queries_.size()) { |
282 SendNextQuery(net::OK); | 281 SendNextQuery(net::OK); |
283 } else { | 282 } else { |
284 callback_.Run(result, response); | 283 callback_.Run(result, response); |
285 delete this; | 284 delete this; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 base::Unretained(this), | 525 base::Unretained(this), |
527 callback, | 526 callback, |
528 new_response, | 527 new_response, |
529 response_buffer, | 528 response_buffer, |
530 bytes_left)); | 529 bytes_left)); |
531 if (result > 0) | 530 if (result > 0) |
532 OnResponseData(callback, new_response, response_buffer, bytes_left, result); | 531 OnResponseData(callback, new_response, response_buffer, bytes_left, result); |
533 else if (result != net::ERR_IO_PENDING) | 532 else if (result != net::ERR_IO_PENDING) |
534 callback.Run(net::OK, new_response); | 533 callback.Run(net::OK, new_response); |
535 } | 534 } |
OLD | NEW |