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

Side by Side Diff: net/ftp/ftp_directory_listing_buffer.cc

Issue 343073: Use the new FTP LIST parsing code in the browser. (Closed)
Patch Set: fixes 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
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer.h ('k') | net/ftp/ftp_directory_listing_parsers.h » ('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) 2009 The Chromium Authors. All rights reserved. Use of this 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 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "net/ftp/ftp_directory_listing_buffer.h" 5 #include "net/ftp/ftp_directory_listing_buffer.h"
6 6
7 #include "base/i18n/icu_string_conversions.h" 7 #include "base/i18n/icu_string_conversions.h"
8 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 return ParseLines(); 60 return ParseLines();
61 } 61 }
62 62
63 int FtpDirectoryListingBuffer::ProcessRemainingData() { 63 int FtpDirectoryListingBuffer::ProcessRemainingData() {
64 int rv = ExtractFullLinesFromBuffer(); 64 int rv = ExtractFullLinesFromBuffer();
65 if (rv != OK) 65 if (rv != OK)
66 return rv; 66 return rv;
67 67
68 if (!buffer_.empty())
69 return ERR_INVALID_RESPONSE;
70
68 return ParseLines(); 71 return ParseLines();
69 } 72 }
70 73
71 bool FtpDirectoryListingBuffer::EntryAvailable() const { 74 bool FtpDirectoryListingBuffer::EntryAvailable() const {
72 return (current_parser_ ? current_parser_->EntryAvailable() : false); 75 return (current_parser_ ? current_parser_->EntryAvailable() : false);
73 } 76 }
74 77
75 FtpDirectoryListingEntry FtpDirectoryListingBuffer::PopEntry() { 78 FtpDirectoryListingEntry FtpDirectoryListingBuffer::PopEntry() {
76 DCHECK(EntryAvailable()); 79 DCHECK(EntryAvailable());
77 return current_parser_->PopEntry(); 80 return current_parser_->PopEntry();
78 } 81 }
79 82
83 FtpServerType FtpDirectoryListingBuffer::GetServerType() const {
84 return (current_parser_ ? current_parser_->GetServerType() : SERVER_UNKNOWN);
85 }
86
80 bool FtpDirectoryListingBuffer::ConvertToDetectedEncoding( 87 bool FtpDirectoryListingBuffer::ConvertToDetectedEncoding(
81 const std::string& from, string16* to) { 88 const std::string& from, string16* to) {
82 std::string encoding(encoding_.empty() ? "ascii" : encoding_); 89 std::string encoding(encoding_.empty() ? "ascii" : encoding_);
83 return base::CodepageToUTF16(from, encoding.c_str(), 90 return base::CodepageToUTF16(from, encoding.c_str(),
84 base::OnStringConversionError::FAIL, to); 91 base::OnStringConversionError::FAIL, to);
85 } 92 }
86 93
87 int FtpDirectoryListingBuffer::ExtractFullLinesFromBuffer() { 94 int FtpDirectoryListingBuffer::ExtractFullLinesFromBuffer() {
88 if (encoding_.empty()) 95 if (encoding_.empty())
89 encoding_ = DetectEncoding(buffer_); 96 encoding_ = DetectEncoding(buffer_);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return ERR_UNRECOGNIZED_FTP_DIRECTORY_LISTING_FORMAT; 138 return ERR_UNRECOGNIZED_FTP_DIRECTORY_LISTING_FORMAT;
132 if (parsers_.size() == 1) 139 if (parsers_.size() == 1)
133 current_parser_ = *parsers_.begin(); 140 current_parser_ = *parsers_.begin();
134 } 141 }
135 } 142 }
136 143
137 return OK; 144 return OK;
138 } 145 }
139 146
140 } // namespace net 147 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer.h ('k') | net/ftp/ftp_directory_listing_parsers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698