summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_usage_tracker.cc
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 20:36:25 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 20:36:25 +0000
commite1dd075eb55377ebe37f0a178681c8c1d421df52 (patch)
treee94ab48ce4d6faf5e34d1b9b76f9ea34ad88315f /webkit/fileapi/file_system_usage_tracker.cc
parent6917161dc18984bbadc969d60bb60be4105a6fca (diff)
downloadchromium_src-e1dd075eb55377ebe37f0a178681c8c1d421df52.zip
chromium_src-e1dd075eb55377ebe37f0a178681c8c1d421df52.tar.gz
chromium_src-e1dd075eb55377ebe37f0a178681c8c1d421df52.tar.bz2
Add a function for usage tracking.
BUG= TEST= Review URL: http://codereview.chromium.org/6453001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76797 0039d316-1c4b-4281-b951-d872f2087c98
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));