| 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 "webkit/fileapi/sandbox_mount_point_provider.h" | 5 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 FileSystemType type, | 290 FileSystemType type, |
| 291 const FilePath& old_base_path, | 291 const FilePath& old_base_path, |
| 292 bool create, | 292 bool create, |
| 293 base::PlatformFileError* error_ptr) { | 293 base::PlatformFileError* error_ptr) { |
| 294 DCHECK(error_ptr); | 294 DCHECK(error_ptr); |
| 295 MigrateIfNeeded(file_util, old_base_path); | 295 MigrateIfNeeded(file_util, old_base_path); |
| 296 | 296 |
| 297 FilePath root_path = | 297 FilePath root_path = |
| 298 file_util->GetDirectoryForOriginAndType( | 298 file_util->GetDirectoryForOriginAndType( |
| 299 origin_url, type, create, error_ptr); | 299 origin_url, type, create, error_ptr); |
| 300 if (root_path.empty()) { | 300 if (*error_ptr != base::PLATFORM_FILE_OK) { |
| 301 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, | 301 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, |
| 302 kCreateDirectoryError, | 302 kCreateDirectoryError, |
| 303 kFileSystemErrorMax); | 303 kFileSystemErrorMax); |
| 304 } else { | 304 } else { |
| 305 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, kOK, kFileSystemErrorMax); | 305 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, kOK, kFileSystemErrorMax); |
| 306 } | 306 } |
| 307 // The reference of file_util will be derefed on the FILE thread | 307 // The reference of file_util will be derefed on the FILE thread |
| 308 // when the storage of this callback gets deleted regardless of whether | 308 // when the storage of this callback gets deleted regardless of whether |
| 309 // this method is called or not. | 309 // this method is called or not. |
| 310 } | 310 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 SandboxMountPointProvider::GetFileSystemRootPathOnFileThread( | 379 SandboxMountPointProvider::GetFileSystemRootPathOnFileThread( |
| 380 const GURL& origin_url, FileSystemType type, const FilePath& unused, | 380 const GURL& origin_url, FileSystemType type, const FilePath& unused, |
| 381 bool create) { | 381 bool create) { |
| 382 if (file_system_options_.is_incognito()) | 382 if (file_system_options_.is_incognito()) |
| 383 // TODO(kinuko): return an isolated temporary directory. | 383 // TODO(kinuko): return an isolated temporary directory. |
| 384 return FilePath(); | 384 return FilePath(); |
| 385 | 385 |
| 386 if (!IsAllowedScheme(origin_url)) | 386 if (!IsAllowedScheme(origin_url)) |
| 387 return FilePath(); | 387 return FilePath(); |
| 388 | 388 |
| 389 MigrateIfNeeded(sandbox_file_util_.get(), old_base_path()); | 389 return GetBaseDirectoryForOriginAndType(origin_url, type, create); |
| 390 | |
| 391 return sandbox_file_util_->GetDirectoryForOriginAndType( | |
| 392 origin_url, type, create); | |
| 393 } | 390 } |
| 394 | 391 |
| 395 bool SandboxMountPointProvider::IsAccessAllowed(const GURL& origin_url, | 392 bool SandboxMountPointProvider::IsAccessAllowed(const GURL& origin_url, |
| 396 FileSystemType type, | 393 FileSystemType type, |
| 397 const FilePath& unused) { | 394 const FilePath& unused) { |
| 398 if (type != kFileSystemTypeTemporary && type != kFileSystemTypePersistent) | 395 if (type != kFileSystemTypeTemporary && type != kFileSystemTypePersistent) |
| 399 return false; | 396 return false; |
| 400 // We essentially depend on quota to do our access controls, so here | 397 // We essentially depend on quota to do our access controls, so here |
| 401 // we only check if the requested scheme is allowed or not. | 398 // we only check if the requested scheme is allowed or not. |
| 402 return IsAllowedScheme(origin_url); | 399 return IsAllowedScheme(origin_url); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 SandboxMountPointProvider::CreateOriginEnumerator() const { | 472 SandboxMountPointProvider::CreateOriginEnumerator() const { |
| 476 MigrateIfNeeded(sandbox_file_util_.get(), old_base_path()); | 473 MigrateIfNeeded(sandbox_file_util_.get(), old_base_path()); |
| 477 return new ObfuscatedOriginEnumerator(sandbox_file_util_.get()); | 474 return new ObfuscatedOriginEnumerator(sandbox_file_util_.get()); |
| 478 } | 475 } |
| 479 | 476 |
| 480 FilePath SandboxMountPointProvider::GetBaseDirectoryForOriginAndType( | 477 FilePath SandboxMountPointProvider::GetBaseDirectoryForOriginAndType( |
| 481 const GURL& origin_url, fileapi::FileSystemType type, bool create) const { | 478 const GURL& origin_url, fileapi::FileSystemType type, bool create) const { |
| 482 | 479 |
| 483 MigrateIfNeeded(sandbox_file_util_.get(), old_base_path()); | 480 MigrateIfNeeded(sandbox_file_util_.get(), old_base_path()); |
| 484 | 481 |
| 485 return sandbox_file_util_->GetDirectoryForOriginAndType( | 482 base::PlatformFileError error = base::PLATFORM_FILE_OK; |
| 486 origin_url, type, create); | 483 FilePath path = sandbox_file_util_->GetDirectoryForOriginAndType( |
| 484 origin_url, type, create, &error); |
| 485 if (error != base::PLATFORM_FILE_OK) |
| 486 return FilePath(); |
| 487 return path; |
| 487 } | 488 } |
| 488 | 489 |
| 489 bool SandboxMountPointProvider::DeleteOriginDataOnFileThread( | 490 bool SandboxMountPointProvider::DeleteOriginDataOnFileThread( |
| 490 FileSystemContext* file_system_context, | 491 FileSystemContext* file_system_context, |
| 491 QuotaManagerProxy* proxy, | 492 QuotaManagerProxy* proxy, |
| 492 const GURL& origin_url, | 493 const GURL& origin_url, |
| 493 fileapi::FileSystemType type) { | 494 fileapi::FileSystemType type) { |
| 494 MigrateIfNeeded(sandbox_file_util_.get(), old_base_path()); | 495 MigrateIfNeeded(sandbox_file_util_.get(), old_base_path()); |
| 495 | 496 |
| 496 int64 usage = GetOriginUsageOnFileThread(file_system_context, | 497 int64 usage = GetOriginUsageOnFileThread(file_system_context, |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 break; | 730 break; |
| 730 case base::PLATFORM_FILE_ERROR_FAILED: | 731 case base::PLATFORM_FILE_ERROR_FAILED: |
| 731 default: | 732 default: |
| 732 REPORT(kUnknownError); | 733 REPORT(kUnknownError); |
| 733 break; | 734 break; |
| 734 } | 735 } |
| 735 #undef REPORT | 736 #undef REPORT |
| 736 } | 737 } |
| 737 | 738 |
| 738 } // namespace fileapi | 739 } // namespace fileapi |
| OLD | NEW |