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 = query.find("shell:") != 0; | 274 bool has_length = |
| 275 !base::StartsWith(query, "shell:", base::CompareCase::SENSITIVE); |
275 SendCommand(query, is_void, has_length, | 276 SendCommand(query, is_void, has_length, |
276 base::Bind(&AdbQuerySocket::OnResponse, base::Unretained(this))); | 277 base::Bind(&AdbQuerySocket::OnResponse, base::Unretained(this))); |
277 } | 278 } |
278 | 279 |
279 void OnResponse(int result, const std::string& response) { | 280 void OnResponse(int result, const std::string& response) { |
280 if (++current_query_ < queries_.size()) { | 281 if (++current_query_ < queries_.size()) { |
281 SendNextQuery(net::OK); | 282 SendNextQuery(net::OK); |
282 } else { | 283 } else { |
283 callback_.Run(result, response); | 284 callback_.Run(result, response); |
284 delete this; | 285 delete this; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 base::Unretained(this), | 526 base::Unretained(this), |
526 callback, | 527 callback, |
527 new_response, | 528 new_response, |
528 response_buffer, | 529 response_buffer, |
529 bytes_left)); | 530 bytes_left)); |
530 if (result > 0) | 531 if (result > 0) |
531 OnResponseData(callback, new_response, response_buffer, bytes_left, result); | 532 OnResponseData(callback, new_response, response_buffer, bytes_left, result); |
532 else if (result != net::ERR_IO_PENDING) | 533 else if (result != net::ERR_IO_PENDING) |
533 callback.Run(net::OK, new_response); | 534 callback.Run(net::OK, new_response); |
534 } | 535 } |
OLD | NEW |