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

Side by Side Diff: webkit/fileapi/media/device_media_file_util.cc

Issue 11960003: Cleanup: Move more recursive operation logic from FileUtilHelper to FileUtil (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
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/media/device_media_file_util.h" 5 #include "webkit/fileapi/media/device_media_file_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "webkit/fileapi/file_system_operation_context.h" 9 #include "webkit/fileapi/file_system_operation_context.h"
10 #include "webkit/fileapi/file_system_url.h" 10 #include "webkit/fileapi/file_system_url.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 bool exclusive, 63 bool exclusive,
64 bool recursive) { 64 bool recursive) {
65 return base::PLATFORM_FILE_ERROR_SECURITY; 65 return base::PLATFORM_FILE_ERROR_SECURITY;
66 } 66 }
67 67
68 PlatformFileError DeviceMediaFileUtil::GetFileInfo( 68 PlatformFileError DeviceMediaFileUtil::GetFileInfo(
69 FileSystemOperationContext* context, 69 FileSystemOperationContext* context,
70 const FileSystemURL& url, 70 const FileSystemURL& url,
71 PlatformFileInfo* file_info, 71 PlatformFileInfo* file_info,
72 FilePath* platform_path) { 72 FilePath* platform_path) {
73 DCHECK(file_info);
73 MTPDeviceDelegate* delegate = GetMTPDeviceDelegate(context); 74 MTPDeviceDelegate* delegate = GetMTPDeviceDelegate(context);
74 if (!delegate) 75 if (!delegate)
75 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 76 return base::PLATFORM_FILE_ERROR_NOT_FOUND;
76 77
77 PlatformFileError error = delegate->GetFileInfo(url.path(), file_info); 78 PlatformFileError error = delegate->GetFileInfo(url.path(), file_info);
78 if (error != base::PLATFORM_FILE_OK) 79 if (error != base::PLATFORM_FILE_OK)
79 return error; 80 return error;
81 if (file_info->is_directory)
82 return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
tzik 2013/01/21 07:10:41 Don't we support directory for DeviceMedia?
kinuko 2013/01/21 07:57:55 No, I needed to make this change in CreateSnapshot
80 83
81 if (file_info->is_directory || 84 if (file_info->is_directory ||
82 context->media_path_filter()->Match(url.path())) 85 context->media_path_filter()->Match(url.path()))
83 return base::PLATFORM_FILE_OK; 86 return base::PLATFORM_FILE_OK;
84 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 87 return base::PLATFORM_FILE_ERROR_NOT_FOUND;
85 } 88 }
86 89
87 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> 90 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator>
88 DeviceMediaFileUtil::CreateFileEnumerator( 91 DeviceMediaFileUtil::CreateFileEnumerator(
89 FileSystemOperationContext* context, 92 FileSystemOperationContext* context,
(...skipping 25 matching lines...) Expand all
115 return base::PLATFORM_FILE_ERROR_FAILED; 118 return base::PLATFORM_FILE_ERROR_FAILED;
116 } 119 }
117 120
118 PlatformFileError DeviceMediaFileUtil::Truncate( 121 PlatformFileError DeviceMediaFileUtil::Truncate(
119 FileSystemOperationContext* context, 122 FileSystemOperationContext* context,
120 const FileSystemURL& url, 123 const FileSystemURL& url,
121 int64 length) { 124 int64 length) {
122 return base::PLATFORM_FILE_ERROR_FAILED; 125 return base::PLATFORM_FILE_ERROR_FAILED;
123 } 126 }
124 127
125 bool DeviceMediaFileUtil::IsDirectoryEmpty(
126 FileSystemOperationContext* context,
127 const FileSystemURL& url) {
128 MTPDeviceDelegate* delegate = GetMTPDeviceDelegate(context);
129 if (!delegate)
130 return false;
131
132 scoped_ptr<AbstractFileEnumerator> enumerator(
133 CreateFileEnumerator(context, url, false));
134 FilePath path;
135 while (!(path = enumerator->Next()).empty()) {
136 if (enumerator->IsDirectory() ||
137 context->media_path_filter()->Match(path))
138 return false;
139 }
140 return true;
141 }
142
143 PlatformFileError DeviceMediaFileUtil::CopyOrMoveFile( 128 PlatformFileError DeviceMediaFileUtil::CopyOrMoveFile(
144 FileSystemOperationContext* context, 129 FileSystemOperationContext* context,
145 const FileSystemURL& src_url, 130 const FileSystemURL& src_url,
146 const FileSystemURL& dest_url, 131 const FileSystemURL& dest_url,
147 bool copy) { 132 bool copy) {
148 return base::PLATFORM_FILE_ERROR_SECURITY; 133 return base::PLATFORM_FILE_ERROR_SECURITY;
149 } 134 }
150 135
151 PlatformFileError DeviceMediaFileUtil::CopyInForeignFile( 136 PlatformFileError DeviceMediaFileUtil::CopyInForeignFile(
152 FileSystemOperationContext* context, 137 FileSystemOperationContext* context,
153 const FilePath& src_file_path, 138 const FilePath& src_file_path,
154 const FileSystemURL& dest_url) { 139 const FileSystemURL& dest_url) {
155 return base::PLATFORM_FILE_ERROR_SECURITY; 140 return base::PLATFORM_FILE_ERROR_SECURITY;
156 } 141 }
157 142
158 PlatformFileError DeviceMediaFileUtil::DeleteFile( 143 PlatformFileError DeviceMediaFileUtil::DeleteFile(
159 FileSystemOperationContext* context, 144 FileSystemOperationContext* context,
160 const FileSystemURL& url) { 145 const FileSystemURL& url) {
161 return base::PLATFORM_FILE_ERROR_SECURITY; 146 return base::PLATFORM_FILE_ERROR_SECURITY;
162 } 147 }
163 148
164 PlatformFileError DeviceMediaFileUtil::DeleteSingleDirectory( 149 PlatformFileError DeviceMediaFileUtil::DeleteDirectory(
165 FileSystemOperationContext* context, 150 FileSystemOperationContext* context,
166 const FileSystemURL& url) { 151 const FileSystemURL& url) {
167 return base::PLATFORM_FILE_ERROR_SECURITY; 152 return base::PLATFORM_FILE_ERROR_SECURITY;
168 } 153 }
169 154
170 base::PlatformFileError DeviceMediaFileUtil::CreateSnapshotFile( 155 base::PlatformFileError DeviceMediaFileUtil::CreateSnapshotFile(
171 FileSystemOperationContext* context, 156 FileSystemOperationContext* context,
172 const FileSystemURL& url, 157 const FileSystemURL& url,
173 base::PlatformFileInfo* file_info, 158 base::PlatformFileInfo* file_info,
174 FilePath* local_path, 159 FilePath* local_path,
(...skipping 24 matching lines...) Expand all
199 isolated_media_file_system_dir_path, local_path); 184 isolated_media_file_system_dir_path, local_path);
200 if (!file_created) { 185 if (!file_created) {
201 LOG(WARNING) << "Could not create a temporary file for media snapshot in " 186 LOG(WARNING) << "Could not create a temporary file for media snapshot in "
202 << isolated_media_file_system_dir_path.value(); 187 << isolated_media_file_system_dir_path.value();
203 return base::PLATFORM_FILE_ERROR_FAILED; 188 return base::PLATFORM_FILE_ERROR_FAILED;
204 } 189 }
205 return delegate->CreateSnapshotFile(url.path(), *local_path, file_info); 190 return delegate->CreateSnapshotFile(url.path(), *local_path, file_info);
206 } 191 }
207 192
208 } // namespace fileapi 193 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698