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 FileSystemOperation* operation = GetNewOperation(); |
kinuko
2012/09/06 09:15:10
Please let GetNewOperation return error code too
calvinlo
2012/09/06 11:19:32
Done.
| |
84 if (!operation) { | 84 if (!operation) { |
85 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, | 85 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, |
86 net::ERR_INVALID_URL)); | 86 net::ERR_INVALID_URL)); |
kinuko
2012/09/06 09:15:10
...and return the error code here (via PlatformFil
calvinlo
2012/09/06 11:19:32
Done.
| |
87 return; | 87 return; |
88 } | 88 } |
89 operation->ReadDirectory( | 89 operation->ReadDirectory( |
90 url_, | 90 url_, |
91 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); | 91 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); |
92 } | 92 } |
93 | 93 |
94 void FileSystemDirURLRequestJob::DidReadDirectory( | 94 void FileSystemDirURLRequestJob::DidReadDirectory( |
95 base::PlatformFileError result, | 95 base::PlatformFileError result, |
96 const std::vector<base::FileUtilProxy::Entry>& entries, | 96 const std::vector<base::FileUtilProxy::Entry>& entries, |
(...skipping 20 matching lines...) Expand all Loading... | |
117 | 117 |
118 typedef std::vector<base::FileUtilProxy::Entry>::const_iterator EntryIterator; | 118 typedef std::vector<base::FileUtilProxy::Entry>::const_iterator EntryIterator; |
119 for (EntryIterator it = entries.begin(); it != entries.end(); ++it) { | 119 for (EntryIterator it = entries.begin(); it != entries.end(); ++it) { |
120 const string16& name = FilePath(it->name).LossyDisplayName(); | 120 const string16& name = FilePath(it->name).LossyDisplayName(); |
121 data_.append(net::GetDirectoryListingEntry( | 121 data_.append(net::GetDirectoryListingEntry( |
122 name, std::string(), it->is_directory, it->size, | 122 name, std::string(), it->is_directory, it->size, |
123 it->last_modified_time)); | 123 it->last_modified_time)); |
124 } | 124 } |
125 | 125 |
126 if (has_more) { | 126 if (has_more) { |
127 GetNewOperation()->ReadDirectory( | 127 GetNewOperation()->ReadDirectory( |
kinuko
2012/09/06 09:15:10
ditto. We need to fail (with NotifyDone) if the o
calvinlo
2012/09/06 11:19:32
Done.
| |
128 url_, | 128 url_, |
129 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); | 129 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); |
130 } else { | 130 } else { |
131 set_expected_content_size(data_.size()); | 131 set_expected_content_size(data_.size()); |
132 NotifyHeadersComplete(); | 132 NotifyHeadersComplete(); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 FileSystemOperation* FileSystemDirURLRequestJob::GetNewOperation() { | 136 FileSystemOperation* FileSystemDirURLRequestJob::GetNewOperation() { |
137 return file_system_context_->CreateFileSystemOperation(url_); | 137 return file_system_context_->CreateFileSystemOperation(url_, NULL); |
138 } | 138 } |
139 | 139 |
140 } // namespace fileapi | 140 } // namespace fileapi |
OLD | NEW |