| OLD | NEW |
| 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 "net/url_request/url_request_new_ftp_job.h" | 5 #include "net/url_request/url_request_new_ftp_job.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 int buf_size, | 119 int buf_size, |
| 120 int bytes_read) { | 120 int bytes_read) { |
| 121 std::string file_entry; | 121 std::string file_entry; |
| 122 std::string line; | 122 std::string line; |
| 123 buf->data()[bytes_read] = 0; | 123 buf->data()[bytes_read] = 0; |
| 124 int64 file_size; | 124 int64 file_size; |
| 125 std::istringstream iss(buf->data()); | 125 std::istringstream iss(buf->data()); |
| 126 while (getline(iss, line)) { | 126 while (getline(iss, line)) { |
| 127 struct net::ListState state; | 127 struct net::ListState state; |
| 128 struct net::ListResult result; | 128 struct net::ListResult result; |
| 129 base::Time::Exploded et; | |
| 130 std::replace(line.begin(), line.end(), '\r', '\0'); | 129 std::replace(line.begin(), line.end(), '\r', '\0'); |
| 131 net::LineType line_type = ParseFTPLine(line.c_str(), &state, &result); | 130 net::LineType line_type = ParseFTPLine(line.c_str(), &state, &result); |
| 132 switch (line_type) { | 131 switch (line_type) { |
| 133 case net::FTP_TYPE_DIRECTORY: | 132 case net::FTP_TYPE_DIRECTORY: |
| 134 // TODO(ibrar): There is some problem in ParseFTPLine function or | |
| 135 // in conversion between tm and base::Time::Exploded. | |
| 136 // It returns wrong date/time (Differnce is 1 day and 17 Hours). | |
| 137 memset(&et, 0, sizeof(base::Time::Exploded)); | |
| 138 et.second = result.fe_time.tm_sec; | |
| 139 et.minute = result.fe_time.tm_min; | |
| 140 et.hour = result.fe_time.tm_hour; | |
| 141 et.day_of_month = result.fe_time.tm_mday; | |
| 142 et.month = result.fe_time.tm_mon + 1; | |
| 143 et.year = result.fe_time.tm_year + 1900; | |
| 144 et.day_of_week = result.fe_time.tm_wday; | |
| 145 | |
| 146 file_entry.append(net::GetDirectoryListingEntry( | 133 file_entry.append(net::GetDirectoryListingEntry( |
| 147 result.fe_fname, true, 0, base::Time::FromLocalExploded(et))); | 134 result.fe_fname, true, 0, |
| 135 base::Time::FromLocalExploded(result.fe_time))); |
| 148 break; | 136 break; |
| 149 case net::FTP_TYPE_FILE: | 137 case net::FTP_TYPE_FILE: |
| 150 // TODO(ibrar): There should be a way to create a Time object based | |
| 151 // on "tm" structure. This will remove bunch of line of code to convert | |
| 152 // tm to Time object. | |
| 153 memset(&et, 0, sizeof(base::Time::Exploded)); | |
| 154 et.second = result.fe_time.tm_sec; | |
| 155 et.minute = result.fe_time.tm_min; | |
| 156 et.hour = result.fe_time.tm_hour; | |
| 157 et.day_of_month = result.fe_time.tm_mday; | |
| 158 et.month = result.fe_time.tm_mon + 1; | |
| 159 et.year = result.fe_time.tm_year + 1900; | |
| 160 et.day_of_week = result.fe_time.tm_wday; | |
| 161 // TODO(ibrar): There is some problem in ParseFTPLine function or | |
| 162 // in conversion between tm and base::Time::Exploded. | |
| 163 // It returns wrong date/time (Differnce is 1 day and 17 Hours). | |
| 164 if (StringToInt64(result.fe_size, &file_size)) | 138 if (StringToInt64(result.fe_size, &file_size)) |
| 165 file_entry.append(net::GetDirectoryListingEntry( | 139 file_entry.append(net::GetDirectoryListingEntry( |
| 166 result.fe_fname, false, file_size, | 140 result.fe_fname, false, file_size, |
| 167 base::Time::FromLocalExploded(et))); | 141 base::Time::FromLocalExploded(result.fe_time))); |
| 168 break; | 142 break; |
| 169 case net::FTP_TYPE_SYMLINK: | 143 case net::FTP_TYPE_SYMLINK: |
| 170 case net::FTP_TYPE_JUNK: | 144 case net::FTP_TYPE_JUNK: |
| 171 case net::FTP_TYPE_COMMENT: | 145 case net::FTP_TYPE_COMMENT: |
| 172 break; | 146 break; |
| 173 default: | 147 default: |
| 174 break; | 148 break; |
| 175 } | 149 } |
| 176 } | 150 } |
| 177 directory_html_.append(file_entry); | 151 directory_html_.append(file_entry); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 218 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
| 245 this, &URLRequestNewFtpJob::OnStartCompleted, rv)); | 219 this, &URLRequestNewFtpJob::OnStartCompleted, rv)); |
| 246 } | 220 } |
| 247 | 221 |
| 248 void URLRequestNewFtpJob::DestroyTransaction() { | 222 void URLRequestNewFtpJob::DestroyTransaction() { |
| 249 DCHECK(transaction_.get()); | 223 DCHECK(transaction_.get()); |
| 250 | 224 |
| 251 transaction_.reset(); | 225 transaction_.reset(); |
| 252 response_info_ = NULL; | 226 response_info_ = NULL; |
| 253 } | 227 } |
| OLD | NEW |