| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // 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 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/time.h" |
| 10 #include "net/ftp/ftp_directory_listing_parser.h" | 11 #include "net/ftp/ftp_directory_listing_parser.h" |
| 11 | 12 |
| 12 namespace net { | 13 namespace net { |
| 13 | 14 |
| 14 // Parser for "ls -l"-style directory listing. | 15 // Parser for "ls -l"-style directory listing. |
| 15 class FtpDirectoryListingParserLs : public FtpDirectoryListingParser { | 16 class FtpDirectoryListingParserLs : public FtpDirectoryListingParser { |
| 16 public: | 17 public: |
| 17 FtpDirectoryListingParserLs(); | 18 // Constructor. When the current time is needed to guess the year on partial |
| 19 // date strings, |current_time| will be used. This allows passing a specific |
| 20 // date during testing. |
| 21 explicit FtpDirectoryListingParserLs(const base::Time& current_time); |
| 18 | 22 |
| 19 // FtpDirectoryListingParser methods: | 23 // FtpDirectoryListingParser methods: |
| 20 virtual FtpServerType GetServerType() const { return SERVER_LS; } | 24 virtual FtpServerType GetServerType() const { return SERVER_LS; } |
| 21 virtual bool ConsumeLine(const string16& line); | 25 virtual bool ConsumeLine(const string16& line); |
| 22 virtual bool OnEndOfInput(); | 26 virtual bool OnEndOfInput(); |
| 23 virtual bool EntryAvailable() const; | 27 virtual bool EntryAvailable() const; |
| 24 virtual FtpDirectoryListingEntry PopEntry(); | 28 virtual FtpDirectoryListingEntry PopEntry(); |
| 25 | 29 |
| 26 private: | 30 private: |
| 27 bool received_nonempty_line_; | 31 bool received_nonempty_line_; |
| 28 | 32 |
| 29 // True after we have received a "total n" listing header, where n is an | 33 // True after we have received a "total n" listing header, where n is an |
| 30 // integer. Only one such header is allowed per listing. | 34 // integer. Only one such header is allowed per listing. |
| 31 bool received_total_line_; | 35 bool received_total_line_; |
| 32 | 36 |
| 37 // Store the current time. We need it to correctly parse received dates. |
| 38 const base::Time current_time_; |
| 39 |
| 33 std::queue<FtpDirectoryListingEntry> entries_; | 40 std::queue<FtpDirectoryListingEntry> entries_; |
| 34 | 41 |
| 35 DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingParserLs); | 42 DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingParserLs); |
| 36 }; | 43 }; |
| 37 | 44 |
| 38 } // namespace net | 45 } // namespace net |
| 39 | 46 |
| 40 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_LS_H_ | 47 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_LS_H_ |
| OLD | NEW |