summaryrefslogtreecommitdiffstats
path: root/net/url_request
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 23:58:23 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 23:58:23 +0000
commitf311bd71f1defeb33ec4903593e23061a913f992 (patch)
treed3dd7f2422d41b15946002bf582b07f919475046 /net/url_request
parent5dce90240ecb2259290cd3aa12294b832b09eee9 (diff)
downloadchromium_src-f311bd71f1defeb33ec4903593e23061a913f992.zip
chromium_src-f311bd71f1defeb33ec4903593e23061a913f992.tar.gz
chromium_src-f311bd71f1defeb33ec4903593e23061a913f992.tar.bz2
revert 5730
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5731 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r--net/url_request/url_request_file_dir_job.cc42
-rw-r--r--net/url_request/url_request_file_dir_job.h10
-rw-r--r--net/url_request/url_request_file_job.cc4
-rw-r--r--net/url_request/url_request_ftp_job.cc7
4 files changed, 25 insertions, 38 deletions
diff --git a/net/url_request/url_request_file_dir_job.cc b/net/url_request/url_request_file_dir_job.cc
index 3685107..731d741 100644
--- a/net/url_request/url_request_file_dir_job.cc
+++ b/net/url_request/url_request_file_dir_job.cc
@@ -7,18 +7,16 @@
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/string_util.h"
-#include "base/time.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
+#include "net/base/wininet_util.h"
#include "net/url_request/url_request.h"
-#if defined(OS_POSIX)
-#include <sys/stat.h>
-#endif
-
using std::string;
using std::wstring;
+using net::WinInetUtil;
+
URLRequestFileDirJob::URLRequestFileDirJob(URLRequest* request,
const wstring& dir_path)
: URLRequestJob(request),
@@ -99,8 +97,12 @@ bool URLRequestFileDirJob::GetCharset(string* charset) {
return true;
}
-void URLRequestFileDirJob::OnListFile(
- const file_util::FileEnumerator::FindInfo& data) {
+void URLRequestFileDirJob::OnListFile(const WIN32_FIND_DATA& data) {
+ FILETIME local_time;
+ FileTimeToLocalFileTime(&data.ftLastWriteTime, &local_time);
+ int64 size = (static_cast<unsigned __int64>(data.nFileSizeHigh) << 32) |
+ data.nFileSizeLow;
+
// We wait to write out the header until we get the first file, so that we
// can catch errors from DirectoryLister and show an error page.
if (!wrote_header_) {
@@ -108,27 +110,11 @@ void URLRequestFileDirJob::OnListFile(
wrote_header_ = true;
}
-#if defined(OS_WIN)
- FILETIME local_time;
- ::FileTimeToLocalFileTime(&data.ftLastWriteTime, &local_time);
- int64 size = (static_cast<unsigned __int64>(data.nFileSizeHigh) << 32) |
- data.nFileSizeLow;
-
data_.append(net::GetDirectoryListingEntry(
- WideToUTF8(data.cFileName),
- (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? true : false,
- size,
- base::Time::FromFileTime(local_time)));
-
-#elif defined(OS_POSIX)
- data_.append(net::GetDirectoryListingEntry(
- data.filename.c_str(),
- S_ISDIR(data.stat.st_mode),
- data.stat.st_size,
- base::Time::FromTimeT(data.stat.st_mtime)));
-#endif
+ WideToUTF8(data.cFileName), data.dwFileAttributes, size, &local_time));
// TODO(darin): coalesce more?
+
CompleteRead();
}
@@ -137,7 +123,8 @@ void URLRequestFileDirJob::OnListDone(int error) {
if (error) {
read_pending_ = false;
- NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, error));
+ NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
+ WinInetUtil::OSErrorToNetError(error)));
} else if (canceled_) {
read_pending_ = false;
NotifyCanceled();
@@ -189,8 +176,7 @@ void URLRequestFileDirJob::CompleteRead() {
NotifyReadComplete(bytes_read);
} else {
NOTREACHED();
- // TODO: Better error code.
- NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, 0));
+ NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, 0)); // TODO: Better error code.
}
}
}
diff --git a/net/url_request/url_request_file_dir_job.h b/net/url_request/url_request_file_dir_job.h
index afbb56b..d8e7d43 100644
--- a/net/url_request/url_request_file_dir_job.h
+++ b/net/url_request/url_request_file_dir_job.h
@@ -5,13 +5,11 @@
#ifndef NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H__
#define NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H__
-#include "base/file_util.h"
#include "net/base/directory_lister.h"
#include "net/url_request/url_request_job.h"
-class URLRequestFileDirJob
- : public URLRequestJob,
- public net::DirectoryLister::DirectoryListerDelegate {
+class URLRequestFileDirJob : public URLRequestJob,
+ public net::DirectoryLister::Delegate {
public:
URLRequestFileDirJob(URLRequest* request, const std::wstring& dir_path);
virtual ~URLRequestFileDirJob();
@@ -24,8 +22,8 @@ class URLRequestFileDirJob
virtual bool GetMimeType(std::string* mime_type);
virtual bool GetCharset(std::string* charset);
- // DirectoryLister::DirectoryListerDelegate methods:
- virtual void OnListFile(const file_util::FileEnumerator::FindInfo& data);
+ // DirectoryLister::Delegate methods:
+ virtual void OnListFile(const WIN32_FIND_DATA& data);
virtual void OnListDone(int error);
private:
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index 5c823d8..608dc64 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -28,7 +28,9 @@
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/url_request/url_request.h"
+#if defined(OS_WIN)
#include "net/url_request/url_request_file_dir_job.h"
+#endif
#if defined(OS_WIN)
class URLRequestFileJob::AsyncResolver :
@@ -74,8 +76,10 @@ URLRequestJob* URLRequestFileJob::Factory(
std::wstring file_path;
if (net::FileURLToFilePath(request->url(), &file_path)) {
if (file_path[file_path.size() - 1] == file_util::kPathSeparator) {
+#if defined(OS_WIN)
// Only directories have trailing slashes.
return new URLRequestFileDirJob(request, file_path);
+#endif
}
}
diff --git a/net/url_request/url_request_ftp_job.cc b/net/url_request/url_request_ftp_job.cc
index 7b72118..9cd7ca9 100644
--- a/net/url_request/url_request_ftp_job.cc
+++ b/net/url_request/url_request_ftp_job.cc
@@ -9,7 +9,6 @@
#include "base/message_loop.h"
#include "base/string_util.h"
-#include "base/time.h"
#include "net/base/auth.h"
#include "net/base/load_flags.h"
#include "net/base/net_util.h"
@@ -379,8 +378,8 @@ void URLRequestFtpJob::OnFindFile(DWORD last_error) {
// We don't know the encoding, and can't assume utf8, so pass the 8bit
// directly to the browser for it to decide.
string file_entry = net::GetDirectoryListingEntry(
- find_data_.cFileName, false, size,
- base::Time::FromFileTime(find_data_.ftLastWriteTime));
+ find_data_.cFileName, find_data_.dwFileAttributes, size,
+ &find_data_.ftLastWriteTime);
WriteData(&file_entry, true);
FindNextFile();
@@ -402,7 +401,7 @@ void URLRequestFtpJob::OnStartDirectoryTraversal() {
// If this isn't top level directory (i.e. the path isn't "/",) add a link to
// the parent directory.
if (request_->url().path().length() > 1)
- html.append(net::GetDirectoryListingEntry("..", false, 0, base::Time()));
+ html.append(net::GetDirectoryListingEntry("..", 0, 0, NULL));
WriteData(&html, true);