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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 } | 515 } |
516 | 516 |
517 int64 SandboxMountPointProvider::GetOriginUsageOnFileThread( | 517 int64 SandboxMountPointProvider::GetOriginUsageOnFileThread( |
518 const GURL& origin_url, fileapi::FileSystemType type) { | 518 const GURL& origin_url, fileapi::FileSystemType type) { |
519 DCHECK(type == kFileSystemTypeTemporary || | 519 DCHECK(type == kFileSystemTypeTemporary || |
520 type == kFileSystemTypePersistent); | 520 type == kFileSystemTypePersistent); |
521 FilePath base_path = | 521 FilePath base_path = |
522 GetBaseDirectoryForOriginAndType(origin_url, type, false); | 522 GetBaseDirectoryForOriginAndType(origin_url, type, false); |
523 if (base_path.empty() || !file_util::DirectoryExists(base_path)) return 0; | 523 if (base_path.empty() || !file_util::DirectoryExists(base_path)) return 0; |
524 FilePath usage_file_path = | 524 FilePath usage_file_path = |
525 base_path.AppendASCII(FileSystemUsageCache::kUsageFileName); | 525 base_path.Append(FileSystemUsageCache::kUsageFileName); |
526 | 526 |
527 bool is_valid = FileSystemUsageCache::IsValid(usage_file_path); | 527 bool is_valid = FileSystemUsageCache::IsValid(usage_file_path); |
528 int32 dirty_status = FileSystemUsageCache::GetDirty(usage_file_path); | 528 int32 dirty_status = FileSystemUsageCache::GetDirty(usage_file_path); |
529 bool visited = (visited_origins_.find(origin_url) != visited_origins_.end()); | 529 bool visited = (visited_origins_.find(origin_url) != visited_origins_.end()); |
530 visited_origins_.insert(origin_url); | 530 visited_origins_.insert(origin_url); |
531 if (is_valid && (dirty_status == 0 || (dirty_status > 0 && visited))) { | 531 if (is_valid && (dirty_status == 0 || (dirty_status > 0 && visited))) { |
532 // The usage cache is clean (dirty == 0) or the origin is already | 532 // The usage cache is clean (dirty == 0) or the origin is already |
533 // initialized and running. Read the cache file to get the usage. | 533 // initialized and running. Read the cache file to get the usage. |
534 return FileSystemUsageCache::GetUsage(usage_file_path); | 534 return FileSystemUsageCache::GetUsage(usage_file_path); |
535 } | 535 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 origin_url, type); | 614 origin_url, type); |
615 FileSystemUsageCache::IncrementDirty(usage_file_path); | 615 FileSystemUsageCache::IncrementDirty(usage_file_path); |
616 } | 616 } |
617 | 617 |
618 FilePath SandboxMountPointProvider::GetUsageCachePathForOriginAndType( | 618 FilePath SandboxMountPointProvider::GetUsageCachePathForOriginAndType( |
619 const GURL& origin_url, fileapi::FileSystemType type) const { | 619 const GURL& origin_url, fileapi::FileSystemType type) const { |
620 FilePath base_path = | 620 FilePath base_path = |
621 GetBaseDirectoryForOriginAndType(origin_url, type, false); | 621 GetBaseDirectoryForOriginAndType(origin_url, type, false); |
622 if (base_path.empty()) | 622 if (base_path.empty()) |
623 return FilePath(); | 623 return FilePath(); |
624 return base_path.AppendASCII(FileSystemUsageCache::kUsageFileName); | 624 return base_path.Append(FileSystemUsageCache::kUsageFileName); |
625 } | 625 } |
626 | 626 |
627 FilePath SandboxMountPointProvider::OldCreateFileSystemRootPath( | 627 FilePath SandboxMountPointProvider::OldCreateFileSystemRootPath( |
628 const GURL& origin_url, fileapi::FileSystemType type) { | 628 const GURL& origin_url, fileapi::FileSystemType type) { |
629 FilePath origin_base_path = | 629 FilePath origin_base_path = |
630 OldGetBaseDirectoryForOriginAndType(old_base_path(), origin_url, type); | 630 OldGetBaseDirectoryForOriginAndType(old_base_path(), origin_url, type); |
631 DCHECK(!origin_base_path.empty()); | 631 DCHECK(!origin_base_path.empty()); |
632 | 632 |
633 FilePath root; | 633 FilePath root; |
634 base::PlatformFileError result = | 634 base::PlatformFileError result = |
(...skipping 26 matching lines...) Expand all Loading... |
661 i < file_system_options_.additional_allowed_schemes().size(); | 661 i < file_system_options_.additional_allowed_schemes().size(); |
662 ++i) { | 662 ++i) { |
663 if (url.SchemeIs( | 663 if (url.SchemeIs( |
664 file_system_options_.additional_allowed_schemes()[i].c_str())) | 664 file_system_options_.additional_allowed_schemes()[i].c_str())) |
665 return true; | 665 return true; |
666 } | 666 } |
667 return false; | 667 return false; |
668 } | 668 } |
669 | 669 |
670 } // namespace fileapi | 670 } // namespace fileapi |
OLD | NEW |