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

Unified Diff: net/ftp/ftp_directory_listing_parser_ls.h

Issue 1120012: Fix the "ls -l" style date parser to correctly guess the year if it is not provided. (Closed)
Patch Set: better comments Created 10 years, 9 months 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_ls.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_ls.h
diff --git a/net/ftp/ftp_directory_listing_parser_ls.h b/net/ftp/ftp_directory_listing_parser_ls.h
index 3fd0d322c2b74113bfb9492e854588d86c5e6fd8..0d52791492e335a28d7755f562bc833b8b1c505b 100644
--- a/net/ftp/ftp_directory_listing_parser_ls.h
+++ b/net/ftp/ftp_directory_listing_parser_ls.h
@@ -7,6 +7,7 @@
#include <queue>
+#include "base/time.h"
#include "net/ftp/ftp_directory_listing_parser.h"
namespace net {
@@ -14,7 +15,10 @@ namespace net {
// Parser for "ls -l"-style directory listing.
class FtpDirectoryListingParserLs : public FtpDirectoryListingParser {
public:
- FtpDirectoryListingParserLs();
+ // Constructor. When the current time is needed to guess the year on partial
+ // date strings, |current_time| will be used. This allows passing a specific
+ // date during testing.
+ explicit FtpDirectoryListingParserLs(const base::Time& current_time);
// FtpDirectoryListingParser methods:
virtual FtpServerType GetServerType() const { return SERVER_LS; }
@@ -30,6 +34,9 @@ class FtpDirectoryListingParserLs : public FtpDirectoryListingParser {
// integer. Only one such header is allowed per listing.
bool received_total_line_;
+ // Store the current time. We need it to correctly parse received dates.
+ const base::Time current_time_;
+
std::queue<FtpDirectoryListingEntry> entries_;
DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingParserLs);
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer_unittest.cc ('k') | net/ftp/ftp_directory_listing_parser_ls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698