Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: net/ftp/ftp_directory_listing_parsers.h

Issue 244008: Beginnings of our own FTP LIST parsing code. (Closed)
Patch Set: test even more (slightly) Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer_unittest.cc ('k') | net/ftp/ftp_directory_listing_parsers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698