OLD | NEW |
(Empty) | |
| 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 |
| 3 // LICENSE file. |
| 4 |
| 5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSERS_H_ |
| 6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSERS_H_ |
| 7 |
| 8 #include <queue> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/string16.h" |
| 12 #include "base/time.h" |
| 13 #include "net/ftp/ftp_server_type_histograms.h" |
| 14 |
| 15 namespace net { |
| 16 |
| 17 struct FtpDirectoryListingEntry { |
| 18 enum Type { |
| 19 FILE, |
| 20 DIRECTORY, |
| 21 SYMLINK, |
| 22 }; |
| 23 |
| 24 Type type; |
| 25 string16 name; |
| 26 |
| 27 // Last modified time, in local time zone. |
| 28 base::Time last_modified; |
| 29 }; |
| 30 |
| 31 class FtpDirectoryListingParser { |
| 32 public: |
| 33 virtual ~FtpDirectoryListingParser(); |
| 34 |
| 35 // Adds |line| to the internal parsing buffer. Returns true on success. |
| 36 virtual bool ConsumeLine(const string16& line) = 0; |
| 37 |
| 38 // Returns true if there is at least one FtpDirectoryListingEntry available. |
| 39 virtual bool EntryAvailable() const = 0; |
| 40 |
| 41 // Returns the next entry. It is an error to call this function unless |
| 42 // EntryAvailable returns true. |
| 43 virtual FtpDirectoryListingEntry PopEntry() = 0; |
| 44 }; |
| 45 |
| 46 class FtpLsDirectoryListingParser : public FtpDirectoryListingParser { |
| 47 public: |
| 48 FtpLsDirectoryListingParser(); |
| 49 |
| 50 // FtpDirectoryListingParser methods: |
| 51 virtual bool ConsumeLine(const string16& line); |
| 52 virtual bool EntryAvailable() const; |
| 53 virtual FtpDirectoryListingEntry PopEntry(); |
| 54 |
| 55 private: |
| 56 std::queue<FtpDirectoryListingEntry> entries_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(FtpLsDirectoryListingParser); |
| 59 }; |
| 60 |
| 61 } // namespace net |
| 62 |
| 63 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSERS_H_ |
OLD | NEW |