OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 201 |
202 if (!metadata.platformPath.isEmpty()) { | 202 if (!metadata.platformPath.isEmpty()) { |
203 // If the platformPath in the returned metadata is given, we create a Fi
le object for the path. | 203 // If the platformPath in the returned metadata is given, we create a Fi
le object for the path. |
204 File::UserVisibility userVisibility = (type == FileSystemTypeExternal) ?
File::IsUserVisible : File::IsNotUserVisible; | 204 File::UserVisibility userVisibility = (type == FileSystemTypeExternal) ?
File::IsUserVisible : File::IsNotUserVisible; |
205 return File::createForFileSystemFile(name, metadata, userVisibility); | 205 return File::createForFileSystemFile(name, metadata, userVisibility); |
206 } | 206 } |
207 | 207 |
208 return File::createForFileSystemFile(fileSystemURL, metadata); | 208 return File::createForFileSystemFile(fileSystemURL, metadata); |
209 } | 209 } |
210 | 210 |
211 void DOMFileSystemBase::getMetadata(const EntryBase* entry, PassOwnPtrWillBeRawP
tr<MetadataCallback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> erro
rCallback, SynchronousType synchronousType) | 211 void DOMFileSystemBase::getMetadata(const EntryBase* entry, MetadataCallback* su
ccessCallback, ErrorCallback* errorCallback, SynchronousType synchronousType) |
212 { | 212 { |
213 if (!fileSystem()) { | 213 if (!fileSystem()) { |
214 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 214 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); |
215 return; | 215 return; |
216 } | 216 } |
217 | 217 |
218 OwnPtr<AsyncFileSystemCallbacks> callbacks(MetadataCallbacks::create(success
Callback, errorCallback, m_context, this)); | 218 OwnPtr<AsyncFileSystemCallbacks> callbacks(MetadataCallbacks::create(success
Callback, errorCallback, m_context, this)); |
219 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 219 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
220 fileSystem()->readMetadata(createFileSystemURL(entry), callbacks.release()); | 220 fileSystem()->readMetadata(createFileSystemURL(entry), callbacks.release()); |
221 } | 221 } |
(...skipping 20 matching lines...) Expand all Loading... |
242 | 242 |
243 destinationPath = parent->fullPath(); | 243 destinationPath = parent->fullPath(); |
244 if (!newName.isEmpty()) | 244 if (!newName.isEmpty()) |
245 destinationPath = DOMFilePath::append(destinationPath, newName); | 245 destinationPath = DOMFilePath::append(destinationPath, newName); |
246 else | 246 else |
247 destinationPath = DOMFilePath::append(destinationPath, source->name()); | 247 destinationPath = DOMFilePath::append(destinationPath, source->name()); |
248 | 248 |
249 return true; | 249 return true; |
250 } | 250 } |
251 | 251 |
252 void DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const S
tring& newName, PassOwnPtrWillBeRawPtr<EntryCallback> successCallback, PassOwnPt
rWillBeRawPtr<ErrorCallback> errorCallback, SynchronousType synchronousType) | 252 void DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const S
tring& newName, EntryCallback* successCallback, ErrorCallback* errorCallback, Sy
nchronousType synchronousType) |
253 { | 253 { |
254 if (!fileSystem()) { | 254 if (!fileSystem()) { |
255 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 255 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); |
256 return; | 256 return; |
257 } | 257 } |
258 | 258 |
259 String destinationPath; | 259 String destinationPath; |
260 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti
nationPath)) { | 260 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti
nationPath)) { |
261 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 261 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); |
262 return; | 262 return; |
263 } | 263 } |
264 | 264 |
265 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal
lback, errorCallback, m_context, parent->filesystem(), destinationPath, source->
isDirectory())); | 265 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal
lback, errorCallback, m_context, parent->filesystem(), destinationPath, source->
isDirectory())); |
266 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 266 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
267 | 267 |
268 fileSystem()->move(createFileSystemURL(source), parent->filesystem()->create
FileSystemURL(destinationPath), callbacks.release()); | 268 fileSystem()->move(createFileSystemURL(source), parent->filesystem()->create
FileSystemURL(destinationPath), callbacks.release()); |
269 } | 269 } |
270 | 270 |
271 void DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const S
tring& newName, PassOwnPtrWillBeRawPtr<EntryCallback> successCallback, PassOwnPt
rWillBeRawPtr<ErrorCallback> errorCallback, SynchronousType synchronousType) | 271 void DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const S
tring& newName, EntryCallback* successCallback, ErrorCallback* errorCallback, Sy
nchronousType synchronousType) |
272 { | 272 { |
273 if (!fileSystem()) { | 273 if (!fileSystem()) { |
274 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 274 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); |
275 return; | 275 return; |
276 } | 276 } |
277 | 277 |
278 String destinationPath; | 278 String destinationPath; |
279 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti
nationPath)) { | 279 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti
nationPath)) { |
280 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 280 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); |
281 return; | 281 return; |
282 } | 282 } |
283 | 283 |
284 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal
lback, errorCallback, m_context, parent->filesystem(), destinationPath, source->
isDirectory())); | 284 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal
lback, errorCallback, m_context, parent->filesystem(), destinationPath, source->
isDirectory())); |
285 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 285 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
286 | 286 |
287 fileSystem()->copy(createFileSystemURL(source), parent->filesystem()->create
FileSystemURL(destinationPath), callbacks.release()); | 287 fileSystem()->copy(createFileSystemURL(source), parent->filesystem()->create
FileSystemURL(destinationPath), callbacks.release()); |
288 } | 288 } |
289 | 289 |
290 void DOMFileSystemBase::remove(const EntryBase* entry, PassOwnPtrWillBeRawPtr<Vo
idCallback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback
, SynchronousType synchronousType) | 290 void DOMFileSystemBase::remove(const EntryBase* entry, VoidCallback* successCall
back, ErrorCallback* errorCallback, SynchronousType synchronousType) |
291 { | 291 { |
292 if (!fileSystem()) { | 292 if (!fileSystem()) { |
293 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 293 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); |
294 return; | 294 return; |
295 } | 295 } |
296 | 296 |
297 ASSERT(entry); | 297 ASSERT(entry); |
298 // We don't allow calling remove() on the root directory. | 298 // We don't allow calling remove() on the root directory. |
299 if (entry->fullPath() == String(DOMFilePath::root)) { | 299 if (entry->fullPath() == String(DOMFilePath::root)) { |
300 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 300 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); |
301 return; | 301 return; |
302 } | 302 } |
303 | 303 |
304 OwnPtr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(successCall
back, errorCallback, m_context, this)); | 304 OwnPtr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(successCall
back, errorCallback, m_context, this)); |
305 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 305 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
306 | 306 |
307 fileSystem()->remove(createFileSystemURL(entry), callbacks.release()); | 307 fileSystem()->remove(createFileSystemURL(entry), callbacks.release()); |
308 } | 308 } |
309 | 309 |
310 void DOMFileSystemBase::removeRecursively(const EntryBase* entry, PassOwnPtrWill
BeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> er
rorCallback, SynchronousType synchronousType) | 310 void DOMFileSystemBase::removeRecursively(const EntryBase* entry, VoidCallback*
successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType) |
311 { | 311 { |
312 if (!fileSystem()) { | 312 if (!fileSystem()) { |
313 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 313 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); |
314 return; | 314 return; |
315 } | 315 } |
316 | 316 |
317 ASSERT(entry && entry->isDirectory()); | 317 ASSERT(entry && entry->isDirectory()); |
318 // We don't allow calling remove() on the root directory. | 318 // We don't allow calling remove() on the root directory. |
319 if (entry->fullPath() == String(DOMFilePath::root)) { | 319 if (entry->fullPath() == String(DOMFilePath::root)) { |
320 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 320 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); |
321 return; | 321 return; |
322 } | 322 } |
323 | 323 |
324 OwnPtr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(successCall
back, errorCallback, m_context, this)); | 324 OwnPtr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(successCall
back, errorCallback, m_context, this)); |
325 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 325 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
326 | 326 |
327 fileSystem()->removeRecursively(createFileSystemURL(entry), callbacks.releas
e()); | 327 fileSystem()->removeRecursively(createFileSystemURL(entry), callbacks.releas
e()); |
328 } | 328 } |
329 | 329 |
330 void DOMFileSystemBase::getParent(const EntryBase* entry, PassOwnPtrWillBeRawPtr
<EntryCallback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCall
back) | 330 void DOMFileSystemBase::getParent(const EntryBase* entry, EntryCallback* success
Callback, ErrorCallback* errorCallback) |
331 { | 331 { |
332 if (!fileSystem()) { | 332 if (!fileSystem()) { |
333 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 333 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); |
334 return; | 334 return; |
335 } | 335 } |
336 | 336 |
337 ASSERT(entry); | 337 ASSERT(entry); |
338 String path = DOMFilePath::getDirectory(entry->fullPath()); | 338 String path = DOMFilePath::getDirectory(entry->fullPath()); |
339 | 339 |
340 fileSystem()->directoryExists(createFileSystemURL(path), EntryCallbacks::cre
ate(successCallback, errorCallback, m_context, this, path, true)); | 340 fileSystem()->directoryExists(createFileSystemURL(path), EntryCallbacks::cre
ate(successCallback, errorCallback, m_context, this, path, true)); |
341 } | 341 } |
342 | 342 |
343 void DOMFileSystemBase::getFile(const EntryBase* entry, const String& path, cons
t FileSystemFlags& flags, PassOwnPtrWillBeRawPtr<EntryCallback> successCallback,
PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, SynchronousType synchronou
sType) | 343 void DOMFileSystemBase::getFile(const EntryBase* entry, const String& path, cons
t FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallback* errorCa
llback, SynchronousType synchronousType) |
344 { | 344 { |
345 if (!fileSystem()) { | 345 if (!fileSystem()) { |
346 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 346 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); |
347 return; | 347 return; |
348 } | 348 } |
349 | 349 |
350 String absolutePath; | 350 String absolutePath; |
351 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) { | 351 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) { |
352 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 352 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); |
353 return; | 353 return; |
354 } | 354 } |
355 | 355 |
356 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal
lback, errorCallback, m_context, this, absolutePath, false)); | 356 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal
lback, errorCallback, m_context, this, absolutePath, false)); |
357 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 357 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
358 | 358 |
359 if (flags.create) | 359 if (flags.create) |
360 fileSystem()->createFile(createFileSystemURL(absolutePath), flags.exclus
ive, callbacks.release()); | 360 fileSystem()->createFile(createFileSystemURL(absolutePath), flags.exclus
ive, callbacks.release()); |
361 else | 361 else |
362 fileSystem()->fileExists(createFileSystemURL(absolutePath), callbacks.re
lease()); | 362 fileSystem()->fileExists(createFileSystemURL(absolutePath), callbacks.re
lease()); |
363 } | 363 } |
364 | 364 |
365 void DOMFileSystemBase::getDirectory(const EntryBase* entry, const String& path,
const FileSystemFlags& flags, PassOwnPtrWillBeRawPtr<EntryCallback> successCall
back, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, SynchronousType synch
ronousType) | 365 void DOMFileSystemBase::getDirectory(const EntryBase* entry, const String& path,
const FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallback* er
rorCallback, SynchronousType synchronousType) |
366 { | 366 { |
367 if (!fileSystem()) { | 367 if (!fileSystem()) { |
368 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 368 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); |
369 return; | 369 return; |
370 } | 370 } |
371 | 371 |
372 String absolutePath; | 372 String absolutePath; |
373 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) { | 373 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) { |
374 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 374 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); |
375 return; | 375 return; |
376 } | 376 } |
377 | 377 |
378 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal
lback, errorCallback, m_context, this, absolutePath, true)); | 378 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(successCal
lback, errorCallback, m_context, this, absolutePath, true)); |
379 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 379 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
380 | 380 |
381 if (flags.create) | 381 if (flags.create) |
382 fileSystem()->createDirectory(createFileSystemURL(absolutePath), flags.e
xclusive, callbacks.release()); | 382 fileSystem()->createDirectory(createFileSystemURL(absolutePath), flags.e
xclusive, callbacks.release()); |
383 else | 383 else |
384 fileSystem()->directoryExists(createFileSystemURL(absolutePath), callbac
ks.release()); | 384 fileSystem()->directoryExists(createFileSystemURL(absolutePath), callbac
ks.release()); |
385 } | 385 } |
386 | 386 |
387 int DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader, const String&
path, PassOwnPtrWillBeRawPtr<EntriesCallback> successCallback, PassOwnPtrWillBeR
awPtr<ErrorCallback> errorCallback, SynchronousType synchronousType) | 387 int DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader, const String&
path, EntriesCallback* successCallback, ErrorCallback* errorCallback, Synchronou
sType synchronousType) |
388 { | 388 { |
389 if (!fileSystem()) { | 389 if (!fileSystem()) { |
390 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 390 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); |
391 return 0; | 391 return 0; |
392 } | 392 } |
393 | 393 |
394 ASSERT(DOMFilePath::isAbsolute(path)); | 394 ASSERT(DOMFilePath::isAbsolute(path)); |
395 | 395 |
396 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntriesCallbacks::create(successC
allback, errorCallback, m_context, reader, path)); | 396 OwnPtr<AsyncFileSystemCallbacks> callbacks(EntriesCallbacks::create(successC
allback, errorCallback, m_context, reader, path)); |
397 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 397 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
398 | 398 |
399 return fileSystem()->readDirectory(createFileSystemURL(path), callbacks.rele
ase()); | 399 return fileSystem()->readDirectory(createFileSystemURL(path), callbacks.rele
ase()); |
400 } | 400 } |
401 | 401 |
402 bool DOMFileSystemBase::waitForAdditionalResult(int callbacksId) | 402 bool DOMFileSystemBase::waitForAdditionalResult(int callbacksId) |
403 { | 403 { |
404 if (!fileSystem()) | 404 if (!fileSystem()) |
405 return false; | 405 return false; |
406 return fileSystem()->waitForAdditionalResult(callbacksId); | 406 return fileSystem()->waitForAdditionalResult(callbacksId); |
407 } | 407 } |
408 | 408 |
409 } // namespace blink | 409 } // namespace blink |
OLD | NEW |