summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_usage_tracker.cc
diff options
context:
space:
mode:
authordmikurube@google.com <dmikurube@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 19:13:53 +0000
committerdmikurube@google.com <dmikurube@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 19:13:53 +0000
commitd1ca70cfc72762d6ff489f2558e6eb1333cbabf2 (patch)
tree667d1630cd6d51842b83da12b6de2e39a752882d /webkit/fileapi/file_system_usage_tracker.cc
parentb05168f7a95d5a2841297e5947eccf5edcea804a (diff)
downloadchromium_src-d1ca70cfc72762d6ff489f2558e6eb1333cbabf2.zip
chromium_src-d1ca70cfc72762d6ff489f2558e6eb1333cbabf2.tar.gz
chromium_src-d1ca70cfc72762d6ff489f2558e6eb1333cbabf2.tar.bz2
Add a function for usage tracking. It's based on the bug 6426001.
BUG= TEST= Review URL: http://codereview.chromium.org/6453001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76578 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));