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" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 response_ += std::string(response_buffer->data(), result); | 157 response_ += std::string(response_buffer->data(), result); |
158 int expected_length = 0; | 158 int expected_length = 0; |
159 if (bytes_total < 0) { | 159 if (bytes_total < 0) { |
160 // TODO(kaznacheev): Use net::HttpResponseHeader to parse the header. | 160 // TODO(kaznacheev): Use net::HttpResponseHeader to parse the header. |
161 size_t content_pos = response_.find("Content-Length:"); | 161 size_t content_pos = response_.find("Content-Length:"); |
162 if (content_pos != std::string::npos) { | 162 if (content_pos != std::string::npos) { |
163 size_t endline_pos = response_.find("\n", content_pos); | 163 size_t endline_pos = response_.find("\n", content_pos); |
164 if (endline_pos != std::string::npos) { | 164 if (endline_pos != std::string::npos) { |
165 std::string len = response_.substr(content_pos + 15, | 165 std::string len = response_.substr(content_pos + 15, |
166 endline_pos - content_pos - 15); | 166 endline_pos - content_pos - 15); |
167 TrimWhitespace(len, TRIM_ALL, &len); | 167 base::TrimWhitespace(len, base::TRIM_ALL, &len); |
168 if (!base::StringToInt(len, &expected_length)) { | 168 if (!base::StringToInt(len, &expected_length)) { |
169 CheckNetResultOrDie(net::ERR_FAILED); | 169 CheckNetResultOrDie(net::ERR_FAILED); |
170 return; | 170 return; |
171 } | 171 } |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 body_pos_ = response_.find("\r\n\r\n"); | 175 body_pos_ = response_.find("\r\n\r\n"); |
176 if (body_pos_ != std::string::npos) { | 176 if (body_pos_ != std::string::npos) { |
177 body_pos_ += 4; | 177 body_pos_ += 4; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 base::Unretained(this), | 427 base::Unretained(this), |
428 callback, | 428 callback, |
429 new_response, | 429 new_response, |
430 response_buffer, | 430 response_buffer, |
431 bytes_left)); | 431 bytes_left)); |
432 if (result > 0) | 432 if (result > 0) |
433 OnResponseData(callback, new_response, response_buffer, bytes_left, result); | 433 OnResponseData(callback, new_response, response_buffer, bytes_left, result); |
434 else if (result != net::ERR_IO_PENDING) | 434 else if (result != net::ERR_IO_PENDING) |
435 callback.Run(net::OK, new_response); | 435 callback.Run(net::OK, new_response); |
436 } | 436 } |
OLD | NEW |