| 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/browser/fileapi/file_system_dir_url_request_job.h" | 5 #include "webkit/browser/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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 | 79 |
| 80 void FileSystemDirURLRequestJob::StartAsync() { | 80 void FileSystemDirURLRequestJob::StartAsync() { |
| 81 if (!request_) | 81 if (!request_) |
| 82 return; | 82 return; |
| 83 url_ = file_system_context_->CrackURL(request_->url()); | 83 url_ = file_system_context_->CrackURL(request_->url()); |
| 84 if (!file_system_context_->CanServeURLRequest(url_)) { | 84 if (!file_system_context_->CanServeURLRequest(url_)) { |
| 85 // In incognito mode the API is not usable and there should be no data. | 85 // In incognito mode the API is not usable and there should be no data. |
| 86 if (url_.is_valid() && VirtualPath::IsRootPath(url_.virtual_path())) { | 86 if (url_.is_valid() && VirtualPath::IsRootPath(url_.virtual_path())) { |
| 87 // Return an empty directory if the filesystem root is queried. | 87 // Return an empty directory if the filesystem root is queried. |
| 88 DidReadDirectory(base::PLATFORM_FILE_OK, | 88 DidReadDirectory(base::File::FILE_OK, |
| 89 std::vector<DirectoryEntry>(), | 89 std::vector<DirectoryEntry>(), |
| 90 false); | 90 false); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, | 93 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, |
| 94 net::ERR_FILE_NOT_FOUND)); | 94 net::ERR_FILE_NOT_FOUND)); |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 file_system_context_->operation_runner()->ReadDirectory( | 97 file_system_context_->operation_runner()->ReadDirectory( |
| 98 url_, | 98 url_, |
| 99 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); | 99 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void FileSystemDirURLRequestJob::DidReadDirectory( | 102 void FileSystemDirURLRequestJob::DidReadDirectory( |
| 103 base::PlatformFileError result, | 103 base::File::Error result, |
| 104 const std::vector<DirectoryEntry>& entries, | 104 const std::vector<DirectoryEntry>& entries, |
| 105 bool has_more) { | 105 bool has_more) { |
| 106 if (result != base::PLATFORM_FILE_OK) { | 106 if (result != base::File::FILE_OK) { |
| 107 int rv = net::ERR_FILE_NOT_FOUND; | 107 int rv = net::ERR_FILE_NOT_FOUND; |
| 108 if (result == base::PLATFORM_FILE_ERROR_INVALID_URL) | 108 if (result == base::File::FILE_ERROR_INVALID_URL) |
| 109 rv = net::ERR_INVALID_URL; | 109 rv = net::ERR_INVALID_URL; |
| 110 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 110 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
| 111 return; | 111 return; |
| 112 } | 112 } |
| 113 | 113 |
| 114 if (!request_) | 114 if (!request_) |
| 115 return; | 115 return; |
| 116 | 116 |
| 117 if (data_.empty()) { | 117 if (data_.empty()) { |
| 118 base::FilePath relative_path = url_.path(); | 118 base::FilePath relative_path = url_.path(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 136 file_system_context_->operation_runner()->ReadDirectory( | 136 file_system_context_->operation_runner()->ReadDirectory( |
| 137 url_, | 137 url_, |
| 138 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); | 138 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); |
| 139 } else { | 139 } else { |
| 140 set_expected_content_size(data_.size()); | 140 set_expected_content_size(data_.size()); |
| 141 NotifyHeadersComplete(); | 141 NotifyHeadersComplete(); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace fileapi | 145 } // namespace fileapi |
| OLD | NEW |