| OLD | NEW |
| 1 // Copyright (c) 2010 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 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSER_LS_H_ | 5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSER_LS_H_ |
| 6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSER_LS_H_ | 6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSER_LS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <queue> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/time.h" | 11 #include "base/string16.h" |
| 12 #include "net/ftp/ftp_directory_listing_parser.h" | 12 |
| 13 namespace base { |
| 14 class Time; |
| 15 } |
| 13 | 16 |
| 14 namespace net { | 17 namespace net { |
| 15 | 18 |
| 16 // Parser for "ls -l"-style directory listing. | 19 struct FtpDirectoryListingEntry; |
| 17 class FtpDirectoryListingParserLs : public FtpDirectoryListingParser { | |
| 18 public: | |
| 19 // Constructor. When the current time is needed to guess the year on partial | |
| 20 // date strings, |current_time| will be used. This allows passing a specific | |
| 21 // date during testing. | |
| 22 explicit FtpDirectoryListingParserLs(const base::Time& current_time); | |
| 23 virtual ~FtpDirectoryListingParserLs(); | |
| 24 | 20 |
| 25 // FtpDirectoryListingParser methods: | 21 // Parses "ls -l" FTP directory listing. Returns true on success. |
| 26 virtual FtpServerType GetServerType() const; | 22 bool ParseFtpDirectoryListingLs(const std::vector<string16>& lines, |
| 27 virtual bool ConsumeLine(const string16& line); | 23 const base::Time& current_time, |
| 28 virtual bool OnEndOfInput(); | 24 std::vector<FtpDirectoryListingEntry>* entries); |
| 29 virtual bool EntryAvailable() const; | |
| 30 virtual FtpDirectoryListingEntry PopEntry(); | |
| 31 | |
| 32 private: | |
| 33 // True after we have received a "total n" listing header, where n is an | |
| 34 // integer. Only one such header is allowed per listing. | |
| 35 bool received_total_line_; | |
| 36 | |
| 37 // Store the current time. We need it to correctly parse received dates. | |
| 38 const base::Time current_time_; | |
| 39 | |
| 40 std::queue<FtpDirectoryListingEntry> entries_; | |
| 41 | |
| 42 DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingParserLs); | |
| 43 }; | |
| 44 | 25 |
| 45 } // namespace net | 26 } // namespace net |
| 46 | 27 |
| 47 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_LS_H_ | 28 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_LS_H_ |
| OLD | NEW |