summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_file_job.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/url_request/url_request_file_job.cc')
-rw-r--r--net/url_request/url_request_file_job.cc25
1 files changed, 12 insertions, 13 deletions
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index 5c823d8..3c37468 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -38,7 +38,7 @@ class URLRequestFileJob::AsyncResolver :
: owner_(owner), owner_loop_(MessageLoop::current()) {
}
- void Resolve(const std::wstring& file_path) {
+ void Resolve(const FilePath& file_path) {
file_util::FileInfo file_info;
bool exists = file_util::GetFileInfo(file_path, &file_info);
AutoLock locked(lock_);
@@ -71,9 +71,9 @@ class URLRequestFileJob::AsyncResolver :
// static
URLRequestJob* URLRequestFileJob::Factory(
URLRequest* request, const std::string& scheme) {
- std::wstring file_path;
+ FilePath file_path;
if (net::FileURLToFilePath(request->url(), &file_path)) {
- if (file_path[file_path.size() - 1] == file_util::kPathSeparator) {
+ if (file_util::DirectoryExists(file_path)) {
// Only directories have trailing slashes.
return new URLRequestFileDirJob(request, file_path);
}
@@ -102,7 +102,7 @@ URLRequestFileJob::~URLRequestFileJob() {
void URLRequestFileJob::Start() {
#if defined(OS_WIN)
// Resolve UNC paths on a background thread.
- if (!file_path_.compare(0, 2, L"\\\\")) {
+ if (!file_path_.value().compare(0, 2, L"\\\\")) {
DCHECK(!async_resolver_);
async_resolver_ = new AsyncResolver(this);
WorkerPool::PostTask(FROM_HERE, NewRunnableMethod(
@@ -154,7 +154,7 @@ bool URLRequestFileJob::ReadRawData(
bool URLRequestFileJob::GetMimeType(std::string* mime_type) {
DCHECK(request_);
- return net::GetMimeTypeFromFile(file_path_, mime_type);
+ return net::GetMimeTypeFromFile(file_path_.ToWStringHack(), mime_type);
}
void URLRequestFileJob::DidResolve(
@@ -176,7 +176,7 @@ void URLRequestFileJob::DidResolve(
int flags = base::PLATFORM_FILE_OPEN |
base::PLATFORM_FILE_READ |
base::PLATFORM_FILE_ASYNC;
- rv = stream_.Open(file_path_, flags);
+ rv = stream_.Open(file_path_.ToWStringHack(), flags);
}
if (rv == net::OK) {
@@ -214,16 +214,15 @@ bool URLRequestFileJob::IsRedirectResponse(
}
#if defined(OS_WIN)
- // Follow a Windows shortcut.
- size_t found;
- found = file_path_.find_last_of('.');
+ std::wstring extension =
+ file_util::GetFileExtensionFromPath(file_path_.value());
- // We just resolve .lnk file, ignor others.
- if (found == std::string::npos ||
- !LowerCaseEqualsASCII(file_path_.substr(found), ".lnk"))
+ // Follow a Windows shortcut.
+ // We just resolve .lnk file, ignore others.
+ if (!LowerCaseEqualsASCII(extension, "lnk"))
return false;
- std::wstring new_path = file_path_;
+ std::wstring new_path = file_path_.value();
bool resolved;
resolved = file_util::ResolveShortcut(&new_path);