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

Side by Side Diff: webkit/glue/ftp_directory_listing_response_delegate.cc

Issue 238001: Fix FTP directory listings for servers which use \n as the line break. (Closed)
Patch Set: updated Created 11 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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. 1 // Copyright (c) 2009 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 #include "webkit/glue/ftp_directory_listing_response_delegate.h" 5 #include "webkit/glue/ftp_directory_listing_response_delegate.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if (!CodepageToUTF16(raw_filename, encoding.c_str(), 56 if (!CodepageToUTF16(raw_filename, encoding.c_str(),
57 OnStringUtilConversionError::SUBSTITUTE, &filename)) 57 OnStringUtilConversionError::SUBSTITUTE, &filename))
58 filename = WideToUTF16Hack(base::SysNativeMBToWide(raw_filename)); 58 filename = WideToUTF16Hack(base::SysNativeMBToWide(raw_filename));
59 return filename; 59 return filename;
60 } 60 }
61 61
62 void ExtractFullLinesFromBuffer(std::string* buffer, 62 void ExtractFullLinesFromBuffer(std::string* buffer,
63 std::vector<std::string>* lines) { 63 std::vector<std::string>* lines) {
64 int cut_pos = 0; 64 int cut_pos = 0;
65 for (size_t i = 0; i < buffer->length(); i++) { 65 for (size_t i = 0; i < buffer->length(); i++) {
66 if (i >= 1 && (*buffer)[i - 1] == '\r' && (*buffer)[i] == '\n') { 66 if ((*buffer)[i] != '\n')
67 lines->push_back(buffer->substr(cut_pos, i - cut_pos - 1)); 67 continue;
68 cut_pos = i + 1; 68 size_t line_length = i - cut_pos;
69 } 69 if (line_length > 0 && (*buffer)[i - 1] == '\r')
70 line_length--;
71 lines->push_back(buffer->substr(cut_pos, line_length));
72 cut_pos = i + 1;
70 } 73 }
71 buffer->erase(0, cut_pos); 74 buffer->erase(0, cut_pos);
72 } 75 }
73 76
74 void LogFtpServerType(char server_type) { 77 void LogFtpServerType(char server_type) {
75 switch (server_type) { 78 switch (server_type) {
76 case 'E': 79 case 'E':
77 net::UpdateFtpServerTypeHistograms(net::SERVER_EPLF); 80 net::UpdateFtpServerTypeHistograms(net::SERVER_EPLF);
78 break; 81 break;
79 case 'V': 82 case 'V':
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 247
245 void FtpDirectoryListingResponseDelegate::SendResponseBufferToClient() { 248 void FtpDirectoryListingResponseDelegate::SendResponseBufferToClient() {
246 if (!response_buffer_.empty()) { 249 if (!response_buffer_.empty()) {
247 client_->didReceiveData(loader_, response_buffer_.data(), 250 client_->didReceiveData(loader_, response_buffer_.data(),
248 response_buffer_.length(), -1); 251 response_buffer_.length(), -1);
249 response_buffer_.clear(); 252 response_buffer_.clear();
250 } 253 }
251 } 254 }
252 255
253 } // namespace webkit_glue 256 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698