summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_usage_tracker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/fileapi/file_system_usage_tracker.cc')
-rw-r--r--webkit/fileapi/file_system_usage_tracker.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/webkit/fileapi/file_system_usage_tracker.cc b/webkit/fileapi/file_system_usage_tracker.cc
index f58e4aa..9456f2a 100644
--- a/webkit/fileapi/file_system_usage_tracker.cc
+++ b/webkit/fileapi/file_system_usage_tracker.cc
@@ -14,6 +14,7 @@
#include "base/task.h"
#include "googleurl/src/gurl.h"
#include "webkit/fileapi/file_system_path_manager.h"
+#include "webkit/fileapi/file_system_usage_cache.h"
namespace fileapi {
@@ -52,7 +53,24 @@ class FileSystemUsageTracker::GetUsageTask
void RunOnFileThread() {
DCHECK(file_message_loop_->BelongsToCurrentThread());
- // TODO(dmikurube): add the code that retrieves the origin usage here.
+ if (!file_util::DirectoryExists(origin_base_path_))
+ fs_usage_ = 0;
+ else {
+ FilePath usage_file_path = origin_base_path_.AppendASCII(
+ FileSystemUsageCache::kUsageFileName);
+ fs_usage_ = FileSystemUsageCache::GetUsage(usage_file_path);
+
+ if (fs_usage_ < 0) {
+ FilePath content_file_path = origin_base_path_;
+ if (FileSystemUsageCache::Exists(usage_file_path))
+ FileSystemUsageCache::Delete(usage_file_path);
+ fs_usage_ = file_util::ComputeDirectorySize(content_file_path);
+ // fs_usage_ will include the size of .usage.
+ // The result of ComputeDirectorySize does not include it.
+ fs_usage_ += FileSystemUsageCache::kUsageFileSize;
+ FileSystemUsageCache::UpdateUsage(usage_file_path, fs_usage_);
+ }
+ }
original_message_loop_->PostTask(
FROM_HERE, NewRunnableMethod(this, &GetUsageTask::Completed));