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

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

Issue 2356253006: Make SplitStringUsingSubstr have consistent args. (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2011 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 #include "net/ftp/ftp_directory_listing_parser.h" 5 #include "net/ftp/ftp_directory_listing_parser.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/i18n/encoding_detection.h" 9 #include "base/i18n/encoding_detection.h"
10 #include "base/i18n/icu_string_conversions.h" 10 #include "base/i18n/icu_string_conversions.h"
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 39
40 // Parses |text| as an FTP directory listing. Fills in |entries| 40 // Parses |text| as an FTP directory listing. Fills in |entries|
41 // and |server_type| and returns network error code. 41 // and |server_type| and returns network error code.
42 int ParseListing(const base::string16& text, 42 int ParseListing(const base::string16& text,
43 const base::string16& newline_separator, 43 const base::string16& newline_separator,
44 const std::string& encoding, 44 const std::string& encoding,
45 const base::Time& current_time, 45 const base::Time& current_time,
46 std::vector<FtpDirectoryListingEntry>* entries, 46 std::vector<FtpDirectoryListingEntry>* entries,
47 FtpServerType* server_type) { 47 FtpServerType* server_type) {
48 std::vector<base::string16> lines; 48 std::vector<base::string16> lines = base::SplitStringUsingSubstr(
49 base::SplitStringUsingSubstr(text, newline_separator, &lines); 49 text, newline_separator, base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
50 50
51 struct { 51 struct {
52 base::Callback<bool(void)> callback; 52 base::Callback<bool(void)> callback;
53 FtpServerType server_type; 53 FtpServerType server_type;
54 } parsers[] = { 54 } parsers[] = {
55 { 55 {
56 base::Bind(&ParseFtpDirectoryListingLs, lines, current_time, entries), 56 base::Bind(&ParseFtpDirectoryListingLs, lines, current_time, entries),
57 SERVER_LS 57 SERVER_LS
58 }, 58 },
59 { 59 {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 int ParseFtpDirectoryListing(const std::string& text, 119 int ParseFtpDirectoryListing(const std::string& text,
120 const base::Time& current_time, 120 const base::Time& current_time,
121 std::vector<FtpDirectoryListingEntry>* entries) { 121 std::vector<FtpDirectoryListingEntry>* entries) {
122 FtpServerType server_type = SERVER_UNKNOWN; 122 FtpServerType server_type = SERVER_UNKNOWN;
123 int rv = DecodeAndParse(text, current_time, entries, &server_type); 123 int rv = DecodeAndParse(text, current_time, entries, &server_type);
124 UpdateFtpServerTypeHistograms(server_type); 124 UpdateFtpServerTypeHistograms(server_type);
125 return rv; 125 return rv;
126 } 126 }
127 127
128 } // namespace net 128 } // namespace net
OLDNEW
« no previous file with comments | « extensions/renderer/extensions_render_frame_observer.cc ('k') | net/ftp/ftp_directory_listing_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698