| 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/browser/fileapi/sandbox_file_system_backend.h" | 5 #include "webkit/browser/fileapi/sandbox_file_system_backend.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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 if (!enable_usage_tracking_) | 396 if (!enable_usage_tracking_) |
| 397 return 0; | 397 return 0; |
| 398 | 398 |
| 399 // Don't use usage cache and return recalculated usage for sticky invalidated | 399 // Don't use usage cache and return recalculated usage for sticky invalidated |
| 400 // origins. | 400 // origins. |
| 401 if (ContainsKey(sticky_dirty_origins_, std::make_pair(origin_url, type))) | 401 if (ContainsKey(sticky_dirty_origins_, std::make_pair(origin_url, type))) |
| 402 return RecalculateUsage(file_system_context, origin_url, type); | 402 return RecalculateUsage(file_system_context, origin_url, type); |
| 403 | 403 |
| 404 base::FilePath base_path = | 404 base::FilePath base_path = |
| 405 GetBaseDirectoryForOriginAndType(origin_url, type, false); | 405 GetBaseDirectoryForOriginAndType(origin_url, type, false); |
| 406 if (base_path.empty() || !file_util::DirectoryExists(base_path)) | 406 if (base_path.empty() || !base::DirectoryExists(base_path)) |
| 407 return 0; | 407 return 0; |
| 408 base::FilePath usage_file_path = | 408 base::FilePath usage_file_path = |
| 409 base_path.Append(FileSystemUsageCache::kUsageFileName); | 409 base_path.Append(FileSystemUsageCache::kUsageFileName); |
| 410 | 410 |
| 411 bool is_valid = usage_cache()->IsValid(usage_file_path); | 411 bool is_valid = usage_cache()->IsValid(usage_file_path); |
| 412 uint32 dirty_status = 0; | 412 uint32 dirty_status = 0; |
| 413 bool dirty_status_available = | 413 bool dirty_status_available = |
| 414 usage_cache()->GetDirty(usage_file_path, &dirty_status); | 414 usage_cache()->GetDirty(usage_file_path, &dirty_status); |
| 415 bool visited = !visited_origins_.insert(origin_url).second; | 415 bool visited = !visited_origins_.insert(origin_url).second; |
| 416 if (is_valid && (dirty_status == 0 || (dirty_status_available && visited))) { | 416 if (is_valid && (dirty_status == 0 || (dirty_status_available && visited))) { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 | 657 |
| 658 while (!(file_path_each = enumerator->Next()).empty()) { | 658 while (!(file_path_each = enumerator->Next()).empty()) { |
| 659 usage += enumerator->Size(); | 659 usage += enumerator->Size(); |
| 660 usage += ObfuscatedFileUtil::ComputeFilePathCost(file_path_each); | 660 usage += ObfuscatedFileUtil::ComputeFilePathCost(file_path_each); |
| 661 } | 661 } |
| 662 | 662 |
| 663 return usage; | 663 return usage; |
| 664 } | 664 } |
| 665 | 665 |
| 666 } // namespace fileapi | 666 } // namespace fileapi |
| OLD | NEW |