Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Side by Side Diff: webkit/fileapi/local_file_util.cc

Issue 13165005: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge, fixes Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/fileapi/isolated_file_util_unittest.cc ('k') | webkit/fileapi/native_file_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/local_file_util.h" 5 #include "webkit/fileapi/local_file_util.h"
6 6
7 #include "base/files/file_enumerator.h"
7 #include "base/files/file_util_proxy.h" 8 #include "base/files/file_util_proxy.h"
8 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
9 #include "webkit/fileapi/file_system_context.h" 10 #include "webkit/fileapi/file_system_context.h"
10 #include "webkit/fileapi/file_system_mount_point_provider.h" 11 #include "webkit/fileapi/file_system_mount_point_provider.h"
11 #include "webkit/fileapi/file_system_operation_context.h" 12 #include "webkit/fileapi/file_system_operation_context.h"
12 #include "webkit/fileapi/file_system_types.h" 13 #include "webkit/fileapi/file_system_types.h"
13 #include "webkit/fileapi/file_system_url.h" 14 #include "webkit/fileapi/file_system_url.h"
14 #include "webkit/fileapi/file_system_util.h" 15 #include "webkit/fileapi/file_system_util.h"
15 #include "webkit/fileapi/native_file_util.h" 16 #include "webkit/fileapi/native_file_util.h"
16 17
(...skipping 15 matching lines...) Expand all
32 } 33 }
33 34
34 virtual ~LocalFileEnumerator() {} 35 virtual ~LocalFileEnumerator() {}
35 36
36 virtual base::FilePath Next() OVERRIDE; 37 virtual base::FilePath Next() OVERRIDE;
37 virtual int64 Size() OVERRIDE; 38 virtual int64 Size() OVERRIDE;
38 virtual base::Time LastModifiedTime() OVERRIDE; 39 virtual base::Time LastModifiedTime() OVERRIDE;
39 virtual bool IsDirectory() OVERRIDE; 40 virtual bool IsDirectory() OVERRIDE;
40 41
41 private: 42 private:
42 file_util::FileEnumerator file_enum_; 43 base::FileEnumerator file_enum_;
43 file_util::FileEnumerator::FindInfo file_util_info_; 44 base::FileEnumerator::FileInfo file_util_info_;
44 base::FilePath platform_root_path_; 45 base::FilePath platform_root_path_;
45 base::FilePath virtual_root_path_; 46 base::FilePath virtual_root_path_;
46 }; 47 };
47 48
48 base::FilePath LocalFileEnumerator::Next() { 49 base::FilePath LocalFileEnumerator::Next() {
49 base::FilePath next = file_enum_.Next(); 50 base::FilePath next = file_enum_.Next();
50 // Don't return symlinks. 51 // Don't return symlinks.
51 while (!next.empty() && file_util::IsLink(next)) 52 while (!next.empty() && file_util::IsLink(next))
52 next = file_enum_.Next(); 53 next = file_enum_.Next();
53 if (next.empty()) 54 if (next.empty())
54 return next; 55 return next;
55 file_enum_.GetFindInfo(&file_util_info_); 56 file_util_info_ = file_enum_.GetInfo();
56 57
57 base::FilePath path; 58 base::FilePath path;
58 platform_root_path_.AppendRelativePath(next, &path); 59 platform_root_path_.AppendRelativePath(next, &path);
59 return virtual_root_path_.Append(path); 60 return virtual_root_path_.Append(path);
60 } 61 }
61 62
62 int64 LocalFileEnumerator::Size() { 63 int64 LocalFileEnumerator::Size() {
63 return file_util::FileEnumerator::GetFilesize(file_util_info_); 64 return file_util_info_.GetSize();
64 } 65 }
65 66
66 base::Time LocalFileEnumerator::LastModifiedTime() { 67 base::Time LocalFileEnumerator::LastModifiedTime() {
67 return file_util::FileEnumerator::GetLastModifiedTime(file_util_info_); 68 return file_util_info_.GetLastModifiedTime();
68 } 69 }
69 70
70 bool LocalFileEnumerator::IsDirectory() { 71 bool LocalFileEnumerator::IsDirectory() {
71 return file_util::FileEnumerator::IsDirectory(file_util_info_); 72 return file_util_info_.IsDirectory();
72 } 73 }
73 74
74 LocalFileUtil::LocalFileUtil() { 75 LocalFileUtil::LocalFileUtil() {
75 } 76 }
76 77
77 LocalFileUtil::~LocalFileUtil() { 78 LocalFileUtil::~LocalFileUtil() {
78 } 79 }
79 80
80 PlatformFileError LocalFileUtil::CreateOrOpen( 81 PlatformFileError LocalFileUtil::CreateOrOpen(
81 FileSystemOperationContext* context, 82 FileSystemOperationContext* context,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 FileSystemOperationContext* context, 145 FileSystemOperationContext* context,
145 const FileSystemURL& root_url) { 146 const FileSystemURL& root_url) {
146 base::FilePath file_path; 147 base::FilePath file_path;
147 if (GetLocalFilePath(context, root_url, &file_path) != 148 if (GetLocalFilePath(context, root_url, &file_path) !=
148 base::PLATFORM_FILE_OK) { 149 base::PLATFORM_FILE_OK) {
149 return make_scoped_ptr(new EmptyFileEnumerator) 150 return make_scoped_ptr(new EmptyFileEnumerator)
150 .PassAs<FileSystemFileUtil::AbstractFileEnumerator>(); 151 .PassAs<FileSystemFileUtil::AbstractFileEnumerator>();
151 } 152 }
152 return make_scoped_ptr(new LocalFileEnumerator( 153 return make_scoped_ptr(new LocalFileEnumerator(
153 file_path, root_url.path(), 154 file_path, root_url.path(),
154 file_util::FileEnumerator::FILES | 155 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES))
155 file_util::FileEnumerator::DIRECTORIES))
156 .PassAs<FileSystemFileUtil::AbstractFileEnumerator>(); 156 .PassAs<FileSystemFileUtil::AbstractFileEnumerator>();
157 } 157 }
158 158
159 PlatformFileError LocalFileUtil::GetLocalFilePath( 159 PlatformFileError LocalFileUtil::GetLocalFilePath(
160 FileSystemOperationContext* context, 160 FileSystemOperationContext* context,
161 const FileSystemURL& url, 161 const FileSystemURL& url,
162 base::FilePath* local_file_path) { 162 base::FilePath* local_file_path) {
163 FileSystemMountPointProvider* provider = 163 FileSystemMountPointProvider* provider =
164 context->file_system_context()->GetMountPointProvider(url.type()); 164 context->file_system_context()->GetMountPointProvider(url.type());
165 DCHECK(provider); 165 DCHECK(provider);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 base::FilePath* platform_path) { 254 base::FilePath* platform_path) {
255 DCHECK(file_info); 255 DCHECK(file_info);
256 // We're just returning the local file information. 256 // We're just returning the local file information.
257 *error = GetFileInfo(context, url, file_info, platform_path); 257 *error = GetFileInfo(context, url, file_info, platform_path);
258 if (*error == base::PLATFORM_FILE_OK && file_info->is_directory) 258 if (*error == base::PLATFORM_FILE_OK && file_info->is_directory)
259 *error = base::PLATFORM_FILE_ERROR_NOT_A_FILE; 259 *error = base::PLATFORM_FILE_ERROR_NOT_A_FILE;
260 return webkit_blob::ScopedFile(); 260 return webkit_blob::ScopedFile();
261 } 261 }
262 262
263 } // namespace fileapi 263 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/isolated_file_util_unittest.cc ('k') | webkit/fileapi/native_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698