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-02-16 07:24:48 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-16 07:24:48 +0000
commitb4bbe9ad1ec0320b73e0914a6fc24ac514b30844 (patch)
tree44fe4361486ef35c5e538228a4762a2cf764a602 /webkit/fileapi/file_system_usage_tracker.cc
parentcf1d3ee8cef29833d62a149b721dd31ff7cd17f2 (diff)
downloadchromium_src-b4bbe9ad1ec0320b73e0914a6fc24ac514b30844.zip
chromium_src-b4bbe9ad1ec0320b73e0914a6fc24ac514b30844.tar.gz
chromium_src-b4bbe9ad1ec0320b73e0914a6fc24ac514b30844.tar.bz2
Make more methods of FileSystemPathManager static and portable.
Changes: - Renamed StorageIdentifier to OriginIdentifier to better reflect its meaning. - Changed a few methods to take string origin identifier but not origin URL as its parameter, since in some cases it seems to be more convenient just to use the identifier string (which can be easily extracted from the path) than to call WebKit method to convert back the identifier to GURL. BUG=none TEST=FileSystemPathManagerTest.* Review URL: http://codereview.chromium.org/6483017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75077 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_usage_tracker.cc')
-rw-r--r--webkit/fileapi/file_system_usage_tracker.cc31
1 files changed, 18 insertions, 13 deletions
diff --git a/webkit/fileapi/file_system_usage_tracker.cc b/webkit/fileapi/file_system_usage_tracker.cc
index 2b16a1f..f58e4aa 100644
--- a/webkit/fileapi/file_system_usage_tracker.cc
+++ b/webkit/fileapi/file_system_usage_tracker.cc
@@ -23,13 +23,13 @@ class FileSystemUsageTracker::GetUsageTask
GetUsageTask(
FileSystemUsageTracker* tracker,
scoped_refptr<base::MessageLoopProxy> file_message_loop,
- std::string fs_name,
+ std::string fs_identifier,
const FilePath& origin_base_path)
: tracker_(tracker),
file_message_loop_(file_message_loop),
original_message_loop_(
base::MessageLoopProxy::CreateForCurrentThread()),
- fs_name_(fs_name),
+ fs_identifier_(fs_identifier),
fs_usage_(0),
origin_base_path_(origin_base_path) {
}
@@ -62,14 +62,14 @@ class FileSystemUsageTracker::GetUsageTask
DCHECK(original_message_loop_->BelongsToCurrentThread());
if (tracker_) {
tracker_->UnregisterUsageTask(this);
- tracker_->DidGetOriginUsage(fs_name_, fs_usage_);
+ tracker_->DidGetOriginUsage(fs_identifier_, fs_usage_);
}
}
FileSystemUsageTracker* tracker_;
scoped_refptr<base::MessageLoopProxy> file_message_loop_;
scoped_refptr<base::MessageLoopProxy> original_message_loop_;
- std::string fs_name_;
+ std::string fs_identifier_;
int64 fs_usage_;
FilePath origin_base_path_;
};
@@ -104,13 +104,17 @@ void FileSystemUsageTracker::GetOriginUsage(
return;
}
- std::string fs_name = FileSystemPathManager::GetFileSystemName(
- origin_url, type);
- if (pending_usage_callbacks_.find(fs_name) !=
+ std::string origin_identifier =
+ FileSystemPathManager::GetOriginIdentifierFromURL(origin_url);
+ std::string type_string =
+ FileSystemPathManager::GetFileSystemTypeString(type);
+ std::string fs_identifier = origin_identifier + ":" + type_string;
+
+ if (pending_usage_callbacks_.find(fs_identifier) !=
pending_usage_callbacks_.end()) {
// Another get usage task is running. Add the callback to
// the pending queue and return.
- pending_usage_callbacks_[fs_name].push_back(callback.release());
+ pending_usage_callbacks_[fs_identifier].push_back(callback.release());
return;
}
@@ -118,16 +122,17 @@ void FileSystemUsageTracker::GetOriginUsage(
// without unique part).
FilePath origin_base_path =
FileSystemPathManager::GetFileSystemBaseDirectoryForOriginAndType(
- base_path_, origin_url, type);
+ base_path_, origin_identifier, type);
if (origin_base_path.empty()) {
// The directory does not exist.
callback->Run(0);
return;
}
- pending_usage_callbacks_[fs_name].push_back(callback.release());
+ pending_usage_callbacks_[fs_identifier].push_back(callback.release());
scoped_refptr<GetUsageTask> task(
- new GetUsageTask(this, file_message_loop_, fs_name, origin_base_path));
+ new GetUsageTask(this, file_message_loop_, fs_identifier,
+ origin_base_path));
task->Start();
}
@@ -141,9 +146,9 @@ void FileSystemUsageTracker::UnregisterUsageTask(GetUsageTask* task) {
}
void FileSystemUsageTracker::DidGetOriginUsage(
- const std::string& fs_name, int64 usage) {
+ const std::string& fs_identifier, int64 usage) {
PendingUsageCallbackMap::iterator cb_list_iter =
- pending_usage_callbacks_.find(fs_name);
+ pending_usage_callbacks_.find(fs_identifier);
DCHECK(cb_list_iter != pending_usage_callbacks_.end());
PendingCallbackList cb_list = cb_list_iter->second;
for (PendingCallbackList::iterator cb_iter = cb_list.begin();