| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_BUFFER_H_ | 5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_BUFFER_H_ |
| 6 #define NET_FTP_FTP_DIRECTORY_LISTING_BUFFER_H_ | 6 #define NET_FTP_FTP_DIRECTORY_LISTING_BUFFER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <deque> | 9 #include <deque> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 // Returns recognized server type. It is valid to call this function at any | 45 // Returns recognized server type. It is valid to call this function at any |
| 46 // time, although it will return SERVER_UNKNOWN if it doesn't know the answer. | 46 // time, although it will return SERVER_UNKNOWN if it doesn't know the answer. |
| 47 FtpServerType GetServerType() const; | 47 FtpServerType GetServerType() const; |
| 48 | 48 |
| 49 const std::string& encoding() const { return encoding_; } | 49 const std::string& encoding() const { return encoding_; } |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 typedef std::set<FtpDirectoryListingParser*> ParserSet; | 52 typedef std::set<FtpDirectoryListingParser*> ParserSet; |
| 53 | 53 |
| 54 // Converts the string |from| to detected encoding and stores it in |to|. | 54 // Converts the raw buffer to UTF-16. Returns network error code. |
| 55 // Returns true on success. | 55 int ConvertBufferToUTF16(); |
| 56 bool ConvertToDetectedEncoding(const std::string& from, string16* to); | |
| 57 | 56 |
| 58 // Tries to extract full lines from the raw buffer, converting them to the | 57 // Extracts lines from the converted buffer, and puts them in |lines_|. |
| 59 // detected encoding. Returns network error code. | 58 void ExtractFullLinesFromBuffer(); |
| 60 int ExtractFullLinesFromBuffer(); | 59 |
| 60 // Consumes the raw buffer (i.e. does the character set conversion |
| 61 // and line splitting). Returns network error code. |
| 62 int ConsumeBuffer(); |
| 61 | 63 |
| 62 // Tries to parse full lines stored in |lines_|. Returns network error code. | 64 // Tries to parse full lines stored in |lines_|. Returns network error code. |
| 63 int ParseLines(); | 65 int ParseLines(); |
| 64 | 66 |
| 65 // Called when we received the entire input. Propagates that info to remaining | 67 // Called when we received the entire input. Propagates that info to remaining |
| 66 // parsers. Returns network error code. | 68 // parsers. Returns network error code. |
| 67 int OnEndOfInput(); | 69 int OnEndOfInput(); |
| 68 | 70 |
| 69 // Detected encoding of the response (empty if unknown or ASCII). | 71 // Detected encoding of the response (empty if unknown). |
| 70 std::string encoding_; | 72 std::string encoding_; |
| 71 | 73 |
| 72 // Buffer to keep not-yet-split data. | 74 // Buffer to keep data before character set conversion. |
| 73 std::string buffer_; | 75 std::string buffer_; |
| 74 | 76 |
| 77 // Buffer to keep data before line splitting. |
| 78 string16 converted_buffer_; |
| 79 |
| 75 // CRLF-delimited lines, without the CRLF, not yet consumed by parser. | 80 // CRLF-delimited lines, without the CRLF, not yet consumed by parser. |
| 76 std::deque<string16> lines_; | 81 std::deque<string16> lines_; |
| 77 | 82 |
| 78 // A collection of parsers for different listing styles. The parsers are owned | 83 // A collection of parsers for different listing styles. The parsers are owned |
| 79 // by this FtpDirectoryListingBuffer. | 84 // by this FtpDirectoryListingBuffer. |
| 80 ParserSet parsers_; | 85 ParserSet parsers_; |
| 81 | 86 |
| 82 // When we're sure about the listing format, its parser is stored in | 87 // When we're sure about the listing format, its parser is stored in |
| 83 // |current_parser_|. | 88 // |current_parser_|. |
| 84 FtpDirectoryListingParser* current_parser_; | 89 FtpDirectoryListingParser* current_parser_; |
| 85 | 90 |
| 86 DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingBuffer); | 91 DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingBuffer); |
| 87 }; | 92 }; |
| 88 | 93 |
| 89 } // namespace net | 94 } // namespace net |
| 90 | 95 |
| 91 #endif // NET_FTP_FTP_DIRECTORY_LISTING_BUFFER_H_ | 96 #endif // NET_FTP_FTP_DIRECTORY_LISTING_BUFFER_H_ |
| OLD | NEW |