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> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
11 #include "base/values.h" | 13 #include "base/values.h" |
12 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
13 | 15 |
14 namespace net { | 16 namespace net { |
15 | 17 |
16 // static | 18 // static |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 namespace { | 82 namespace { |
81 | 83 |
82 scoped_ptr<base::Value> NetLogFtpCtrlResponseCallback( | 84 scoped_ptr<base::Value> NetLogFtpCtrlResponseCallback( |
83 const FtpCtrlResponse* response, | 85 const FtpCtrlResponse* response, |
84 NetLogCaptureMode capture_mode) { | 86 NetLogCaptureMode capture_mode) { |
85 scoped_ptr<base::ListValue> lines(new base::ListValue()); | 87 scoped_ptr<base::ListValue> lines(new base::ListValue()); |
86 lines->AppendStrings(response->lines); | 88 lines->AppendStrings(response->lines); |
87 | 89 |
88 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 90 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
89 dict->SetInteger("status_code", response->status_code); | 91 dict->SetInteger("status_code", response->status_code); |
90 dict->Set("lines", lines.Pass()); | 92 dict->Set("lines", std::move(lines)); |
91 return dict.Pass(); | 93 return std::move(dict); |
92 } | 94 } |
93 | 95 |
94 } // namespace | 96 } // namespace |
95 | 97 |
96 FtpCtrlResponse FtpCtrlResponseBuffer::PopResponse() { | 98 FtpCtrlResponse FtpCtrlResponseBuffer::PopResponse() { |
97 FtpCtrlResponse result = responses_.front(); | 99 FtpCtrlResponse result = responses_.front(); |
98 responses_.pop(); | 100 responses_.pop(); |
99 | 101 |
100 net_log_.AddEvent(NetLog::TYPE_FTP_CONTROL_RESPONSE, | 102 net_log_.AddEvent(NetLog::TYPE_FTP_CONTROL_RESPONSE, |
101 base::Bind(&NetLogFtpCtrlResponseCallback, &result)); | 103 base::Bind(&NetLogFtpCtrlResponseCallback, &result)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 for (size_t i = 0; i < buffer_.length(); i++) { | 146 for (size_t i = 0; i < buffer_.length(); i++) { |
145 if (i >= 1 && buffer_[i - 1] == '\r' && buffer_[i] == '\n') { | 147 if (i >= 1 && buffer_[i - 1] == '\r' && buffer_[i] == '\n') { |
146 lines_.push(ParseLine(buffer_.substr(cut_pos, i - cut_pos - 1))); | 148 lines_.push(ParseLine(buffer_.substr(cut_pos, i - cut_pos - 1))); |
147 cut_pos = i + 1; | 149 cut_pos = i + 1; |
148 } | 150 } |
149 } | 151 } |
150 buffer_.erase(0, cut_pos); | 152 buffer_.erase(0, cut_pos); |
151 } | 153 } |
152 | 154 |
153 } // namespace net | 155 } // namespace net |
OLD | NEW |