| OLD | NEW |
| 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 "webkit/fileapi/file_system_dir_url_request_job.h" | 5 #include "webkit/fileapi/file_system_dir_url_request_job.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_util_proxy.h" | 10 #include "base/file_util_proxy.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 void FileSystemDirURLRequestJob::DidReadDirectory( | 110 void FileSystemDirURLRequestJob::DidReadDirectory( |
| 111 base::PlatformFileError error_code, | 111 base::PlatformFileError error_code, |
| 112 const std::vector<base::FileUtilProxy::Entry>& entries) { | 112 const std::vector<base::FileUtilProxy::Entry>& entries) { |
| 113 if (error_code != base::PLATFORM_FILE_OK) { | 113 if (error_code != base::PLATFORM_FILE_OK) { |
| 114 NotifyFailed(error_code); | 114 NotifyFailed(error_code); |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 | 117 |
| 118 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
| 119 const string16& title = absolute_dir_path_.value(); | 119 const string16& title = relative_dir_path_.value(); |
| 120 #elif defined(OS_POSIX) | 120 #elif defined(OS_POSIX) |
| 121 const string16& title = WideToUTF16( | 121 const string16& title = WideToUTF16( |
| 122 base::SysNativeMBToWide(absolute_dir_path_.value())); | 122 base::SysNativeMBToWide(relative_dir_path_.value())); |
| 123 #endif | 123 #endif |
| 124 data_.append(net::GetDirectoryListingHeader(title)); | 124 data_.append(net::GetDirectoryListingHeader(ASCIIToUTF16("/") + title)); |
| 125 | 125 |
| 126 typedef std::vector<base::FileUtilProxy::Entry>::const_iterator EntryIterator; | 126 typedef std::vector<base::FileUtilProxy::Entry>::const_iterator EntryIterator; |
| 127 for (EntryIterator it = entries.begin(); it != entries.end(); ++it) { | 127 for (EntryIterator it = entries.begin(); it != entries.end(); ++it) { |
| 128 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
| 129 const string16& name = it->name; | 129 const string16& name = it->name; |
| 130 #elif defined(OS_POSIX) | 130 #elif defined(OS_POSIX) |
| 131 const string16& name = | 131 const string16& name = |
| 132 WideToUTF16(base::SysNativeMBToWide(it->name)); | 132 WideToUTF16(base::SysNativeMBToWide(it->name)); |
| 133 #endif | 133 #endif |
| 134 // TODO(adamk): Add file size? | 134 // TODO(adamk): Add file size? |
| 135 data_.append(net::GetDirectoryListingEntry( | 135 data_.append(net::GetDirectoryListingEntry( |
| 136 name, std::string(), it->is_directory, 0, base::Time())); | 136 name, std::string(), it->is_directory, 0, base::Time())); |
| 137 } | 137 } |
| 138 | 138 |
| 139 set_expected_content_size(data_.size()); | 139 set_expected_content_size(data_.size()); |
| 140 NotifyHeadersComplete(); | 140 NotifyHeadersComplete(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void FileSystemDirURLRequestJob::NotifyFailed(int rv) { | 143 void FileSystemDirURLRequestJob::NotifyFailed(int rv) { |
| 144 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 144 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace fileapi | 147 } // namespace fileapi |
| OLD | NEW |