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

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

Issue 6670085: FTP: Detect the character encoding only after the entire listing is received. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test coverage Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer.cc ('k') | net/ftp/ftp_directory_listing_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSER_H_ 5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSER_H_
6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSER_H_ 6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string>
10 #include <vector>
11
9 #include "base/basictypes.h" 12 #include "base/basictypes.h"
10 #include "base/string16.h" 13 #include "base/string16.h"
11 #include "base/time.h" 14 #include "base/time.h"
12 #include "net/ftp/ftp_server_type_histograms.h"
13 15
14 namespace net { 16 namespace net {
15 17
16 struct FtpDirectoryListingEntry { 18 struct FtpDirectoryListingEntry {
17 enum Type { 19 enum Type {
18 FILE, 20 FILE,
19 DIRECTORY, 21 DIRECTORY,
20 SYMLINK, 22 SYMLINK,
21 }; 23 };
22 24
23 Type type; 25 Type type;
24 string16 name; 26 string16 name; // Name (UTF-16-encoded).
27 std::string raw_name; // Name in original character encoding.
25 int64 size; // File size, in bytes. -1 if not applicable. 28 int64 size; // File size, in bytes. -1 if not applicable.
26 29
27 // Last modified time, in local time zone. 30 // Last modified time, in local time zone.
28 base::Time last_modified; 31 base::Time last_modified;
29 }; 32 };
30 33
31 class FtpDirectoryListingParser { 34 // Parses an FTP directory listing |text|. On success fills in |entries|.
32 public: 35 // Returns network error code.
33 virtual ~FtpDirectoryListingParser(); 36 int ParseFtpDirectoryListing(const std::string& text,
34 37 const base::Time& current_time,
35 virtual FtpServerType GetServerType() const = 0; 38 std::vector<FtpDirectoryListingEntry>* entries);
36
37 // Adds |line| to the internal parsing buffer. Returns true on success.
38 virtual bool ConsumeLine(const string16& line) = 0;
39
40 // Called after all input has been consumed. Returns true if the parser
41 // recognizes all received data as a valid listing.
42 virtual bool OnEndOfInput() = 0;
43
44 // Returns true if there is at least one FtpDirectoryListingEntry available.
45 virtual bool EntryAvailable() const = 0;
46
47 // Returns the next entry. It is an error to call this function unless
48 // EntryAvailable returns true.
49 virtual FtpDirectoryListingEntry PopEntry() = 0;
50 };
51 39
52 } // namespace net 40 } // namespace net
53 41
54 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_H_ 42 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_H_
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer.cc ('k') | net/ftp/ftp_directory_listing_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698