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

Unified Diff: net/ftp/ftp_directory_listing_parser.h

Issue 465035: Split FTP LIST parsing code into individual files for each listing style. (Closed)
Patch Set: fix Created 11 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer_unittest.cc ('k') | net/ftp/ftp_directory_listing_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_directory_listing_parser.h
diff --git a/net/ftp/ftp_directory_listing_parser.h b/net/ftp/ftp_directory_listing_parser.h
new file mode 100644
index 0000000000000000000000000000000000000000..7ba895ad3efba6a4031ff80197c4517ccb582476
--- /dev/null
+++ b/net/ftp/ftp_directory_listing_parser.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSER_H_
+#define NET_FTP_FTP_DIRECTORY_LISTING_PARSER_H_
+
+#include "base/basictypes.h"
+#include "base/string16.h"
+#include "base/time.h"
+#include "net/ftp/ftp_server_type_histograms.h"
+
+namespace net {
+
+struct FtpDirectoryListingEntry {
+ enum Type {
+ FILE,
+ DIRECTORY,
+ SYMLINK,
+ };
+
+ Type type;
+ string16 name;
+ int64 size; // File size, in bytes. -1 if not applicable.
+
+ // Last modified time, in local time zone.
+ base::Time last_modified;
+};
+
+class FtpDirectoryListingParser {
+ public:
+ virtual ~FtpDirectoryListingParser();
+
+ virtual FtpServerType GetServerType() const = 0;
+
+ // Adds |line| to the internal parsing buffer. Returns true on success.
+ virtual bool ConsumeLine(const string16& line) = 0;
+
+ // Called after all input has been consumed. Returns true if the parser
+ // recognizes all received data as a valid listing.
+ virtual bool OnEndOfInput() = 0;
+
+ // Returns true if there is at least one FtpDirectoryListingEntry available.
+ virtual bool EntryAvailable() const = 0;
+
+ // Returns the next entry. It is an error to call this function unless
+ // EntryAvailable returns true.
+ virtual FtpDirectoryListingEntry PopEntry() = 0;
+};
+
+} // namespace net
+
+#endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_H_
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer_unittest.cc ('k') | net/ftp/ftp_directory_listing_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698