| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/ftp/ftp_ctrl_response_buffer.h" | 5 #include "net/ftp/ftp_ctrl_response_buffer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "net/base/parse_number.h" | 11 #include "net/base/parse_number.h" |
| 12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/log/net_log_event_type.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 // static | 19 // static |
| 19 const int FtpCtrlResponse::kInvalidStatusCode = -1; | 20 const int FtpCtrlResponse::kInvalidStatusCode = -1; |
| 20 | 21 |
| 21 FtpCtrlResponse::FtpCtrlResponse() : status_code(kInvalidStatusCode) {} | 22 FtpCtrlResponse::FtpCtrlResponse() : status_code(kInvalidStatusCode) {} |
| 22 | 23 |
| 23 FtpCtrlResponse::FtpCtrlResponse(const FtpCtrlResponse& other) = default; | 24 FtpCtrlResponse::FtpCtrlResponse(const FtpCtrlResponse& other) = default; |
| 24 | 25 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 dict->Set("lines", std::move(lines)); | 95 dict->Set("lines", std::move(lines)); |
| 95 return std::move(dict); | 96 return std::move(dict); |
| 96 } | 97 } |
| 97 | 98 |
| 98 } // namespace | 99 } // namespace |
| 99 | 100 |
| 100 FtpCtrlResponse FtpCtrlResponseBuffer::PopResponse() { | 101 FtpCtrlResponse FtpCtrlResponseBuffer::PopResponse() { |
| 101 FtpCtrlResponse result = responses_.front(); | 102 FtpCtrlResponse result = responses_.front(); |
| 102 responses_.pop(); | 103 responses_.pop(); |
| 103 | 104 |
| 104 net_log_.AddEvent(NetLog::TYPE_FTP_CONTROL_RESPONSE, | 105 net_log_.AddEvent(NetLogEventType::FTP_CONTROL_RESPONSE, |
| 105 base::Bind(&NetLogFtpCtrlResponseCallback, &result)); | 106 base::Bind(&NetLogFtpCtrlResponseCallback, &result)); |
| 106 | 107 |
| 107 return result; | 108 return result; |
| 108 } | 109 } |
| 109 | 110 |
| 110 FtpCtrlResponseBuffer::ParsedLine::ParsedLine() | 111 FtpCtrlResponseBuffer::ParsedLine::ParsedLine() |
| 111 : has_status_code(false), | 112 : has_status_code(false), |
| 112 is_multiline(false), | 113 is_multiline(false), |
| 113 is_complete(false), | 114 is_complete(false), |
| 114 status_code(FtpCtrlResponse::kInvalidStatusCode) { | 115 status_code(FtpCtrlResponse::kInvalidStatusCode) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 for (size_t i = 0; i < buffer_.length(); i++) { | 153 for (size_t i = 0; i < buffer_.length(); i++) { |
| 153 if (i >= 1 && buffer_[i - 1] == '\r' && buffer_[i] == '\n') { | 154 if (i >= 1 && buffer_[i - 1] == '\r' && buffer_[i] == '\n') { |
| 154 lines_.push(ParseLine(buffer_.substr(cut_pos, i - cut_pos - 1))); | 155 lines_.push(ParseLine(buffer_.substr(cut_pos, i - cut_pos - 1))); |
| 155 cut_pos = i + 1; | 156 cut_pos = i + 1; |
| 156 } | 157 } |
| 157 } | 158 } |
| 158 buffer_.erase(0, cut_pos); | 159 buffer_.erase(0, cut_pos); |
| 159 } | 160 } |
| 160 | 161 |
| 161 } // namespace net | 162 } // namespace net |
| OLD | NEW |