OLD | NEW |
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 "storage/browser/fileapi/file_system_context.h" | 5 #include "storage/browser/fileapi/file_system_context.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // Additional mount points must be added before regular system-wide | 201 // Additional mount points must be added before regular system-wide |
202 // mount points. | 202 // mount points. |
203 if (external_mount_points) | 203 if (external_mount_points) |
204 url_crackers_.push_back(external_mount_points); | 204 url_crackers_.push_back(external_mount_points); |
205 url_crackers_.push_back(ExternalMountPoints::GetSystemInstance()); | 205 url_crackers_.push_back(ExternalMountPoints::GetSystemInstance()); |
206 url_crackers_.push_back(IsolatedContext::GetInstance()); | 206 url_crackers_.push_back(IsolatedContext::GetInstance()); |
207 } | 207 } |
208 | 208 |
209 bool FileSystemContext::DeleteDataForOriginOnFileTaskRunner( | 209 bool FileSystemContext::DeleteDataForOriginOnFileTaskRunner( |
210 const GURL& origin_url) { | 210 const GURL& origin_url) { |
211 DCHECK(default_file_task_runner()->RunsTasksOnCurrentThread()); | 211 DCHECK(default_file_task_runner()->RunsTasksInCurrentSequence()); |
212 DCHECK(origin_url == origin_url.GetOrigin()); | 212 DCHECK(origin_url == origin_url.GetOrigin()); |
213 | 213 |
214 bool success = true; | 214 bool success = true; |
215 for (FileSystemBackendMap::iterator iter = backend_map_.begin(); | 215 for (FileSystemBackendMap::iterator iter = backend_map_.begin(); |
216 iter != backend_map_.end(); | 216 iter != backend_map_.end(); |
217 ++iter) { | 217 ++iter) { |
218 FileSystemBackend* backend = iter->second; | 218 FileSystemBackend* backend = iter->second; |
219 if (!backend->GetQuotaUtil()) | 219 if (!backend->GetQuotaUtil()) |
220 continue; | 220 continue; |
221 if (backend->GetQuotaUtil()->DeleteOriginDataOnFileTaskRunner( | 221 if (backend->GetQuotaUtil()->DeleteOriginDataOnFileTaskRunner( |
222 this, quota_manager_proxy(), origin_url, iter->first) | 222 this, quota_manager_proxy(), origin_url, iter->first) |
223 != base::File::FILE_OK) { | 223 != base::File::FILE_OK) { |
224 // Continue the loop, but record the failure. | 224 // Continue the loop, but record the failure. |
225 success = false; | 225 success = false; |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 return success; | 229 return success; |
230 } | 230 } |
231 | 231 |
232 scoped_refptr<QuotaReservation> | 232 scoped_refptr<QuotaReservation> |
233 FileSystemContext::CreateQuotaReservationOnFileTaskRunner( | 233 FileSystemContext::CreateQuotaReservationOnFileTaskRunner( |
234 const GURL& origin_url, | 234 const GURL& origin_url, |
235 FileSystemType type) { | 235 FileSystemType type) { |
236 DCHECK(default_file_task_runner()->RunsTasksOnCurrentThread()); | 236 DCHECK(default_file_task_runner()->RunsTasksInCurrentSequence()); |
237 FileSystemBackend* backend = GetFileSystemBackend(type); | 237 FileSystemBackend* backend = GetFileSystemBackend(type); |
238 if (!backend || !backend->GetQuotaUtil()) | 238 if (!backend || !backend->GetQuotaUtil()) |
239 return scoped_refptr<QuotaReservation>(); | 239 return scoped_refptr<QuotaReservation>(); |
240 return backend->GetQuotaUtil()->CreateQuotaReservationOnFileTaskRunner( | 240 return backend->GetQuotaUtil()->CreateQuotaReservationOnFileTaskRunner( |
241 origin_url, type); | 241 origin_url, type); |
242 } | 242 } |
243 | 243 |
244 void FileSystemContext::Shutdown() { | 244 void FileSystemContext::Shutdown() { |
245 if (!io_task_runner_->RunsTasksOnCurrentThread()) { | 245 if (!io_task_runner_->RunsTasksInCurrentSequence()) { |
246 io_task_runner_->PostTask( | 246 io_task_runner_->PostTask( |
247 FROM_HERE, base::Bind(&FileSystemContext::Shutdown, | 247 FROM_HERE, base::Bind(&FileSystemContext::Shutdown, |
248 make_scoped_refptr(this))); | 248 make_scoped_refptr(this))); |
249 return; | 249 return; |
250 } | 250 } |
251 operation_runner_->Shutdown(); | 251 operation_runner_->Shutdown(); |
252 } | 252 } |
253 | 253 |
254 FileSystemQuotaUtil* | 254 FileSystemQuotaUtil* |
255 FileSystemContext::GetQuotaUtil(FileSystemType type) const { | 255 FileSystemContext::GetQuotaUtil(FileSystemType type) const { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 FileSystemContext::external_backend() const { | 331 FileSystemContext::external_backend() const { |
332 return static_cast<ExternalFileSystemBackend*>( | 332 return static_cast<ExternalFileSystemBackend*>( |
333 GetFileSystemBackend(kFileSystemTypeExternal)); | 333 GetFileSystemBackend(kFileSystemTypeExternal)); |
334 } | 334 } |
335 | 335 |
336 void FileSystemContext::OpenFileSystem( | 336 void FileSystemContext::OpenFileSystem( |
337 const GURL& origin_url, | 337 const GURL& origin_url, |
338 FileSystemType type, | 338 FileSystemType type, |
339 OpenFileSystemMode mode, | 339 OpenFileSystemMode mode, |
340 const OpenFileSystemCallback& callback) { | 340 const OpenFileSystemCallback& callback) { |
341 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 341 DCHECK(io_task_runner_->RunsTasksInCurrentSequence()); |
342 DCHECK(!callback.is_null()); | 342 DCHECK(!callback.is_null()); |
343 | 343 |
344 if (!FileSystemContext::IsSandboxFileSystem(type)) { | 344 if (!FileSystemContext::IsSandboxFileSystem(type)) { |
345 // Disallow opening a non-sandboxed filesystem. | 345 // Disallow opening a non-sandboxed filesystem. |
346 callback.Run(GURL(), std::string(), base::File::FILE_ERROR_SECURITY); | 346 callback.Run(GURL(), std::string(), base::File::FILE_ERROR_SECURITY); |
347 return; | 347 return; |
348 } | 348 } |
349 | 349 |
350 FileSystemBackend* backend = GetFileSystemBackend(type); | 350 FileSystemBackend* backend = GetFileSystemBackend(type); |
351 if (!backend) { | 351 if (!backend) { |
352 callback.Run(GURL(), std::string(), base::File::FILE_ERROR_SECURITY); | 352 callback.Run(GURL(), std::string(), base::File::FILE_ERROR_SECURITY); |
353 return; | 353 return; |
354 } | 354 } |
355 | 355 |
356 backend->ResolveURL( | 356 backend->ResolveURL( |
357 CreateCrackedFileSystemURL(origin_url, type, base::FilePath()), | 357 CreateCrackedFileSystemURL(origin_url, type, base::FilePath()), |
358 mode, | 358 mode, |
359 callback); | 359 callback); |
360 } | 360 } |
361 | 361 |
362 void FileSystemContext::ResolveURL( | 362 void FileSystemContext::ResolveURL( |
363 const FileSystemURL& url, | 363 const FileSystemURL& url, |
364 const ResolveURLCallback& callback) { | 364 const ResolveURLCallback& callback) { |
365 DCHECK(!callback.is_null()); | 365 DCHECK(!callback.is_null()); |
366 | 366 |
367 // If not on IO thread, forward before passing the task to the backend. | 367 // If not on IO thread, forward before passing the task to the backend. |
368 if (!io_task_runner_->RunsTasksOnCurrentThread()) { | 368 if (!io_task_runner_->RunsTasksInCurrentSequence()) { |
369 ResolveURLCallback relay_callback = | 369 ResolveURLCallback relay_callback = |
370 base::Bind(&RelayResolveURLCallback, | 370 base::Bind(&RelayResolveURLCallback, |
371 base::ThreadTaskRunnerHandle::Get(), callback); | 371 base::ThreadTaskRunnerHandle::Get(), callback); |
372 io_task_runner_->PostTask( | 372 io_task_runner_->PostTask( |
373 FROM_HERE, | 373 FROM_HERE, |
374 base::Bind(&FileSystemContext::ResolveURL, this, url, relay_callback)); | 374 base::Bind(&FileSystemContext::ResolveURL, this, url, relay_callback)); |
375 return; | 375 return; |
376 } | 376 } |
377 | 377 |
378 FileSystemBackend* backend = GetFileSystemBackend(url.type()); | 378 FileSystemBackend* backend = GetFileSystemBackend(url.type()); |
(...skipping 26 matching lines...) Expand all Loading... |
405 } | 405 } |
406 } | 406 } |
407 } | 407 } |
408 callback.Run(base::File::FILE_ERROR_NOT_FOUND); | 408 callback.Run(base::File::FILE_ERROR_NOT_FOUND); |
409 } | 409 } |
410 | 410 |
411 void FileSystemContext::DeleteFileSystem( | 411 void FileSystemContext::DeleteFileSystem( |
412 const GURL& origin_url, | 412 const GURL& origin_url, |
413 FileSystemType type, | 413 FileSystemType type, |
414 const StatusCallback& callback) { | 414 const StatusCallback& callback) { |
415 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 415 DCHECK(io_task_runner_->RunsTasksInCurrentSequence()); |
416 DCHECK(origin_url == origin_url.GetOrigin()); | 416 DCHECK(origin_url == origin_url.GetOrigin()); |
417 DCHECK(!callback.is_null()); | 417 DCHECK(!callback.is_null()); |
418 | 418 |
419 FileSystemBackend* backend = GetFileSystemBackend(type); | 419 FileSystemBackend* backend = GetFileSystemBackend(type); |
420 if (!backend) { | 420 if (!backend) { |
421 callback.Run(base::File::FILE_ERROR_SECURITY); | 421 callback.Run(base::File::FILE_ERROR_SECURITY); |
422 return; | 422 return; |
423 } | 423 } |
424 if (!backend->GetQuotaUtil()) { | 424 if (!backend->GetQuotaUtil()) { |
425 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 425 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 OpenFileSystemMode mode, | 503 OpenFileSystemMode mode, |
504 const StatusCallback& callback) { | 504 const StatusCallback& callback) { |
505 DCHECK(plugin_private_backend_); | 505 DCHECK(plugin_private_backend_); |
506 plugin_private_backend_->OpenPrivateFileSystem( | 506 plugin_private_backend_->OpenPrivateFileSystem( |
507 origin_url, type, filesystem_id, plugin_id, mode, callback); | 507 origin_url, type, filesystem_id, plugin_id, mode, callback); |
508 } | 508 } |
509 | 509 |
510 FileSystemContext::~FileSystemContext() { | 510 FileSystemContext::~FileSystemContext() { |
511 } | 511 } |
512 | 512 |
513 void FileSystemContext::DeleteOnCorrectThread() const { | 513 void FileSystemContext::DeleteOnCorrectSequence() const { |
514 if (!io_task_runner_->RunsTasksOnCurrentThread() && | 514 if (!io_task_runner_->RunsTasksInCurrentSequence() && |
515 io_task_runner_->DeleteSoon(FROM_HERE, this)) { | 515 io_task_runner_->DeleteSoon(FROM_HERE, this)) { |
516 return; | 516 return; |
517 } | 517 } |
518 delete this; | 518 delete this; |
519 } | 519 } |
520 | 520 |
521 FileSystemOperation* FileSystemContext::CreateFileSystemOperation( | 521 FileSystemOperation* FileSystemContext::CreateFileSystemOperation( |
522 const FileSystemURL& url, base::File::Error* error_code) { | 522 const FileSystemURL& url, base::File::Error* error_code) { |
523 if (!url.is_valid()) { | 523 if (!url.is_valid()) { |
524 if (error_code) | 524 if (error_code) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 } | 595 } |
596 } | 596 } |
597 } | 597 } |
598 | 598 |
599 void FileSystemContext::DidOpenFileSystemForResolveURL( | 599 void FileSystemContext::DidOpenFileSystemForResolveURL( |
600 const FileSystemURL& url, | 600 const FileSystemURL& url, |
601 const FileSystemContext::ResolveURLCallback& callback, | 601 const FileSystemContext::ResolveURLCallback& callback, |
602 const GURL& filesystem_root, | 602 const GURL& filesystem_root, |
603 const std::string& filesystem_name, | 603 const std::string& filesystem_name, |
604 base::File::Error error) { | 604 base::File::Error error) { |
605 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 605 DCHECK(io_task_runner_->RunsTasksInCurrentSequence()); |
606 | 606 |
607 if (error != base::File::FILE_OK) { | 607 if (error != base::File::FILE_OK) { |
608 callback.Run(error, FileSystemInfo(), base::FilePath(), | 608 callback.Run(error, FileSystemInfo(), base::FilePath(), |
609 FileSystemContext::RESOLVED_ENTRY_NOT_FOUND); | 609 FileSystemContext::RESOLVED_ENTRY_NOT_FOUND); |
610 return; | 610 return; |
611 } | 611 } |
612 | 612 |
613 storage::FileSystemInfo info( | 613 storage::FileSystemInfo info( |
614 filesystem_name, filesystem_root, url.mount_type()); | 614 filesystem_name, filesystem_root, url.mount_type()); |
615 | 615 |
(...skipping 11 matching lines...) Expand all Loading... |
627 | 627 |
628 // TODO(mtomasz): Not all fields should be required for ResolveURL. | 628 // TODO(mtomasz): Not all fields should be required for ResolveURL. |
629 operation_runner()->GetMetadata( | 629 operation_runner()->GetMetadata( |
630 url, FileSystemOperation::GET_METADATA_FIELD_IS_DIRECTORY | | 630 url, FileSystemOperation::GET_METADATA_FIELD_IS_DIRECTORY | |
631 FileSystemOperation::GET_METADATA_FIELD_SIZE | | 631 FileSystemOperation::GET_METADATA_FIELD_SIZE | |
632 FileSystemOperation::GET_METADATA_FIELD_LAST_MODIFIED, | 632 FileSystemOperation::GET_METADATA_FIELD_LAST_MODIFIED, |
633 base::Bind(&DidGetMetadataForResolveURL, path, callback, info)); | 633 base::Bind(&DidGetMetadataForResolveURL, path, callback, info)); |
634 } | 634 } |
635 | 635 |
636 } // namespace storage | 636 } // namespace storage |
OLD | NEW |