OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 bool FileSystemDirURLRequestJob::GetCharset(std::string* charset) { | 74 bool FileSystemDirURLRequestJob::GetCharset(std::string* charset) { |
75 *charset = "utf-8"; | 75 *charset = "utf-8"; |
76 return true; | 76 return true; |
77 } | 77 } |
78 | 78 |
79 void FileSystemDirURLRequestJob::StartAsync() { | 79 void FileSystemDirURLRequestJob::StartAsync() { |
80 if (!request_) | 80 if (!request_) |
81 return; | 81 return; |
82 url_ = FileSystemURL(request_->url()); | 82 url_ = FileSystemURL(request_->url()); |
83 FileSystemOperation* operation = GetNewOperation(); | 83 base::PlatformFileError error_code; |
84 if (!operation) { | 84 FileSystemOperation* operation = GetNewOperation(&error_code); |
| 85 if (error_code != base::PLATFORM_FILE_OK) { |
85 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, | 86 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, |
86 net::ERR_INVALID_URL)); | 87 net::PlatformFileErrorToNetError(error_code))); |
87 return; | 88 return; |
88 } | 89 } |
89 operation->ReadDirectory( | 90 operation->ReadDirectory( |
90 url_, | 91 url_, |
91 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); | 92 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); |
92 } | 93 } |
93 | 94 |
94 void FileSystemDirURLRequestJob::DidReadDirectory( | 95 void FileSystemDirURLRequestJob::DidReadDirectory( |
95 base::PlatformFileError result, | 96 base::PlatformFileError result, |
96 const std::vector<base::FileUtilProxy::Entry>& entries, | 97 const std::vector<base::FileUtilProxy::Entry>& entries, |
(...skipping 20 matching lines...) Expand all Loading... |
117 | 118 |
118 typedef std::vector<base::FileUtilProxy::Entry>::const_iterator EntryIterator; | 119 typedef std::vector<base::FileUtilProxy::Entry>::const_iterator EntryIterator; |
119 for (EntryIterator it = entries.begin(); it != entries.end(); ++it) { | 120 for (EntryIterator it = entries.begin(); it != entries.end(); ++it) { |
120 const string16& name = FilePath(it->name).LossyDisplayName(); | 121 const string16& name = FilePath(it->name).LossyDisplayName(); |
121 data_.append(net::GetDirectoryListingEntry( | 122 data_.append(net::GetDirectoryListingEntry( |
122 name, std::string(), it->is_directory, it->size, | 123 name, std::string(), it->is_directory, it->size, |
123 it->last_modified_time)); | 124 it->last_modified_time)); |
124 } | 125 } |
125 | 126 |
126 if (has_more) { | 127 if (has_more) { |
127 GetNewOperation()->ReadDirectory( | 128 base::PlatformFileError error_code; |
| 129 FileSystemOperation* operation = GetNewOperation(&error_code); |
| 130 if (error_code != base::PLATFORM_FILE_OK) { |
| 131 NotifyDone(URLRequestStatus( |
| 132 URLRequestStatus::FAILED, |
| 133 net::PlatformFileErrorToNetError(error_code))); |
| 134 return; |
| 135 } |
| 136 |
| 137 operation->ReadDirectory( |
128 url_, | 138 url_, |
129 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); | 139 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); |
130 } else { | 140 } else { |
131 set_expected_content_size(data_.size()); | 141 set_expected_content_size(data_.size()); |
132 NotifyHeadersComplete(); | 142 NotifyHeadersComplete(); |
133 } | 143 } |
134 } | 144 } |
135 | 145 |
136 FileSystemOperation* FileSystemDirURLRequestJob::GetNewOperation() { | 146 FileSystemOperation* FileSystemDirURLRequestJob::GetNewOperation( |
137 return file_system_context_->CreateFileSystemOperation(url_); | 147 base::PlatformFileError* error_code) { |
| 148 return file_system_context_->CreateFileSystemOperation(url_, error_code); |
138 } | 149 } |
139 | 150 |
140 } // namespace fileapi | 151 } // namespace fileapi |
OLD | NEW |