| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 |
| 5 #ifndef NET_FTP_FTP_CTRL_RESPONSE_BUFFER_H_ | 6 #ifndef NET_FTP_FTP_CTRL_RESPONSE_BUFFER_H_ |
| 6 #define NET_FTP_FTP_CTRL_RESPONSE_BUFFER_H_ | 7 #define NET_FTP_FTP_CTRL_RESPONSE_BUFFER_H_ |
| 7 #pragma once | 8 #pragma once |
| 8 | 9 |
| 9 #include <queue> | 10 #include <queue> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 14 | 15 |
| 15 namespace net { | 16 namespace net { |
| 16 | 17 |
| 17 struct FtpCtrlResponse { | 18 struct FtpCtrlResponse { |
| 18 static const int kInvalidStatusCode; | 19 static const int kInvalidStatusCode; |
| 19 | 20 |
| 20 FtpCtrlResponse() : status_code(kInvalidStatusCode) {} | 21 FtpCtrlResponse() : status_code(kInvalidStatusCode) {} |
| 21 | 22 |
| 22 int status_code; // Three-digit status code. | 23 int status_code; // Three-digit status code. |
| 23 std::vector<std::string> lines; // Response lines, without CRLFs. | 24 std::vector<std::string> lines; // Response lines, without CRLFs. |
| 24 }; | 25 }; |
| 25 | 26 |
| 26 class FtpCtrlResponseBuffer { | 27 class FtpCtrlResponseBuffer { |
| 27 public: | 28 public: |
| 28 FtpCtrlResponseBuffer() : multiline_(false) { | 29 FtpCtrlResponseBuffer() : multiline_(false) {} |
| 29 } | |
| 30 | 30 |
| 31 // Called when data is received from the control socket. Returns error code. | 31 // Called when data is received from the control socket. Returns error code. |
| 32 int ConsumeData(const char* data, int data_length); | 32 int ConsumeData(const char* data, int data_length); |
| 33 | 33 |
| 34 bool ResponseAvailable() const { | 34 bool ResponseAvailable() const { |
| 35 return !responses_.empty(); | 35 return !responses_.empty(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Returns the next response. It is an error to call this function | 38 // Returns the next response. It is an error to call this function |
| 39 // unless ResponseAvailable returns true. | 39 // unless ResponseAvailable returns true. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 // As we read full responses (possibly multiline), we add them to the queue. | 97 // As we read full responses (possibly multiline), we add them to the queue. |
| 98 std::queue<FtpCtrlResponse> responses_; | 98 std::queue<FtpCtrlResponse> responses_; |
| 99 | 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(FtpCtrlResponseBuffer); | 100 DISALLOW_COPY_AND_ASSIGN(FtpCtrlResponseBuffer); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace net | 103 } // namespace net |
| 104 | 104 |
| 105 #endif // NET_FTP_FTP_CTRL_RESPONSE_BUFFER_H_ | 105 #endif // NET_FTP_FTP_CTRL_RESPONSE_BUFFER_H_ |
| OLD | NEW |