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

Side by Side Diff: chrome/browser/media_galleries/fileapi/native_media_file_util.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 "chrome/browser/media_galleries/fileapi/native_media_file_util.h" 5 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_enumerator.h" 12 #include "base/files/file_enumerator.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/task_runner_util.h" 14 #include "base/task_runner_util.h"
15 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" 15 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "net/base/io_buffer.h" 17 #include "net/base/io_buffer.h"
18 #include "net/base/mime_sniffer.h" 18 #include "net/base/mime_sniffer.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 #include "webkit/browser/fileapi/file_system_context.h" 20 #include "storage/browser/fileapi/file_system_context.h"
21 #include "webkit/browser/fileapi/file_system_operation_context.h" 21 #include "storage/browser/fileapi/file_system_operation_context.h"
22 #include "webkit/browser/fileapi/native_file_util.h" 22 #include "storage/browser/fileapi/native_file_util.h"
23 #include "webkit/common/blob/shareable_file_reference.h" 23 #include "storage/common/blob/shareable_file_reference.h"
24 24
25 namespace { 25 namespace {
26 26
27 // Returns true if the current thread is capable of doing IO. 27 // Returns true if the current thread is capable of doing IO.
28 bool IsOnTaskRunnerThread(fileapi::FileSystemOperationContext* context) { 28 bool IsOnTaskRunnerThread(storage::FileSystemOperationContext* context) {
29 return context->task_runner()->RunsTasksOnCurrentThread(); 29 return context->task_runner()->RunsTasksOnCurrentThread();
30 } 30 }
31 31
32 base::File::Error IsMediaHeader(const char* buf, size_t length) { 32 base::File::Error IsMediaHeader(const char* buf, size_t length) {
33 if (length == 0) 33 if (length == 0)
34 return base::File::FILE_ERROR_SECURITY; 34 return base::File::FILE_ERROR_SECURITY;
35 35
36 std::string mime_type; 36 std::string mime_type;
37 if (!net::SniffMimeTypeFromLocalData(buf, length, &mime_type)) 37 if (!net::SniffMimeTypeFromLocalData(buf, length, &mime_type))
38 return base::File::FILE_ERROR_SECURITY; 38 return base::File::FILE_ERROR_SECURITY;
39 39
40 if (StartsWithASCII(mime_type, "image/", true) || 40 if (StartsWithASCII(mime_type, "image/", true) ||
41 StartsWithASCII(mime_type, "audio/", true) || 41 StartsWithASCII(mime_type, "audio/", true) ||
42 StartsWithASCII(mime_type, "video/", true) || 42 StartsWithASCII(mime_type, "video/", true) ||
43 mime_type == "application/x-shockwave-flash") { 43 mime_type == "application/x-shockwave-flash") {
44 return base::File::FILE_OK; 44 return base::File::FILE_OK;
45 } 45 }
46 return base::File::FILE_ERROR_SECURITY; 46 return base::File::FILE_ERROR_SECURITY;
47 } 47 }
48 48
49 void HoldFileRef( 49 void HoldFileRef(
50 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { 50 const scoped_refptr<storage::ShareableFileReference>& file_ref) {
51 } 51 }
52 52
53 void DidOpenSnapshot( 53 void DidOpenSnapshot(
54 const fileapi::AsyncFileUtil::CreateOrOpenCallback& callback, 54 const storage::AsyncFileUtil::CreateOrOpenCallback& callback,
55 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref, 55 const scoped_refptr<storage::ShareableFileReference>& file_ref,
56 base::File file) { 56 base::File file) {
57 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 57 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
58 if (!file.IsValid()) { 58 if (!file.IsValid()) {
59 callback.Run(file.Pass(), base::Closure()); 59 callback.Run(file.Pass(), base::Closure());
60 return; 60 return;
61 } 61 }
62 callback.Run(file.Pass(), base::Bind(&HoldFileRef, file_ref)); 62 callback.Run(file.Pass(), base::Bind(&HoldFileRef, file_ref));
63 } 63 }
64 64
65 } // namespace 65 } // namespace
(...skipping 26 matching lines...) Expand all
92 // static 92 // static
93 base::File::Error NativeMediaFileUtil::BufferIsMediaHeader( 93 base::File::Error NativeMediaFileUtil::BufferIsMediaHeader(
94 net::IOBuffer* buf, size_t length) { 94 net::IOBuffer* buf, size_t length) {
95 return IsMediaHeader(buf->data(), length); 95 return IsMediaHeader(buf->data(), length);
96 } 96 }
97 97
98 // static 98 // static
99 void NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen( 99 void NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen(
100 base::SequencedTaskRunner* media_task_runner, 100 base::SequencedTaskRunner* media_task_runner,
101 int file_flags, 101 int file_flags,
102 const fileapi::AsyncFileUtil::CreateOrOpenCallback& callback, 102 const storage::AsyncFileUtil::CreateOrOpenCallback& callback,
103 base::File::Error result, 103 base::File::Error result,
104 const base::File::Info& file_info, 104 const base::File::Info& file_info,
105 const base::FilePath& platform_path, 105 const base::FilePath& platform_path,
106 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { 106 const scoped_refptr<storage::ShareableFileReference>& file_ref) {
107 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 107 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
108 if (result != base::File::FILE_OK) { 108 if (result != base::File::FILE_OK) {
109 callback.Run(base::File(), base::Closure()); 109 callback.Run(base::File(), base::Closure());
110 return; 110 return;
111 } 111 }
112 base::PostTaskAndReplyWithResult( 112 base::PostTaskAndReplyWithResult(
113 media_task_runner, 113 media_task_runner,
114 FROM_HERE, 114 FROM_HERE,
115 base::Bind(&fileapi::NativeFileUtil::CreateOrOpen, 115 base::Bind(
116 platform_path, 116 &storage::NativeFileUtil::CreateOrOpen, platform_path, file_flags),
117 file_flags),
118 base::Bind(&DidOpenSnapshot, callback, file_ref)); 117 base::Bind(&DidOpenSnapshot, callback, file_ref));
119 } 118 }
120 119
121 void NativeMediaFileUtil::CreateOrOpen( 120 void NativeMediaFileUtil::CreateOrOpen(
122 scoped_ptr<fileapi::FileSystemOperationContext> context, 121 scoped_ptr<storage::FileSystemOperationContext> context,
123 const fileapi::FileSystemURL& url, 122 const storage::FileSystemURL& url,
124 int file_flags, 123 int file_flags,
125 const CreateOrOpenCallback& callback) { 124 const CreateOrOpenCallback& callback) {
126 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 125 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
127 // Returns an error if any unsupported flag is found. 126 // Returns an error if any unsupported flag is found.
128 if (file_flags & ~(base::File::FLAG_OPEN | 127 if (file_flags & ~(base::File::FLAG_OPEN |
129 base::File::FLAG_READ | 128 base::File::FLAG_READ |
130 base::File::FLAG_WRITE_ATTRIBUTES)) { 129 base::File::FLAG_WRITE_ATTRIBUTES)) {
131 callback.Run(base::File(base::File::FILE_ERROR_SECURITY), base::Closure()); 130 callback.Run(base::File(base::File::FILE_ERROR_SECURITY), base::Closure());
132 return; 131 return;
133 } 132 }
134 scoped_refptr<base::SequencedTaskRunner> task_runner = context->task_runner(); 133 scoped_refptr<base::SequencedTaskRunner> task_runner = context->task_runner();
135 CreateSnapshotFile( 134 CreateSnapshotFile(
136 context.Pass(), 135 context.Pass(),
137 url, 136 url,
138 base::Bind(&NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen, 137 base::Bind(&NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen,
139 task_runner, 138 task_runner,
140 file_flags, 139 file_flags,
141 callback)); 140 callback));
142 } 141 }
143 142
144 void NativeMediaFileUtil::EnsureFileExists( 143 void NativeMediaFileUtil::EnsureFileExists(
145 scoped_ptr<fileapi::FileSystemOperationContext> context, 144 scoped_ptr<storage::FileSystemOperationContext> context,
146 const fileapi::FileSystemURL& url, 145 const storage::FileSystemURL& url,
147 const EnsureFileExistsCallback& callback) { 146 const EnsureFileExistsCallback& callback) {
148 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 147 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
149 callback.Run(base::File::FILE_ERROR_SECURITY, false); 148 callback.Run(base::File::FILE_ERROR_SECURITY, false);
150 } 149 }
151 150
152 void NativeMediaFileUtil::CreateDirectory( 151 void NativeMediaFileUtil::CreateDirectory(
153 scoped_ptr<fileapi::FileSystemOperationContext> context, 152 scoped_ptr<storage::FileSystemOperationContext> context,
154 const fileapi::FileSystemURL& url, 153 const storage::FileSystemURL& url,
155 bool exclusive, 154 bool exclusive,
156 bool recursive, 155 bool recursive,
157 const StatusCallback& callback) { 156 const StatusCallback& callback) {
158 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 157 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
159 fileapi::FileSystemOperationContext* context_ptr = context.get(); 158 storage::FileSystemOperationContext* context_ptr = context.get();
160 const bool success = context_ptr->task_runner()->PostTask( 159 const bool success = context_ptr->task_runner()->PostTask(
161 FROM_HERE, 160 FROM_HERE,
162 base::Bind(&NativeMediaFileUtil::CreateDirectoryOnTaskRunnerThread, 161 base::Bind(&NativeMediaFileUtil::CreateDirectoryOnTaskRunnerThread,
163 weak_factory_.GetWeakPtr(), base::Passed(&context), 162 weak_factory_.GetWeakPtr(), base::Passed(&context),
164 url, exclusive, recursive, callback)); 163 url, exclusive, recursive, callback));
165 DCHECK(success); 164 DCHECK(success);
166 } 165 }
167 166
168 void NativeMediaFileUtil::GetFileInfo( 167 void NativeMediaFileUtil::GetFileInfo(
169 scoped_ptr<fileapi::FileSystemOperationContext> context, 168 scoped_ptr<storage::FileSystemOperationContext> context,
170 const fileapi::FileSystemURL& url, 169 const storage::FileSystemURL& url,
171 const GetFileInfoCallback& callback) { 170 const GetFileInfoCallback& callback) {
172 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 171 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
173 fileapi::FileSystemOperationContext* context_ptr = context.get(); 172 storage::FileSystemOperationContext* context_ptr = context.get();
174 const bool success = context_ptr->task_runner()->PostTask( 173 const bool success = context_ptr->task_runner()->PostTask(
175 FROM_HERE, 174 FROM_HERE,
176 base::Bind(&NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread, 175 base::Bind(&NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread,
177 weak_factory_.GetWeakPtr(), base::Passed(&context), 176 weak_factory_.GetWeakPtr(), base::Passed(&context),
178 url, callback)); 177 url, callback));
179 DCHECK(success); 178 DCHECK(success);
180 } 179 }
181 180
182 void NativeMediaFileUtil::ReadDirectory( 181 void NativeMediaFileUtil::ReadDirectory(
183 scoped_ptr<fileapi::FileSystemOperationContext> context, 182 scoped_ptr<storage::FileSystemOperationContext> context,
184 const fileapi::FileSystemURL& url, 183 const storage::FileSystemURL& url,
185 const ReadDirectoryCallback& callback) { 184 const ReadDirectoryCallback& callback) {
186 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 185 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
187 fileapi::FileSystemOperationContext* context_ptr = context.get(); 186 storage::FileSystemOperationContext* context_ptr = context.get();
188 const bool success = context_ptr->task_runner()->PostTask( 187 const bool success = context_ptr->task_runner()->PostTask(
189 FROM_HERE, 188 FROM_HERE,
190 base::Bind(&NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread, 189 base::Bind(&NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread,
191 weak_factory_.GetWeakPtr(), base::Passed(&context), 190 weak_factory_.GetWeakPtr(), base::Passed(&context),
192 url, callback)); 191 url, callback));
193 DCHECK(success); 192 DCHECK(success);
194 } 193 }
195 194
196 void NativeMediaFileUtil::Touch( 195 void NativeMediaFileUtil::Touch(
197 scoped_ptr<fileapi::FileSystemOperationContext> context, 196 scoped_ptr<storage::FileSystemOperationContext> context,
198 const fileapi::FileSystemURL& url, 197 const storage::FileSystemURL& url,
199 const base::Time& last_access_time, 198 const base::Time& last_access_time,
200 const base::Time& last_modified_time, 199 const base::Time& last_modified_time,
201 const StatusCallback& callback) { 200 const StatusCallback& callback) {
202 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 201 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
203 callback.Run(base::File::FILE_ERROR_SECURITY); 202 callback.Run(base::File::FILE_ERROR_SECURITY);
204 } 203 }
205 204
206 void NativeMediaFileUtil::Truncate( 205 void NativeMediaFileUtil::Truncate(
207 scoped_ptr<fileapi::FileSystemOperationContext> context, 206 scoped_ptr<storage::FileSystemOperationContext> context,
208 const fileapi::FileSystemURL& url, 207 const storage::FileSystemURL& url,
209 int64 length, 208 int64 length,
210 const StatusCallback& callback) { 209 const StatusCallback& callback) {
211 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 210 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
212 callback.Run(base::File::FILE_ERROR_SECURITY); 211 callback.Run(base::File::FILE_ERROR_SECURITY);
213 } 212 }
214 213
215 void NativeMediaFileUtil::CopyFileLocal( 214 void NativeMediaFileUtil::CopyFileLocal(
216 scoped_ptr<fileapi::FileSystemOperationContext> context, 215 scoped_ptr<storage::FileSystemOperationContext> context,
217 const fileapi::FileSystemURL& src_url, 216 const storage::FileSystemURL& src_url,
218 const fileapi::FileSystemURL& dest_url, 217 const storage::FileSystemURL& dest_url,
219 CopyOrMoveOption option, 218 CopyOrMoveOption option,
220 const CopyFileProgressCallback& progress_callback, 219 const CopyFileProgressCallback& progress_callback,
221 const StatusCallback& callback) { 220 const StatusCallback& callback) {
222 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 221 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
223 fileapi::FileSystemOperationContext* context_ptr = context.get(); 222 storage::FileSystemOperationContext* context_ptr = context.get();
224 const bool success = context_ptr->task_runner()->PostTask( 223 const bool success = context_ptr->task_runner()->PostTask(
225 FROM_HERE, 224 FROM_HERE,
226 base::Bind(&NativeMediaFileUtil::CopyOrMoveFileLocalOnTaskRunnerThread, 225 base::Bind(&NativeMediaFileUtil::CopyOrMoveFileLocalOnTaskRunnerThread,
227 weak_factory_.GetWeakPtr(), base::Passed(&context), 226 weak_factory_.GetWeakPtr(), base::Passed(&context),
228 src_url, dest_url, option, true /* copy */, callback)); 227 src_url, dest_url, option, true /* copy */, callback));
229 DCHECK(success); 228 DCHECK(success);
230 } 229 }
231 230
232 void NativeMediaFileUtil::MoveFileLocal( 231 void NativeMediaFileUtil::MoveFileLocal(
233 scoped_ptr<fileapi::FileSystemOperationContext> context, 232 scoped_ptr<storage::FileSystemOperationContext> context,
234 const fileapi::FileSystemURL& src_url, 233 const storage::FileSystemURL& src_url,
235 const fileapi::FileSystemURL& dest_url, 234 const storage::FileSystemURL& dest_url,
236 CopyOrMoveOption option, 235 CopyOrMoveOption option,
237 const StatusCallback& callback) { 236 const StatusCallback& callback) {
238 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 237 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
239 fileapi::FileSystemOperationContext* context_ptr = context.get(); 238 storage::FileSystemOperationContext* context_ptr = context.get();
240 const bool success = context_ptr->task_runner()->PostTask( 239 const bool success = context_ptr->task_runner()->PostTask(
241 FROM_HERE, 240 FROM_HERE,
242 base::Bind(&NativeMediaFileUtil::CopyOrMoveFileLocalOnTaskRunnerThread, 241 base::Bind(&NativeMediaFileUtil::CopyOrMoveFileLocalOnTaskRunnerThread,
243 weak_factory_.GetWeakPtr(), base::Passed(&context), 242 weak_factory_.GetWeakPtr(), base::Passed(&context),
244 src_url, dest_url, option, false /* copy */, callback)); 243 src_url, dest_url, option, false /* copy */, callback));
245 DCHECK(success); 244 DCHECK(success);
246 } 245 }
247 246
248 void NativeMediaFileUtil::CopyInForeignFile( 247 void NativeMediaFileUtil::CopyInForeignFile(
249 scoped_ptr<fileapi::FileSystemOperationContext> context, 248 scoped_ptr<storage::FileSystemOperationContext> context,
250 const base::FilePath& src_file_path, 249 const base::FilePath& src_file_path,
251 const fileapi::FileSystemURL& dest_url, 250 const storage::FileSystemURL& dest_url,
252 const StatusCallback& callback) { 251 const StatusCallback& callback) {
253 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 252 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
254 fileapi::FileSystemOperationContext* context_ptr = context.get(); 253 storage::FileSystemOperationContext* context_ptr = context.get();
255 const bool success = context_ptr->task_runner()->PostTask( 254 const bool success = context_ptr->task_runner()->PostTask(
256 FROM_HERE, 255 FROM_HERE,
257 base::Bind(&NativeMediaFileUtil::CopyInForeignFileOnTaskRunnerThread, 256 base::Bind(&NativeMediaFileUtil::CopyInForeignFileOnTaskRunnerThread,
258 weak_factory_.GetWeakPtr(), base::Passed(&context), 257 weak_factory_.GetWeakPtr(), base::Passed(&context),
259 src_file_path, dest_url, callback)); 258 src_file_path, dest_url, callback));
260 DCHECK(success); 259 DCHECK(success);
261 } 260 }
262 261
263 void NativeMediaFileUtil::DeleteFile( 262 void NativeMediaFileUtil::DeleteFile(
264 scoped_ptr<fileapi::FileSystemOperationContext> context, 263 scoped_ptr<storage::FileSystemOperationContext> context,
265 const fileapi::FileSystemURL& url, 264 const storage::FileSystemURL& url,
266 const StatusCallback& callback) { 265 const StatusCallback& callback) {
267 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 266 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
268 fileapi::FileSystemOperationContext* context_ptr = context.get(); 267 storage::FileSystemOperationContext* context_ptr = context.get();
269 const bool success = context_ptr->task_runner()->PostTask( 268 const bool success = context_ptr->task_runner()->PostTask(
270 FROM_HERE, 269 FROM_HERE,
271 base::Bind(&NativeMediaFileUtil::DeleteFileOnTaskRunnerThread, 270 base::Bind(&NativeMediaFileUtil::DeleteFileOnTaskRunnerThread,
272 weak_factory_.GetWeakPtr(), base::Passed(&context), 271 weak_factory_.GetWeakPtr(), base::Passed(&context),
273 url, callback)); 272 url, callback));
274 DCHECK(success); 273 DCHECK(success);
275 } 274 }
276 275
277 // This is needed to support Copy and Move. 276 // This is needed to support Copy and Move.
278 void NativeMediaFileUtil::DeleteDirectory( 277 void NativeMediaFileUtil::DeleteDirectory(
279 scoped_ptr<fileapi::FileSystemOperationContext> context, 278 scoped_ptr<storage::FileSystemOperationContext> context,
280 const fileapi::FileSystemURL& url, 279 const storage::FileSystemURL& url,
281 const StatusCallback& callback) { 280 const StatusCallback& callback) {
282 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 281 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
283 fileapi::FileSystemOperationContext* context_ptr = context.get(); 282 storage::FileSystemOperationContext* context_ptr = context.get();
284 const bool success = context_ptr->task_runner()->PostTask( 283 const bool success = context_ptr->task_runner()->PostTask(
285 FROM_HERE, 284 FROM_HERE,
286 base::Bind(&NativeMediaFileUtil::DeleteDirectoryOnTaskRunnerThread, 285 base::Bind(&NativeMediaFileUtil::DeleteDirectoryOnTaskRunnerThread,
287 weak_factory_.GetWeakPtr(), base::Passed(&context), 286 weak_factory_.GetWeakPtr(), base::Passed(&context),
288 url, callback)); 287 url, callback));
289 DCHECK(success); 288 DCHECK(success);
290 } 289 }
291 290
292 void NativeMediaFileUtil::DeleteRecursively( 291 void NativeMediaFileUtil::DeleteRecursively(
293 scoped_ptr<fileapi::FileSystemOperationContext> context, 292 scoped_ptr<storage::FileSystemOperationContext> context,
294 const fileapi::FileSystemURL& url, 293 const storage::FileSystemURL& url,
295 const StatusCallback& callback) { 294 const StatusCallback& callback) {
296 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 295 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
297 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); 296 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
298 } 297 }
299 298
300 void NativeMediaFileUtil::CreateSnapshotFile( 299 void NativeMediaFileUtil::CreateSnapshotFile(
301 scoped_ptr<fileapi::FileSystemOperationContext> context, 300 scoped_ptr<storage::FileSystemOperationContext> context,
302 const fileapi::FileSystemURL& url, 301 const storage::FileSystemURL& url,
303 const CreateSnapshotFileCallback& callback) { 302 const CreateSnapshotFileCallback& callback) {
304 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 303 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
305 fileapi::FileSystemOperationContext* context_ptr = context.get(); 304 storage::FileSystemOperationContext* context_ptr = context.get();
306 const bool success = context_ptr->task_runner()->PostTask( 305 const bool success = context_ptr->task_runner()->PostTask(
307 FROM_HERE, 306 FROM_HERE,
308 base::Bind(&NativeMediaFileUtil::CreateSnapshotFileOnTaskRunnerThread, 307 base::Bind(&NativeMediaFileUtil::CreateSnapshotFileOnTaskRunnerThread,
309 weak_factory_.GetWeakPtr(), base::Passed(&context), 308 weak_factory_.GetWeakPtr(), base::Passed(&context),
310 url, callback)); 309 url, callback));
311 DCHECK(success); 310 DCHECK(success);
312 } 311 }
313 312
314 void NativeMediaFileUtil::CreateDirectoryOnTaskRunnerThread( 313 void NativeMediaFileUtil::CreateDirectoryOnTaskRunnerThread(
315 scoped_ptr<fileapi::FileSystemOperationContext> context, 314 scoped_ptr<storage::FileSystemOperationContext> context,
316 const fileapi::FileSystemURL& url, 315 const storage::FileSystemURL& url,
317 bool exclusive, 316 bool exclusive,
318 bool recursive, 317 bool recursive,
319 const StatusCallback& callback) { 318 const StatusCallback& callback) {
320 DCHECK(IsOnTaskRunnerThread(context.get())); 319 DCHECK(IsOnTaskRunnerThread(context.get()));
321 base::File::Error error = 320 base::File::Error error =
322 CreateDirectorySync(context.get(), url, exclusive, recursive); 321 CreateDirectorySync(context.get(), url, exclusive, recursive);
323 content::BrowserThread::PostTask( 322 content::BrowserThread::PostTask(
324 content::BrowserThread::IO, 323 content::BrowserThread::IO,
325 FROM_HERE, 324 FROM_HERE,
326 base::Bind(callback, error)); 325 base::Bind(callback, error));
327 } 326 }
328 327
329 void NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread( 328 void NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread(
330 scoped_ptr<fileapi::FileSystemOperationContext> context, 329 scoped_ptr<storage::FileSystemOperationContext> context,
331 const fileapi::FileSystemURL& url, 330 const storage::FileSystemURL& url,
332 const GetFileInfoCallback& callback) { 331 const GetFileInfoCallback& callback) {
333 DCHECK(IsOnTaskRunnerThread(context.get())); 332 DCHECK(IsOnTaskRunnerThread(context.get()));
334 base::File::Info file_info; 333 base::File::Info file_info;
335 base::File::Error error = 334 base::File::Error error =
336 GetFileInfoSync(context.get(), url, &file_info, NULL); 335 GetFileInfoSync(context.get(), url, &file_info, NULL);
337 content::BrowserThread::PostTask( 336 content::BrowserThread::PostTask(
338 content::BrowserThread::IO, 337 content::BrowserThread::IO,
339 FROM_HERE, 338 FROM_HERE,
340 base::Bind(callback, error, file_info)); 339 base::Bind(callback, error, file_info));
341 } 340 }
342 341
343 void NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread( 342 void NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread(
344 scoped_ptr<fileapi::FileSystemOperationContext> context, 343 scoped_ptr<storage::FileSystemOperationContext> context,
345 const fileapi::FileSystemURL& url, 344 const storage::FileSystemURL& url,
346 const ReadDirectoryCallback& callback) { 345 const ReadDirectoryCallback& callback) {
347 DCHECK(IsOnTaskRunnerThread(context.get())); 346 DCHECK(IsOnTaskRunnerThread(context.get()));
348 EntryList entry_list; 347 EntryList entry_list;
349 base::File::Error error = 348 base::File::Error error =
350 ReadDirectorySync(context.get(), url, &entry_list); 349 ReadDirectorySync(context.get(), url, &entry_list);
351 content::BrowserThread::PostTask( 350 content::BrowserThread::PostTask(
352 content::BrowserThread::IO, 351 content::BrowserThread::IO,
353 FROM_HERE, 352 FROM_HERE,
354 base::Bind(callback, error, entry_list, false /* has_more */)); 353 base::Bind(callback, error, entry_list, false /* has_more */));
355 } 354 }
356 355
357 void NativeMediaFileUtil::CopyOrMoveFileLocalOnTaskRunnerThread( 356 void NativeMediaFileUtil::CopyOrMoveFileLocalOnTaskRunnerThread(
358 scoped_ptr<fileapi::FileSystemOperationContext> context, 357 scoped_ptr<storage::FileSystemOperationContext> context,
359 const fileapi::FileSystemURL& src_url, 358 const storage::FileSystemURL& src_url,
360 const fileapi::FileSystemURL& dest_url, 359 const storage::FileSystemURL& dest_url,
361 CopyOrMoveOption option, 360 CopyOrMoveOption option,
362 bool copy, 361 bool copy,
363 const StatusCallback& callback) { 362 const StatusCallback& callback) {
364 DCHECK(IsOnTaskRunnerThread(context.get())); 363 DCHECK(IsOnTaskRunnerThread(context.get()));
365 base::File::Error error = 364 base::File::Error error =
366 CopyOrMoveFileSync(context.get(), src_url, dest_url, option, copy); 365 CopyOrMoveFileSync(context.get(), src_url, dest_url, option, copy);
367 content::BrowserThread::PostTask( 366 content::BrowserThread::PostTask(
368 content::BrowserThread::IO, 367 content::BrowserThread::IO,
369 FROM_HERE, 368 FROM_HERE,
370 base::Bind(callback, error)); 369 base::Bind(callback, error));
371 } 370 }
372 371
373 void NativeMediaFileUtil::CopyInForeignFileOnTaskRunnerThread( 372 void NativeMediaFileUtil::CopyInForeignFileOnTaskRunnerThread(
374 scoped_ptr<fileapi::FileSystemOperationContext> context, 373 scoped_ptr<storage::FileSystemOperationContext> context,
375 const base::FilePath& src_file_path, 374 const base::FilePath& src_file_path,
376 const fileapi::FileSystemURL& dest_url, 375 const storage::FileSystemURL& dest_url,
377 const StatusCallback& callback) { 376 const StatusCallback& callback) {
378 DCHECK(IsOnTaskRunnerThread(context.get())); 377 DCHECK(IsOnTaskRunnerThread(context.get()));
379 base::File::Error error = 378 base::File::Error error =
380 CopyInForeignFileSync(context.get(), src_file_path, dest_url); 379 CopyInForeignFileSync(context.get(), src_file_path, dest_url);
381 content::BrowserThread::PostTask( 380 content::BrowserThread::PostTask(
382 content::BrowserThread::IO, 381 content::BrowserThread::IO,
383 FROM_HERE, 382 FROM_HERE,
384 base::Bind(callback, error)); 383 base::Bind(callback, error));
385 } 384 }
386 385
387 void NativeMediaFileUtil::DeleteFileOnTaskRunnerThread( 386 void NativeMediaFileUtil::DeleteFileOnTaskRunnerThread(
388 scoped_ptr<fileapi::FileSystemOperationContext> context, 387 scoped_ptr<storage::FileSystemOperationContext> context,
389 const fileapi::FileSystemURL& url, 388 const storage::FileSystemURL& url,
390 const StatusCallback& callback) { 389 const StatusCallback& callback) {
391 DCHECK(IsOnTaskRunnerThread(context.get())); 390 DCHECK(IsOnTaskRunnerThread(context.get()));
392 base::File::Error error = DeleteFileSync(context.get(), url); 391 base::File::Error error = DeleteFileSync(context.get(), url);
393 content::BrowserThread::PostTask( 392 content::BrowserThread::PostTask(
394 content::BrowserThread::IO, 393 content::BrowserThread::IO,
395 FROM_HERE, 394 FROM_HERE,
396 base::Bind(callback, error)); 395 base::Bind(callback, error));
397 } 396 }
398 397
399 void NativeMediaFileUtil::DeleteDirectoryOnTaskRunnerThread( 398 void NativeMediaFileUtil::DeleteDirectoryOnTaskRunnerThread(
400 scoped_ptr<fileapi::FileSystemOperationContext> context, 399 scoped_ptr<storage::FileSystemOperationContext> context,
401 const fileapi::FileSystemURL& url, 400 const storage::FileSystemURL& url,
402 const StatusCallback& callback) { 401 const StatusCallback& callback) {
403 DCHECK(IsOnTaskRunnerThread(context.get())); 402 DCHECK(IsOnTaskRunnerThread(context.get()));
404 base::File::Error error = DeleteDirectorySync(context.get(), url); 403 base::File::Error error = DeleteDirectorySync(context.get(), url);
405 content::BrowserThread::PostTask( 404 content::BrowserThread::PostTask(
406 content::BrowserThread::IO, 405 content::BrowserThread::IO,
407 FROM_HERE, 406 FROM_HERE,
408 base::Bind(callback, error)); 407 base::Bind(callback, error));
409 } 408 }
410 409
411 void NativeMediaFileUtil::CreateSnapshotFileOnTaskRunnerThread( 410 void NativeMediaFileUtil::CreateSnapshotFileOnTaskRunnerThread(
412 scoped_ptr<fileapi::FileSystemOperationContext> context, 411 scoped_ptr<storage::FileSystemOperationContext> context,
413 const fileapi::FileSystemURL& url, 412 const storage::FileSystemURL& url,
414 const CreateSnapshotFileCallback& callback) { 413 const CreateSnapshotFileCallback& callback) {
415 DCHECK(IsOnTaskRunnerThread(context.get())); 414 DCHECK(IsOnTaskRunnerThread(context.get()));
416 base::File::Info file_info; 415 base::File::Info file_info;
417 base::FilePath platform_path; 416 base::FilePath platform_path;
418 scoped_refptr<webkit_blob::ShareableFileReference> file_ref; 417 scoped_refptr<storage::ShareableFileReference> file_ref;
419 base::File::Error error = CreateSnapshotFileSync( 418 base::File::Error error = CreateSnapshotFileSync(
420 context.get(), url, &file_info, &platform_path, &file_ref); 419 context.get(), url, &file_info, &platform_path, &file_ref);
421 content::BrowserThread::PostTask( 420 content::BrowserThread::PostTask(
422 content::BrowserThread::IO, 421 content::BrowserThread::IO,
423 FROM_HERE, 422 FROM_HERE,
424 base::Bind(callback, error, file_info, platform_path, file_ref)); 423 base::Bind(callback, error, file_info, platform_path, file_ref));
425 } 424 }
426 425
427 base::File::Error NativeMediaFileUtil::CreateDirectorySync( 426 base::File::Error NativeMediaFileUtil::CreateDirectorySync(
428 fileapi::FileSystemOperationContext* context, 427 storage::FileSystemOperationContext* context,
429 const fileapi::FileSystemURL& url, 428 const storage::FileSystemURL& url,
430 bool exclusive, 429 bool exclusive,
431 bool recursive) { 430 bool recursive) {
432 base::FilePath file_path; 431 base::FilePath file_path;
433 base::File::Error error = GetLocalFilePath(context, url, &file_path); 432 base::File::Error error = GetLocalFilePath(context, url, &file_path);
434 if (error != base::File::FILE_OK) 433 if (error != base::File::FILE_OK)
435 return error; 434 return error;
436 return fileapi::NativeFileUtil::CreateDirectory(file_path, exclusive, 435 return storage::NativeFileUtil::CreateDirectory(
437 recursive); 436 file_path, exclusive, recursive);
438 } 437 }
439 438
440 base::File::Error NativeMediaFileUtil::CopyOrMoveFileSync( 439 base::File::Error NativeMediaFileUtil::CopyOrMoveFileSync(
441 fileapi::FileSystemOperationContext* context, 440 storage::FileSystemOperationContext* context,
442 const fileapi::FileSystemURL& src_url, 441 const storage::FileSystemURL& src_url,
443 const fileapi::FileSystemURL& dest_url, 442 const storage::FileSystemURL& dest_url,
444 CopyOrMoveOption option, 443 CopyOrMoveOption option,
445 bool copy) { 444 bool copy) {
446 DCHECK(IsOnTaskRunnerThread(context)); 445 DCHECK(IsOnTaskRunnerThread(context));
447 base::FilePath src_file_path; 446 base::FilePath src_file_path;
448 base::File::Error error = 447 base::File::Error error =
449 GetFilteredLocalFilePathForExistingFileOrDirectory( 448 GetFilteredLocalFilePathForExistingFileOrDirectory(
450 context, src_url, 449 context, src_url,
451 base::File::FILE_ERROR_NOT_FOUND, 450 base::File::FILE_ERROR_NOT_FOUND,
452 &src_file_path); 451 &src_file_path);
453 if (error != base::File::FILE_OK) 452 if (error != base::File::FILE_OK)
454 return error; 453 return error;
455 if (fileapi::NativeFileUtil::DirectoryExists(src_file_path)) 454 if (storage::NativeFileUtil::DirectoryExists(src_file_path))
456 return base::File::FILE_ERROR_NOT_A_FILE; 455 return base::File::FILE_ERROR_NOT_A_FILE;
457 456
458 base::FilePath dest_file_path; 457 base::FilePath dest_file_path;
459 error = GetLocalFilePath(context, dest_url, &dest_file_path); 458 error = GetLocalFilePath(context, dest_url, &dest_file_path);
460 if (error != base::File::FILE_OK) 459 if (error != base::File::FILE_OK)
461 return error; 460 return error;
462 base::File::Info file_info; 461 base::File::Info file_info;
463 error = fileapi::NativeFileUtil::GetFileInfo(dest_file_path, &file_info); 462 error = storage::NativeFileUtil::GetFileInfo(dest_file_path, &file_info);
464 if (error != base::File::FILE_OK && 463 if (error != base::File::FILE_OK &&
465 error != base::File::FILE_ERROR_NOT_FOUND) { 464 error != base::File::FILE_ERROR_NOT_FOUND) {
466 return error; 465 return error;
467 } 466 }
468 if (error == base::File::FILE_OK && file_info.is_directory) 467 if (error == base::File::FILE_OK && file_info.is_directory)
469 return base::File::FILE_ERROR_INVALID_OPERATION; 468 return base::File::FILE_ERROR_INVALID_OPERATION;
470 if (!media_path_filter_->Match(dest_file_path)) 469 if (!media_path_filter_->Match(dest_file_path))
471 return base::File::FILE_ERROR_SECURITY; 470 return base::File::FILE_ERROR_SECURITY;
472 471
473 return fileapi::NativeFileUtil::CopyOrMoveFile( 472 return storage::NativeFileUtil::CopyOrMoveFile(
474 src_file_path, dest_file_path, option, 473 src_file_path,
475 fileapi::NativeFileUtil::CopyOrMoveModeForDestination(dest_url, copy)); 474 dest_file_path,
475 option,
476 storage::NativeFileUtil::CopyOrMoveModeForDestination(dest_url, copy));
476 } 477 }
477 478
478 base::File::Error NativeMediaFileUtil::CopyInForeignFileSync( 479 base::File::Error NativeMediaFileUtil::CopyInForeignFileSync(
479 fileapi::FileSystemOperationContext* context, 480 storage::FileSystemOperationContext* context,
480 const base::FilePath& src_file_path, 481 const base::FilePath& src_file_path,
481 const fileapi::FileSystemURL& dest_url) { 482 const storage::FileSystemURL& dest_url) {
482 DCHECK(IsOnTaskRunnerThread(context)); 483 DCHECK(IsOnTaskRunnerThread(context));
483 if (src_file_path.empty()) 484 if (src_file_path.empty())
484 return base::File::FILE_ERROR_INVALID_OPERATION; 485 return base::File::FILE_ERROR_INVALID_OPERATION;
485 486
486 base::FilePath dest_file_path; 487 base::FilePath dest_file_path;
487 base::File::Error error = 488 base::File::Error error =
488 GetFilteredLocalFilePath(context, dest_url, &dest_file_path); 489 GetFilteredLocalFilePath(context, dest_url, &dest_file_path);
489 if (error != base::File::FILE_OK) 490 if (error != base::File::FILE_OK)
490 return error; 491 return error;
491 return fileapi::NativeFileUtil::CopyOrMoveFile( 492 return storage::NativeFileUtil::CopyOrMoveFile(
492 src_file_path, dest_file_path, 493 src_file_path,
493 fileapi::FileSystemOperation::OPTION_NONE, 494 dest_file_path,
494 fileapi::NativeFileUtil::CopyOrMoveModeForDestination(dest_url, 495 storage::FileSystemOperation::OPTION_NONE,
496 storage::NativeFileUtil::CopyOrMoveModeForDestination(dest_url,
495 true /* copy */)); 497 true /* copy */));
496 } 498 }
497 499
498 base::File::Error NativeMediaFileUtil::GetFileInfoSync( 500 base::File::Error NativeMediaFileUtil::GetFileInfoSync(
499 fileapi::FileSystemOperationContext* context, 501 storage::FileSystemOperationContext* context,
500 const fileapi::FileSystemURL& url, 502 const storage::FileSystemURL& url,
501 base::File::Info* file_info, 503 base::File::Info* file_info,
502 base::FilePath* platform_path) { 504 base::FilePath* platform_path) {
503 DCHECK(context); 505 DCHECK(context);
504 DCHECK(IsOnTaskRunnerThread(context)); 506 DCHECK(IsOnTaskRunnerThread(context));
505 DCHECK(file_info); 507 DCHECK(file_info);
506 508
507 base::FilePath file_path; 509 base::FilePath file_path;
508 base::File::Error error = GetLocalFilePath(context, url, &file_path); 510 base::File::Error error = GetLocalFilePath(context, url, &file_path);
509 if (error != base::File::FILE_OK) 511 if (error != base::File::FILE_OK)
510 return error; 512 return error;
511 if (base::IsLink(file_path)) 513 if (base::IsLink(file_path))
512 return base::File::FILE_ERROR_NOT_FOUND; 514 return base::File::FILE_ERROR_NOT_FOUND;
513 error = fileapi::NativeFileUtil::GetFileInfo(file_path, file_info); 515 error = storage::NativeFileUtil::GetFileInfo(file_path, file_info);
514 if (error != base::File::FILE_OK) 516 if (error != base::File::FILE_OK)
515 return error; 517 return error;
516 518
517 if (platform_path) 519 if (platform_path)
518 *platform_path = file_path; 520 *platform_path = file_path;
519 if (file_info->is_directory || 521 if (file_info->is_directory ||
520 media_path_filter_->Match(file_path)) { 522 media_path_filter_->Match(file_path)) {
521 return base::File::FILE_OK; 523 return base::File::FILE_OK;
522 } 524 }
523 return base::File::FILE_ERROR_NOT_FOUND; 525 return base::File::FILE_ERROR_NOT_FOUND;
524 } 526 }
525 527
526 base::File::Error NativeMediaFileUtil::GetLocalFilePath( 528 base::File::Error NativeMediaFileUtil::GetLocalFilePath(
527 fileapi::FileSystemOperationContext* context, 529 storage::FileSystemOperationContext* context,
528 const fileapi::FileSystemURL& url, 530 const storage::FileSystemURL& url,
529 base::FilePath* local_file_path) { 531 base::FilePath* local_file_path) {
530 DCHECK(local_file_path); 532 DCHECK(local_file_path);
531 DCHECK(url.is_valid()); 533 DCHECK(url.is_valid());
532 if (url.path().empty()) { 534 if (url.path().empty()) {
533 // Root direcory case, which should not be accessed. 535 // Root direcory case, which should not be accessed.
534 return base::File::FILE_ERROR_ACCESS_DENIED; 536 return base::File::FILE_ERROR_ACCESS_DENIED;
535 } 537 }
536 *local_file_path = url.path(); 538 *local_file_path = url.path();
537 return base::File::FILE_OK; 539 return base::File::FILE_OK;
538 } 540 }
539 541
540 base::File::Error NativeMediaFileUtil::ReadDirectorySync( 542 base::File::Error NativeMediaFileUtil::ReadDirectorySync(
541 fileapi::FileSystemOperationContext* context, 543 storage::FileSystemOperationContext* context,
542 const fileapi::FileSystemURL& url, 544 const storage::FileSystemURL& url,
543 EntryList* file_list) { 545 EntryList* file_list) {
544 DCHECK(IsOnTaskRunnerThread(context)); 546 DCHECK(IsOnTaskRunnerThread(context));
545 DCHECK(file_list); 547 DCHECK(file_list);
546 DCHECK(file_list->empty()); 548 DCHECK(file_list->empty());
547 base::File::Info file_info; 549 base::File::Info file_info;
548 base::FilePath dir_path; 550 base::FilePath dir_path;
549 base::File::Error error = 551 base::File::Error error =
550 GetFileInfoSync(context, url, &file_info, &dir_path); 552 GetFileInfoSync(context, url, &file_info, &dir_path);
551 553
552 if (error != base::File::FILE_OK) 554 if (error != base::File::FILE_OK)
553 return error; 555 return error;
(...skipping 13 matching lines...) Expand all
567 continue; 569 continue;
568 570
569 base::FileEnumerator::FileInfo info = file_enum.GetInfo(); 571 base::FileEnumerator::FileInfo info = file_enum.GetInfo();
570 572
571 // NativeMediaFileUtil skip criteria. 573 // NativeMediaFileUtil skip criteria.
572 if (MediaPathFilter::ShouldSkip(enum_path)) 574 if (MediaPathFilter::ShouldSkip(enum_path))
573 continue; 575 continue;
574 if (!info.IsDirectory() && !media_path_filter_->Match(enum_path)) 576 if (!info.IsDirectory() && !media_path_filter_->Match(enum_path))
575 continue; 577 continue;
576 578
577 fileapi::DirectoryEntry entry; 579 storage::DirectoryEntry entry;
578 entry.is_directory = info.IsDirectory(); 580 entry.is_directory = info.IsDirectory();
579 entry.name = enum_path.BaseName().value(); 581 entry.name = enum_path.BaseName().value();
580 entry.size = info.GetSize(); 582 entry.size = info.GetSize();
581 entry.last_modified_time = info.GetLastModifiedTime(); 583 entry.last_modified_time = info.GetLastModifiedTime();
582 584
583 file_list->push_back(entry); 585 file_list->push_back(entry);
584 } 586 }
585 587
586 return base::File::FILE_OK; 588 return base::File::FILE_OK;
587 } 589 }
588 590
589 base::File::Error NativeMediaFileUtil::DeleteFileSync( 591 base::File::Error NativeMediaFileUtil::DeleteFileSync(
590 fileapi::FileSystemOperationContext* context, 592 storage::FileSystemOperationContext* context,
591 const fileapi::FileSystemURL& url) { 593 const storage::FileSystemURL& url) {
592 DCHECK(IsOnTaskRunnerThread(context)); 594 DCHECK(IsOnTaskRunnerThread(context));
593 base::File::Info file_info; 595 base::File::Info file_info;
594 base::FilePath file_path; 596 base::FilePath file_path;
595 base::File::Error error = 597 base::File::Error error =
596 GetFileInfoSync(context, url, &file_info, &file_path); 598 GetFileInfoSync(context, url, &file_info, &file_path);
597 if (error != base::File::FILE_OK) 599 if (error != base::File::FILE_OK)
598 return error; 600 return error;
599 if (file_info.is_directory) 601 if (file_info.is_directory)
600 return base::File::FILE_ERROR_NOT_A_FILE; 602 return base::File::FILE_ERROR_NOT_A_FILE;
601 return fileapi::NativeFileUtil::DeleteFile(file_path); 603 return storage::NativeFileUtil::DeleteFile(file_path);
602 } 604 }
603 605
604 base::File::Error NativeMediaFileUtil::DeleteDirectorySync( 606 base::File::Error NativeMediaFileUtil::DeleteDirectorySync(
605 fileapi::FileSystemOperationContext* context, 607 storage::FileSystemOperationContext* context,
606 const fileapi::FileSystemURL& url) { 608 const storage::FileSystemURL& url) {
607 DCHECK(IsOnTaskRunnerThread(context)); 609 DCHECK(IsOnTaskRunnerThread(context));
608 base::FilePath file_path; 610 base::FilePath file_path;
609 base::File::Error error = GetLocalFilePath(context, url, &file_path); 611 base::File::Error error = GetLocalFilePath(context, url, &file_path);
610 if (error != base::File::FILE_OK) 612 if (error != base::File::FILE_OK)
611 return error; 613 return error;
612 return fileapi::NativeFileUtil::DeleteDirectory(file_path); 614 return storage::NativeFileUtil::DeleteDirectory(file_path);
613 } 615 }
614 616
615 base::File::Error NativeMediaFileUtil::CreateSnapshotFileSync( 617 base::File::Error NativeMediaFileUtil::CreateSnapshotFileSync(
616 fileapi::FileSystemOperationContext* context, 618 storage::FileSystemOperationContext* context,
617 const fileapi::FileSystemURL& url, 619 const storage::FileSystemURL& url,
618 base::File::Info* file_info, 620 base::File::Info* file_info,
619 base::FilePath* platform_path, 621 base::FilePath* platform_path,
620 scoped_refptr<webkit_blob::ShareableFileReference>* file_ref) { 622 scoped_refptr<storage::ShareableFileReference>* file_ref) {
621 DCHECK(IsOnTaskRunnerThread(context)); 623 DCHECK(IsOnTaskRunnerThread(context));
622 base::File::Error error = 624 base::File::Error error =
623 GetFileInfoSync(context, url, file_info, platform_path); 625 GetFileInfoSync(context, url, file_info, platform_path);
624 if (error == base::File::FILE_OK && file_info->is_directory) 626 if (error == base::File::FILE_OK && file_info->is_directory)
625 error = base::File::FILE_ERROR_NOT_A_FILE; 627 error = base::File::FILE_ERROR_NOT_A_FILE;
626 if (error == base::File::FILE_OK) 628 if (error == base::File::FILE_OK)
627 error = NativeMediaFileUtil::IsMediaFile(*platform_path); 629 error = NativeMediaFileUtil::IsMediaFile(*platform_path);
628 630
629 // We're just returning the local file information. 631 // We're just returning the local file information.
630 *file_ref = scoped_refptr<webkit_blob::ShareableFileReference>(); 632 *file_ref = scoped_refptr<storage::ShareableFileReference>();
631 633
632 return error; 634 return error;
633 } 635 }
634 636
635 base::File::Error NativeMediaFileUtil::GetFilteredLocalFilePath( 637 base::File::Error NativeMediaFileUtil::GetFilteredLocalFilePath(
636 fileapi::FileSystemOperationContext* context, 638 storage::FileSystemOperationContext* context,
637 const fileapi::FileSystemURL& file_system_url, 639 const storage::FileSystemURL& file_system_url,
638 base::FilePath* local_file_path) { 640 base::FilePath* local_file_path) {
639 DCHECK(IsOnTaskRunnerThread(context)); 641 DCHECK(IsOnTaskRunnerThread(context));
640 base::FilePath file_path; 642 base::FilePath file_path;
641 base::File::Error error = 643 base::File::Error error =
642 GetLocalFilePath(context, file_system_url, &file_path); 644 GetLocalFilePath(context, file_system_url, &file_path);
643 if (error != base::File::FILE_OK) 645 if (error != base::File::FILE_OK)
644 return error; 646 return error;
645 if (!media_path_filter_->Match(file_path)) 647 if (!media_path_filter_->Match(file_path))
646 return base::File::FILE_ERROR_SECURITY; 648 return base::File::FILE_ERROR_SECURITY;
647 649
648 *local_file_path = file_path; 650 *local_file_path = file_path;
649 return base::File::FILE_OK; 651 return base::File::FILE_OK;
650 } 652 }
651 653
652 base::File::Error 654 base::File::Error
653 NativeMediaFileUtil::GetFilteredLocalFilePathForExistingFileOrDirectory( 655 NativeMediaFileUtil::GetFilteredLocalFilePathForExistingFileOrDirectory(
654 fileapi::FileSystemOperationContext* context, 656 storage::FileSystemOperationContext* context,
655 const fileapi::FileSystemURL& file_system_url, 657 const storage::FileSystemURL& file_system_url,
656 base::File::Error failure_error, 658 base::File::Error failure_error,
657 base::FilePath* local_file_path) { 659 base::FilePath* local_file_path) {
658 DCHECK(IsOnTaskRunnerThread(context)); 660 DCHECK(IsOnTaskRunnerThread(context));
659 base::FilePath file_path; 661 base::FilePath file_path;
660 base::File::Error error = 662 base::File::Error error =
661 GetLocalFilePath(context, file_system_url, &file_path); 663 GetLocalFilePath(context, file_system_url, &file_path);
662 if (error != base::File::FILE_OK) 664 if (error != base::File::FILE_OK)
663 return error; 665 return error;
664 666
665 if (!base::PathExists(file_path)) 667 if (!base::PathExists(file_path))
666 return failure_error; 668 return failure_error;
667 base::File::Info file_info; 669 base::File::Info file_info;
668 if (!base::GetFileInfo(file_path, &file_info)) 670 if (!base::GetFileInfo(file_path, &file_info))
669 return base::File::FILE_ERROR_FAILED; 671 return base::File::FILE_ERROR_FAILED;
670 672
671 if (!file_info.is_directory && 673 if (!file_info.is_directory &&
672 !media_path_filter_->Match(file_path)) { 674 !media_path_filter_->Match(file_path)) {
673 return failure_error; 675 return failure_error;
674 } 676 }
675 677
676 *local_file_path = file_path; 678 *local_file_path = file_path;
677 return base::File::FILE_OK; 679 return base::File::FILE_OK;
678 } 680 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698