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

Unified Diff: storage/browser/fileapi/file_system_dir_url_request_job.cc

Issue 1432403003: Do not call stat() when reading directories via File API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed FSP tests. Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « storage/browser/fileapi/file_system_dir_url_request_job.h ('k') | storage/common/fileapi/directory_entry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/fileapi/file_system_dir_url_request_job.cc
diff --git a/storage/browser/fileapi/file_system_dir_url_request_job.cc b/storage/browser/fileapi/file_system_dir_url_request_job.cc
index 35b6c1d8d63d9644c7c6861a35be3e366d79f440..747ed661261a8b42b3362c35cf611c1658c2c650 100644
--- a/storage/browser/fileapi/file_system_dir_url_request_job.cc
+++ b/storage/browser/fileapi/file_system_dir_url_request_job.cc
@@ -142,15 +142,52 @@ void FileSystemDirURLRequestJob::DidReadDirectory(
data_.append(net::GetDirectoryListingHeader(title));
}
- typedef std::vector<DirectoryEntry>::const_iterator EntryIterator;
- for (EntryIterator it = entries.begin(); it != entries.end(); ++it) {
- const base::string16& name = base::FilePath(it->name).LossyDisplayName();
- data_.append(net::GetDirectoryListingEntry(
- name, std::string(), it->is_directory, it->size,
- it->last_modified_time));
- }
+ entries_.insert(entries_.end(), entries.begin(), entries.end());
if (!has_more) {
+ if (entries_.size()) {
+ GetMetadata(0);
+ } else {
+ set_expected_content_size(data_.size());
+ NotifyHeadersComplete();
+ }
+ }
+}
+
+void FileSystemDirURLRequestJob::GetMetadata(size_t index) {
+ const DirectoryEntry& entry = entries_[index];
+ const FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL(
+ url_.origin(), url_.type(),
+ url_.path().Append(base::FilePath(entry.name)));
+ DCHECK(url.is_valid());
+ file_system_context_->operation_runner()->GetMetadata(
+ url,
+ base::Bind(&FileSystemDirURLRequestJob::DidGetMetadata, this, index));
+}
+
+void FileSystemDirURLRequestJob::DidGetMetadata(
+ size_t index,
+ base::File::Error result,
+ const base::File::Info& file_info) {
+ if (result != base::File::FILE_OK) {
+ int rv = net::ERR_FILE_NOT_FOUND;
+ if (result == base::File::FILE_ERROR_INVALID_URL)
+ rv = net::ERR_INVALID_URL;
+ NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
+ }
+
+ if (!request_)
+ return;
+
+ const DirectoryEntry& entry = entries_[index];
+ const base::string16& name = base::FilePath(entry.name).LossyDisplayName();
+ data_.append(net::GetDirectoryListingEntry(name, std::string(),
+ entry.is_directory, file_info.size,
+ file_info.last_modified));
+
+ if (index < entries_.size() - 1) {
+ GetMetadata(index + 1);
+ } else {
set_expected_content_size(data_.size());
NotifyHeadersComplete();
}
« no previous file with comments | « storage/browser/fileapi/file_system_dir_url_request_job.h ('k') | storage/common/fileapi/directory_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698