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/obfuscated_file_system_file_util.h" | 5 #include "webkit/fileapi/obfuscated_file_system_file_util.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 base::PlatformFileInfo* file_info, | 167 base::PlatformFileInfo* file_info, |
168 FilePath* platform_file_path) { | 168 FilePath* platform_file_path) { |
169 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 169 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( |
170 context->src_origin_url(), context->src_type(), false); | 170 context->src_origin_url(), context->src_type(), false); |
171 if (!db) | 171 if (!db) |
172 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 172 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
173 FileId file_id; | 173 FileId file_id; |
174 if (!db->GetFileWithPath(virtual_path, &file_id)) | 174 if (!db->GetFileWithPath(virtual_path, &file_id)) |
175 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 175 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
176 FileInfo local_info; | 176 FileInfo local_info; |
177 if (!db->GetFileInfo(file_id, &local_info)) { | 177 if (!db->GetFileInfo(file_id, &local_info)) { |
kinuko
2011/07/13 07:56:51
Maybe this part could also be included into the fa
tzik
2011/07/13 08:30:44
Done.
| |
178 NOTREACHED(); | 178 NOTREACHED(); |
179 return base::PLATFORM_FILE_ERROR_FAILED; | 179 return base::PLATFORM_FILE_ERROR_FAILED; |
180 } | 180 } |
181 if (local_info.is_directory()) { | 181 return GetPlatformFileInfo(context, file_id, local_info, |
182 file_info->is_directory = true; | 182 file_info, platform_file_path); |
183 file_info->is_symbolic_link = false; | |
184 file_info->last_modified = local_info.modification_time; | |
185 *platform_file_path = FilePath(); | |
186 // We don't fill in ctime or atime. | |
187 return base::PLATFORM_FILE_OK; | |
188 } | |
189 if (local_info.data_path.empty()) | |
190 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; | |
191 FilePath data_path = DataPathToLocalPath(context->src_origin_url(), | |
192 context->src_type(), local_info.data_path); | |
193 return underlying_file_util_->GetFileInfo( | |
194 context, data_path, file_info, platform_file_path); | |
195 } | 183 } |
196 | 184 |
197 PlatformFileError ObfuscatedFileSystemFileUtil::ReadDirectory( | 185 PlatformFileError ObfuscatedFileSystemFileUtil::ReadDirectory( |
198 FileSystemOperationContext* context, | 186 FileSystemOperationContext* context, |
199 const FilePath& virtual_path, | 187 const FilePath& virtual_path, |
200 std::vector<base::FileUtilProxy::Entry>* entries) { | 188 std::vector<base::FileUtilProxy::Entry>* entries) { |
201 // TODO(kkanetkar): Implement directory read in multiple chunks. | 189 // TODO(kkanetkar): Implement directory read in multiple chunks. |
202 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 190 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( |
203 context->src_origin_url(), context->src_type(), false); | 191 context->src_origin_url(), context->src_type(), false); |
204 if (!db) { | 192 if (!db) { |
(...skipping 20 matching lines...) Expand all Loading... | |
225 if (!db->ListChildren(file_id, &children)) { | 213 if (!db->ListChildren(file_id, &children)) { |
226 NOTREACHED(); | 214 NOTREACHED(); |
227 return base::PLATFORM_FILE_ERROR_FAILED; | 215 return base::PLATFORM_FILE_ERROR_FAILED; |
228 } | 216 } |
229 std::vector<FileId>::iterator iter; | 217 std::vector<FileId>::iterator iter; |
230 for (iter = children.begin(); iter != children.end(); ++iter) { | 218 for (iter = children.begin(); iter != children.end(); ++iter) { |
231 if (!db->GetFileInfo(*iter, &file_info)) { | 219 if (!db->GetFileInfo(*iter, &file_info)) { |
232 NOTREACHED(); | 220 NOTREACHED(); |
233 return base::PLATFORM_FILE_ERROR_FAILED; | 221 return base::PLATFORM_FILE_ERROR_FAILED; |
234 } | 222 } |
223 | |
224 base::PlatformFileInfo platform_file_info; | |
225 FilePath file_path; | |
226 if (GetPlatformFileInfo(context, file_id, file_info, | |
227 &platform_file_info, &file_path) != | |
228 base::PLATFORM_FILE_OK) { | |
229 NOTREACHED(); | |
230 return base::PLATFORM_FILE_ERROR_FAILED; | |
231 } | |
232 | |
235 base::FileUtilProxy::Entry entry; | 233 base::FileUtilProxy::Entry entry; |
236 entry.name = file_info.name; | 234 entry.name = file_info.name; |
237 entry.is_directory = file_info.is_directory(); | 235 entry.is_directory = file_info.is_directory(); |
236 entry.size = entry.is_directory ? 0 : platform_file_info.size; | |
237 entry.last_modified_time = platform_file_info.last_modified; | |
238 entries->push_back(entry); | 238 entries->push_back(entry); |
239 } | 239 } |
240 return base::PLATFORM_FILE_OK; | 240 return base::PLATFORM_FILE_OK; |
241 } | 241 } |
242 | 242 |
243 PlatformFileError ObfuscatedFileSystemFileUtil::CreateDirectory( | 243 PlatformFileError ObfuscatedFileSystemFileUtil::CreateDirectory( |
244 FileSystemOperationContext* context, | 244 FileSystemOperationContext* context, |
245 const FilePath& virtual_path, | 245 const FilePath& virtual_path, |
246 bool exclusive, | 246 bool exclusive, |
247 bool recursive) { | 247 bool recursive) { |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 ObfuscatedFileSystemFileUtil::CreateFileEnumerator( | 714 ObfuscatedFileSystemFileUtil::CreateFileEnumerator( |
715 FileSystemOperationContext* context, | 715 FileSystemOperationContext* context, |
716 const FilePath& root_path) { | 716 const FilePath& root_path) { |
717 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 717 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( |
718 context->src_origin_url(), context->src_type(), false); | 718 context->src_origin_url(), context->src_type(), false); |
719 if (!db) | 719 if (!db) |
720 return new FileSystemFileUtil::EmptyFileEnumerator(); | 720 return new FileSystemFileUtil::EmptyFileEnumerator(); |
721 return new ObfuscatedFileSystemFileEnumerator(db, root_path); | 721 return new ObfuscatedFileSystemFileEnumerator(db, root_path); |
722 } | 722 } |
723 | 723 |
724 PlatformFileError ObfuscatedFileSystemFileUtil::GetPlatformFileInfo( | |
kinuko
2011/07/13 07:56:51
This naming may be confusing as it could be return
tzik
2011/07/13 08:30:44
Done.
| |
725 FileSystemOperationContext* context, | |
726 FileId file_id, | |
727 const FileInfo& local_info, | |
728 base::PlatformFileInfo* file_info, | |
729 FilePath* platform_file_path) { | |
730 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | |
kinuko
2011/07/13 07:56:51
Can we pass this pointer as a parameter? (Actuall
tzik
2011/07/13 08:30:44
Done.
| |
731 context->src_origin_url(), context->src_type(), false); | |
732 if (!db) | |
733 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | |
734 if (local_info.is_directory()) { | |
735 file_info->is_directory = true; | |
736 file_info->is_symbolic_link = false; | |
737 file_info->last_modified = local_info.modification_time; | |
738 *platform_file_path = FilePath(); | |
739 // We don't fill in ctime or atime. | |
740 return base::PLATFORM_FILE_OK; | |
741 } | |
742 if (local_info.data_path.empty()) | |
743 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; | |
744 FilePath data_path = DataPathToLocalPath(context->src_origin_url(), | |
745 context->src_type(), local_info.data_path); | |
746 return underlying_file_util_->GetFileInfo( | |
747 context, data_path, file_info, platform_file_path); | |
748 } | |
749 | |
724 PlatformFileError ObfuscatedFileSystemFileUtil::CreateFile( | 750 PlatformFileError ObfuscatedFileSystemFileUtil::CreateFile( |
725 FileSystemOperationContext* context, | 751 FileSystemOperationContext* context, |
726 const GURL& origin_url, FileSystemType type, const FilePath& source_path, | 752 const GURL& origin_url, FileSystemType type, const FilePath& source_path, |
727 FileInfo* file_info, int file_flags, PlatformFile* handle) { | 753 FileInfo* file_info, int file_flags, PlatformFile* handle) { |
728 if (handle) | 754 if (handle) |
729 *handle = base::kInvalidPlatformFileValue; | 755 *handle = base::kInvalidPlatformFileValue; |
730 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( | 756 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( |
731 origin_url, type, true); | 757 origin_url, type, true); |
732 int64 number; | 758 int64 number; |
733 if (!db || !db->GetNextInteger(&number)) | 759 if (!db || !db->GetNextInteger(&number)) |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1047 return false; | 1073 return false; |
1048 } | 1074 } |
1049 origin_database_.reset( | 1075 origin_database_.reset( |
1050 new FileSystemOriginDatabase( | 1076 new FileSystemOriginDatabase( |
1051 file_system_directory_.AppendASCII(kOriginDatabaseName))); | 1077 file_system_directory_.AppendASCII(kOriginDatabaseName))); |
1052 } | 1078 } |
1053 return true; | 1079 return true; |
1054 } | 1080 } |
1055 | 1081 |
1056 } // namespace fileapi | 1082 } // namespace fileapi |
OLD | NEW |