| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return File::createForFileSystemFile(name, metadata, userVisibility); | 211 return File::createForFileSystemFile(name, metadata, userVisibility); |
| 212 } else { | 212 } else { |
| 213 // Otherwise we create a File object for the fileSystemURL. | 213 // Otherwise we create a File object for the fileSystemURL. |
| 214 return File::createForFileSystemFile(fileSystemURL, metadata, userVisibi
lity); | 214 return File::createForFileSystemFile(fileSystemURL, metadata, userVisibi
lity); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 void DOMFileSystemBase::getMetadata(const EntryBase* entry, MetadataCallback* su
ccessCallback, ErrorCallback* errorCallback, SynchronousType synchronousType) | 218 void DOMFileSystemBase::getMetadata(const EntryBase* entry, MetadataCallback* su
ccessCallback, ErrorCallback* errorCallback, SynchronousType synchronousType) |
| 219 { | 219 { |
| 220 if (!fileSystem()) { | 220 if (!fileSystem()) { |
| 221 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 221 reportError(errorCallback, FileError::ABORT_ERR); |
| 222 return; | 222 return; |
| 223 } | 223 } |
| 224 | 224 |
| 225 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(MetadataCallbacks::creat
e(successCallback, errorCallback, m_context, this)); | 225 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(MetadataCallbacks::creat
e(successCallback, errorCallback, m_context, this)); |
| 226 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 226 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
| 227 fileSystem()->readMetadata(createFileSystemURL(entry), std::move(callbacks))
; | 227 fileSystem()->readMetadata(createFileSystemURL(entry), std::move(callbacks))
; |
| 228 } | 228 } |
| 229 | 229 |
| 230 static bool verifyAndGetDestinationPathForCopyOrMove(const EntryBase* source, En
tryBase* parent, const String& newName, String& destinationPath) | 230 static bool verifyAndGetDestinationPathForCopyOrMove(const EntryBase* source, En
tryBase* parent, const String& newName, String& destinationPath) |
| 231 { | 231 { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 252 destinationPath = DOMFilePath::append(destinationPath, newName); | 252 destinationPath = DOMFilePath::append(destinationPath, newName); |
| 253 else | 253 else |
| 254 destinationPath = DOMFilePath::append(destinationPath, source->name()); | 254 destinationPath = DOMFilePath::append(destinationPath, source->name()); |
| 255 | 255 |
| 256 return true; | 256 return true; |
| 257 } | 257 } |
| 258 | 258 |
| 259 void DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const S
tring& newName, EntryCallback* successCallback, ErrorCallback* errorCallback, Sy
nchronousType synchronousType) | 259 void DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const S
tring& newName, EntryCallback* successCallback, ErrorCallback* errorCallback, Sy
nchronousType synchronousType) |
| 260 { | 260 { |
| 261 if (!fileSystem()) { | 261 if (!fileSystem()) { |
| 262 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 262 reportError(errorCallback, FileError::ABORT_ERR); |
| 263 return; | 263 return; |
| 264 } | 264 } |
| 265 | 265 |
| 266 String destinationPath; | 266 String destinationPath; |
| 267 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti
nationPath)) { | 267 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti
nationPath)) { |
| 268 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 268 reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR); |
| 269 return; | 269 return; |
| 270 } | 270 } |
| 271 | 271 |
| 272 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s
uccessCallback, errorCallback, m_context, parent->filesystem(), destinationPath,
source->isDirectory())); | 272 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s
uccessCallback, errorCallback, m_context, parent->filesystem(), destinationPath,
source->isDirectory())); |
| 273 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 273 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
| 274 | 274 |
| 275 fileSystem()->move(createFileSystemURL(source), parent->filesystem()->create
FileSystemURL(destinationPath), std::move(callbacks)); | 275 fileSystem()->move(createFileSystemURL(source), parent->filesystem()->create
FileSystemURL(destinationPath), std::move(callbacks)); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const S
tring& newName, EntryCallback* successCallback, ErrorCallback* errorCallback, Sy
nchronousType synchronousType) | 278 void DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const S
tring& newName, EntryCallback* successCallback, ErrorCallback* errorCallback, Sy
nchronousType synchronousType) |
| 279 { | 279 { |
| 280 if (!fileSystem()) { | 280 if (!fileSystem()) { |
| 281 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 281 reportError(errorCallback, FileError::ABORT_ERR); |
| 282 return; | 282 return; |
| 283 } | 283 } |
| 284 | 284 |
| 285 String destinationPath; | 285 String destinationPath; |
| 286 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti
nationPath)) { | 286 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti
nationPath)) { |
| 287 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 287 reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR); |
| 288 return; | 288 return; |
| 289 } | 289 } |
| 290 | 290 |
| 291 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s
uccessCallback, errorCallback, m_context, parent->filesystem(), destinationPath,
source->isDirectory())); | 291 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s
uccessCallback, errorCallback, m_context, parent->filesystem(), destinationPath,
source->isDirectory())); |
| 292 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 292 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
| 293 | 293 |
| 294 fileSystem()->copy(createFileSystemURL(source), parent->filesystem()->create
FileSystemURL(destinationPath), std::move(callbacks)); | 294 fileSystem()->copy(createFileSystemURL(source), parent->filesystem()->create
FileSystemURL(destinationPath), std::move(callbacks)); |
| 295 } | 295 } |
| 296 | 296 |
| 297 void DOMFileSystemBase::remove(const EntryBase* entry, VoidCallback* successCall
back, ErrorCallback* errorCallback, SynchronousType synchronousType) | 297 void DOMFileSystemBase::remove(const EntryBase* entry, VoidCallback* successCall
back, ErrorCallback* errorCallback, SynchronousType synchronousType) |
| 298 { | 298 { |
| 299 if (!fileSystem()) { | 299 if (!fileSystem()) { |
| 300 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 300 reportError(errorCallback, FileError::ABORT_ERR); |
| 301 return; | 301 return; |
| 302 } | 302 } |
| 303 | 303 |
| 304 ASSERT(entry); | 304 ASSERT(entry); |
| 305 // We don't allow calling remove() on the root directory. | 305 // We don't allow calling remove() on the root directory. |
| 306 if (entry->fullPath() == String(DOMFilePath::root)) { | 306 if (entry->fullPath() == String(DOMFilePath::root)) { |
| 307 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 307 reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR); |
| 308 return; | 308 return; |
| 309 } | 309 } |
| 310 | 310 |
| 311 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(su
ccessCallback, errorCallback, m_context, this)); | 311 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(su
ccessCallback, errorCallback, m_context, this)); |
| 312 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 312 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
| 313 | 313 |
| 314 fileSystem()->remove(createFileSystemURL(entry), std::move(callbacks)); | 314 fileSystem()->remove(createFileSystemURL(entry), std::move(callbacks)); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void DOMFileSystemBase::removeRecursively(const EntryBase* entry, VoidCallback*
successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType) | 317 void DOMFileSystemBase::removeRecursively(const EntryBase* entry, VoidCallback*
successCallback, ErrorCallback* errorCallback, SynchronousType synchronousType) |
| 318 { | 318 { |
| 319 if (!fileSystem()) { | 319 if (!fileSystem()) { |
| 320 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 320 reportError(errorCallback, FileError::ABORT_ERR); |
| 321 return; | 321 return; |
| 322 } | 322 } |
| 323 | 323 |
| 324 ASSERT(entry && entry->isDirectory()); | 324 ASSERT(entry && entry->isDirectory()); |
| 325 // We don't allow calling remove() on the root directory. | 325 // We don't allow calling remove() on the root directory. |
| 326 if (entry->fullPath() == String(DOMFilePath::root)) { | 326 if (entry->fullPath() == String(DOMFilePath::root)) { |
| 327 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 327 reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR); |
| 328 return; | 328 return; |
| 329 } | 329 } |
| 330 | 330 |
| 331 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(su
ccessCallback, errorCallback, m_context, this)); | 331 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(VoidCallbacks::create(su
ccessCallback, errorCallback, m_context, this)); |
| 332 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 332 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
| 333 | 333 |
| 334 fileSystem()->removeRecursively(createFileSystemURL(entry), std::move(callba
cks)); | 334 fileSystem()->removeRecursively(createFileSystemURL(entry), std::move(callba
cks)); |
| 335 } | 335 } |
| 336 | 336 |
| 337 void DOMFileSystemBase::getParent(const EntryBase* entry, EntryCallback* success
Callback, ErrorCallback* errorCallback) | 337 void DOMFileSystemBase::getParent(const EntryBase* entry, EntryCallback* success
Callback, ErrorCallback* errorCallback) |
| 338 { | 338 { |
| 339 if (!fileSystem()) { | 339 if (!fileSystem()) { |
| 340 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 340 reportError(errorCallback, FileError::ABORT_ERR); |
| 341 return; | 341 return; |
| 342 } | 342 } |
| 343 | 343 |
| 344 ASSERT(entry); | 344 ASSERT(entry); |
| 345 String path = DOMFilePath::getDirectory(entry->fullPath()); | 345 String path = DOMFilePath::getDirectory(entry->fullPath()); |
| 346 | 346 |
| 347 fileSystem()->directoryExists(createFileSystemURL(path), EntryCallbacks::cre
ate(successCallback, errorCallback, m_context, this, path, true)); | 347 fileSystem()->directoryExists(createFileSystemURL(path), EntryCallbacks::cre
ate(successCallback, errorCallback, m_context, this, path, true)); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void DOMFileSystemBase::getFile(const EntryBase* entry, const String& path, cons
t FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallback* errorCa
llback, SynchronousType synchronousType) | 350 void DOMFileSystemBase::getFile(const EntryBase* entry, const String& path, cons
t FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallback* errorCa
llback, SynchronousType synchronousType) |
| 351 { | 351 { |
| 352 if (!fileSystem()) { | 352 if (!fileSystem()) { |
| 353 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 353 reportError(errorCallback, FileError::ABORT_ERR); |
| 354 return; | 354 return; |
| 355 } | 355 } |
| 356 | 356 |
| 357 String absolutePath; | 357 String absolutePath; |
| 358 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) { | 358 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) { |
| 359 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 359 reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR); |
| 360 return; | 360 return; |
| 361 } | 361 } |
| 362 | 362 |
| 363 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s
uccessCallback, errorCallback, m_context, this, absolutePath, false)); | 363 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s
uccessCallback, errorCallback, m_context, this, absolutePath, false)); |
| 364 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 364 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
| 365 | 365 |
| 366 if (flags.createFlag()) | 366 if (flags.createFlag()) |
| 367 fileSystem()->createFile(createFileSystemURL(absolutePath), flags.exclus
ive(), std::move(callbacks)); | 367 fileSystem()->createFile(createFileSystemURL(absolutePath), flags.exclus
ive(), std::move(callbacks)); |
| 368 else | 368 else |
| 369 fileSystem()->fileExists(createFileSystemURL(absolutePath), std::move(ca
llbacks)); | 369 fileSystem()->fileExists(createFileSystemURL(absolutePath), std::move(ca
llbacks)); |
| 370 } | 370 } |
| 371 | 371 |
| 372 void DOMFileSystemBase::getDirectory(const EntryBase* entry, const String& path,
const FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallback* er
rorCallback, SynchronousType synchronousType) | 372 void DOMFileSystemBase::getDirectory(const EntryBase* entry, const String& path,
const FileSystemFlags& flags, EntryCallback* successCallback, ErrorCallback* er
rorCallback, SynchronousType synchronousType) |
| 373 { | 373 { |
| 374 if (!fileSystem()) { | 374 if (!fileSystem()) { |
| 375 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 375 reportError(errorCallback, FileError::ABORT_ERR); |
| 376 return; | 376 return; |
| 377 } | 377 } |
| 378 | 378 |
| 379 String absolutePath; | 379 String absolutePath; |
| 380 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) { | 380 if (!pathToAbsolutePath(m_type, entry, path, absolutePath)) { |
| 381 reportError(errorCallback, FileError::create(FileError::INVALID_MODIFICA
TION_ERR)); | 381 reportError(errorCallback, FileError::INVALID_MODIFICATION_ERR); |
| 382 return; | 382 return; |
| 383 } | 383 } |
| 384 | 384 |
| 385 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s
uccessCallback, errorCallback, m_context, this, absolutePath, true)); | 385 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntryCallbacks::create(s
uccessCallback, errorCallback, m_context, this, absolutePath, true)); |
| 386 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 386 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
| 387 | 387 |
| 388 if (flags.createFlag()) | 388 if (flags.createFlag()) |
| 389 fileSystem()->createDirectory(createFileSystemURL(absolutePath), flags.e
xclusive(), std::move(callbacks)); | 389 fileSystem()->createDirectory(createFileSystemURL(absolutePath), flags.e
xclusive(), std::move(callbacks)); |
| 390 else | 390 else |
| 391 fileSystem()->directoryExists(createFileSystemURL(absolutePath), std::mo
ve(callbacks)); | 391 fileSystem()->directoryExists(createFileSystemURL(absolutePath), std::mo
ve(callbacks)); |
| 392 } | 392 } |
| 393 | 393 |
| 394 int DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader, const String&
path, EntriesCallback* successCallback, ErrorCallback* errorCallback, Synchronou
sType synchronousType) | 394 int DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader, const String&
path, EntriesCallback* successCallback, ErrorCallback* errorCallback, Synchronou
sType synchronousType) |
| 395 { | 395 { |
| 396 if (!fileSystem()) { | 396 if (!fileSystem()) { |
| 397 reportError(errorCallback, FileError::create(FileError::ABORT_ERR)); | 397 reportError(errorCallback, FileError::ABORT_ERR); |
| 398 return 0; | 398 return 0; |
| 399 } | 399 } |
| 400 | 400 |
| 401 ASSERT(DOMFilePath::isAbsolute(path)); | 401 ASSERT(DOMFilePath::isAbsolute(path)); |
| 402 | 402 |
| 403 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntriesCallbacks::create
(successCallback, errorCallback, m_context, reader, path)); | 403 std::unique_ptr<AsyncFileSystemCallbacks> callbacks(EntriesCallbacks::create
(successCallback, errorCallback, m_context, reader, path)); |
| 404 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); | 404 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); |
| 405 | 405 |
| 406 return fileSystem()->readDirectory(createFileSystemURL(path), std::move(call
backs)); | 406 return fileSystem()->readDirectory(createFileSystemURL(path), std::move(call
backs)); |
| 407 } | 407 } |
| 408 | 408 |
| 409 bool DOMFileSystemBase::waitForAdditionalResult(int callbacksId) | 409 bool DOMFileSystemBase::waitForAdditionalResult(int callbacksId) |
| 410 { | 410 { |
| 411 if (!fileSystem()) | 411 if (!fileSystem()) |
| 412 return false; | 412 return false; |
| 413 return fileSystem()->waitForAdditionalResult(callbacksId); | 413 return fileSystem()->waitForAdditionalResult(callbacksId); |
| 414 } | 414 } |
| 415 | 415 |
| 416 } // namespace blink | 416 } // namespace blink |
| OLD | NEW |