| 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 "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" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 response_ += std::string(response_buffer->data(), result); | 178 response_ += std::string(response_buffer->data(), result); |
| 179 int expected_length = 0; | 179 int expected_length = 0; |
| 180 if (bytes_total < 0) { | 180 if (bytes_total < 0) { |
| 181 size_t content_pos = response_.find("Content-Length:"); | 181 size_t content_pos = response_.find("Content-Length:"); |
| 182 if (content_pos != std::string::npos) { | 182 if (content_pos != std::string::npos) { |
| 183 size_t endline_pos = response_.find("\n", content_pos); | 183 size_t endline_pos = response_.find("\n", content_pos); |
| 184 if (endline_pos != std::string::npos) { | 184 if (endline_pos != std::string::npos) { |
| 185 std::string len = response_.substr(content_pos + 15, | 185 std::string len = response_.substr(content_pos + 15, |
| 186 endline_pos - content_pos - 15); | 186 endline_pos - content_pos - 15); |
| 187 TrimWhitespace(len, TRIM_ALL, &len); | 187 base::TrimWhitespace(len, base::TRIM_ALL, &len); |
| 188 if (!base::StringToInt(len, &expected_length)) { | 188 if (!base::StringToInt(len, &expected_length)) { |
| 189 CheckNetResultOrDie(net::ERR_FAILED); | 189 CheckNetResultOrDie(net::ERR_FAILED); |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 | 194 |
| 195 body_pos_ = response_.find("\r\n\r\n"); | 195 body_pos_ = response_.find("\r\n\r\n"); |
| 196 if (body_pos_ != std::string::npos) { | 196 if (body_pos_ != std::string::npos) { |
| 197 body_pos_ += 4; | 197 body_pos_ += 4; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 base::Unretained(this), | 480 base::Unretained(this), |
| 481 callback, | 481 callback, |
| 482 new_response, | 482 new_response, |
| 483 response_buffer, | 483 response_buffer, |
| 484 bytes_left)); | 484 bytes_left)); |
| 485 if (result > 0) | 485 if (result > 0) |
| 486 OnResponseData(callback, new_response, response_buffer, bytes_left, result); | 486 OnResponseData(callback, new_response, response_buffer, bytes_left, result); |
| 487 else if (result != net::ERR_IO_PENDING) | 487 else if (result != net::ERR_IO_PENDING) |
| 488 callback.Run(net::OK, new_response); | 488 callback.Run(net::OK, new_response); |
| 489 } | 489 } |
| OLD | NEW |