Chromium Code Reviews| 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/local_file_system_file_util.h" | 5 #include "webkit/fileapi/local_file_system_file_util.h" |
| 6 | 6 |
| 7 #include "base/file_util_proxy.h" | 7 #include "base/file_util_proxy.h" |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #include "webkit/fileapi/file_system_context.h" | 9 #include "webkit/fileapi/file_system_context.h" |
| 10 #include "webkit/fileapi/file_system_operation_context.h" | 10 #include "webkit/fileapi/file_system_operation_context.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 const FilePath& virtual_root_path, | 234 const FilePath& virtual_root_path, |
| 235 bool recursive, | 235 bool recursive, |
| 236 file_util::FileEnumerator::FileType file_type) | 236 file_util::FileEnumerator::FileType file_type) |
| 237 : file_enum_(platform_root_path, recursive, file_type), | 237 : file_enum_(platform_root_path, recursive, file_type), |
| 238 platform_root_path_(platform_root_path), | 238 platform_root_path_(platform_root_path), |
| 239 virtual_root_path_(virtual_root_path) { | 239 virtual_root_path_(virtual_root_path) { |
| 240 } | 240 } |
| 241 | 241 |
| 242 ~LocalFileSystemFileEnumerator() {} | 242 ~LocalFileSystemFileEnumerator() {} |
| 243 | 243 |
| 244 virtual FilePath Next(); | 244 virtual FilePath Next() OVERRIDE; |
| 245 virtual bool IsDirectory(); | 245 virtual int64 Size() OVERRIDE; |
| 246 virtual bool IsDirectory() OVERRIDE; | |
| 246 | 247 |
| 247 private: | 248 private: |
| 248 file_util::FileEnumerator file_enum_; | 249 file_util::FileEnumerator file_enum_; |
| 249 FilePath platform_root_path_; | 250 FilePath platform_root_path_; |
| 250 FilePath virtual_root_path_; | 251 FilePath virtual_root_path_; |
| 251 }; | 252 }; |
| 252 | 253 |
| 253 FilePath LocalFileSystemFileEnumerator::Next() { | 254 FilePath LocalFileSystemFileEnumerator::Next() { |
| 254 FilePath next = file_enum_.Next(); | 255 FilePath next = file_enum_.Next(); |
| 255 if (next.empty()) | 256 if (next.empty()) |
| 256 return next; | 257 return next; |
| 257 | 258 |
| 258 FilePath path; | 259 FilePath path; |
| 259 platform_root_path_.AppendRelativePath(next, &path); | 260 platform_root_path_.AppendRelativePath(next, &path); |
| 260 return virtual_root_path_.Append(path); | 261 return virtual_root_path_.Append(path); |
| 261 } | 262 } |
| 262 | 263 |
| 264 int64 LocalFileSystemFileEnumerator::Size() { | |
| 265 file_util::FileEnumerator::FindInfo file_util_info; | |
|
ericu
2011/08/25 18:29:30
Is there any reason that we shouldn't cache the re
tzik
2011/08/26 02:41:53
Done. No reason other than making the patch small
| |
| 266 file_enum_.GetFindInfo(&file_util_info); | |
| 267 return file_util::FileEnumerator::GetFilesize(file_util_info); | |
| 268 } | |
| 269 | |
| 263 bool LocalFileSystemFileEnumerator::IsDirectory() { | 270 bool LocalFileSystemFileEnumerator::IsDirectory() { |
| 264 file_util::FileEnumerator::FindInfo file_util_info; | 271 file_util::FileEnumerator::FindInfo file_util_info; |
| 265 file_enum_.GetFindInfo(&file_util_info); | 272 file_enum_.GetFindInfo(&file_util_info); |
| 266 return file_util::FileEnumerator::IsDirectory(file_util_info); | 273 return file_util::FileEnumerator::IsDirectory(file_util_info); |
| 267 } | 274 } |
| 268 | 275 |
| 269 FileSystemFileUtil::AbstractFileEnumerator* | 276 FileSystemFileUtil::AbstractFileEnumerator* |
| 270 LocalFileSystemFileUtil::CreateFileEnumerator( | 277 LocalFileSystemFileUtil::CreateFileEnumerator( |
| 271 FileSystemOperationContext* context, | 278 FileSystemOperationContext* context, |
| 272 const FilePath& root_path) { | 279 const FilePath& root_path) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 289 const FilePath& virtual_path) { | 296 const FilePath& virtual_path) { |
| 290 FilePath root = context->file_system_context()->path_manager()-> | 297 FilePath root = context->file_system_context()->path_manager()-> |
| 291 ValidateFileSystemRootAndGetPathOnFileThread(origin_url, type, | 298 ValidateFileSystemRootAndGetPathOnFileThread(origin_url, type, |
| 292 virtual_path, false); | 299 virtual_path, false); |
| 293 if (root.empty()) | 300 if (root.empty()) |
| 294 return FilePath(); | 301 return FilePath(); |
| 295 return root.Append(virtual_path); | 302 return root.Append(virtual_path); |
| 296 } | 303 } |
| 297 | 304 |
| 298 } // namespace fileapi | 305 } // namespace fileapi |
| OLD | NEW |