diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-10 13:17:58 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-10 13:17:58 +0000 |
commit | 955dd7ebf6808dd93dd1aedc7390e7280e848f80 (patch) | |
tree | 6a9e559583084a956005c367249026647e3879bf /webkit/fileapi/file_system_path_manager.cc | |
parent | 0c5e07b0a63a5aea8ab0c2b50177b4c99e7c9538 (diff) | |
download | chromium_src-955dd7ebf6808dd93dd1aedc7390e7280e848f80.zip chromium_src-955dd7ebf6808dd93dd1aedc7390e7280e848f80.tar.gz chromium_src-955dd7ebf6808dd93dd1aedc7390e7280e848f80.tar.bz2 |
Add 1st cut of FileSystemUsageTracker that tracks the usage changes in FileSystem API.
For now it has no meaningful implementation yet; mostly just for
defining a few interfaces.
BUG=
TEST=FileSystemUsageTrackerTest.DummyTest
Review URL: http://codereview.chromium.org/6426001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74429 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_path_manager.cc')
-rw-r--r-- | webkit/fileapi/file_system_path_manager.cc | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/webkit/fileapi/file_system_path_manager.cc b/webkit/fileapi/file_system_path_manager.cc index 72c5355..3e0cd5e 100644 --- a/webkit/fileapi/file_system_path_manager.cc +++ b/webkit/fileapi/file_system_path_manager.cc @@ -77,6 +77,14 @@ FilePath::StringType CreateUniqueDirectoryName(const GURL& origin_url) { static const char kExtensionScheme[] = "chrome-extension"; +inline std::string GetFileSystemTypeString(fileapi::FileSystemType type) { + if (type == fileapi::kFileSystemTypeTemporary) + return fileapi::FileSystemPathManager::kTemporaryName; + else if (type == fileapi::kFileSystemTypePersistent) + return fileapi::FileSystemPathManager::kPersistentName; + return std::string(); +} + } // anonymous namespace class FileSystemPathManager::GetFileSystemRootPathTask @@ -198,29 +206,17 @@ void FileSystemPathManager::GetFileSystemRootPath( return; } - if (type != fileapi::kFileSystemTypeTemporary && - type != fileapi::kFileSystemTypePersistent) { - LOG(WARNING) << "Unknown filesystem type is requested:" << type; + FilePath origin_base_path = GetFileSystemBaseDirectoryForOriginAndType( + base_path(), origin_url, type); + if (origin_base_path.empty()) { callback->Run(false, FilePath(), std::string()); return; } - std::string storage_identifier = GetStorageIdentifierFromURL(origin_url); - - std::string type_string; - if (type == fileapi::kFileSystemTypeTemporary) - type_string = kTemporaryName; - else if (type == fileapi::kFileSystemTypePersistent) - type_string = kPersistentName; - DCHECK(!type_string.empty()); - - FilePath origin_base_path = base_path_.AppendASCII(storage_identifier) - .AppendASCII(type_string); - std::string name = storage_identifier + ":" + type_string; - scoped_refptr<GetFileSystemRootPathTask> task( new GetFileSystemRootPathTask(file_message_loop_, - name, callback.release())); + GetFileSystemName(origin_url, type), + callback.release())); task->Start(origin_url, origin_base_path, create); } @@ -326,6 +322,14 @@ bool FileSystemPathManager::IsAllowedScheme(const GURL& url) const { (url.SchemeIsFile() && allow_file_access_from_files_); } +// static +std::string FileSystemPathManager::GetFileSystemName( + const GURL& origin_url, fileapi::FileSystemType type) { + return GetStorageIdentifierFromURL(origin_url) + .append(":").append(GetFileSystemTypeString(type)); +} + +// static std::string FileSystemPathManager::GetStorageIdentifierFromURL( const GURL& url) { WebKit::WebSecurityOrigin web_security_origin = @@ -333,6 +337,21 @@ std::string FileSystemPathManager::GetStorageIdentifierFromURL( return web_security_origin.databaseIdentifier().utf8(); } +// static +FilePath FileSystemPathManager::GetFileSystemBaseDirectoryForOriginAndType( + const FilePath& base_path, const GURL& origin_url, + fileapi::FileSystemType type) { + if (!origin_url.is_valid()) + return FilePath(); + std::string type_string = GetFileSystemTypeString(type); + if (type_string.empty()) { + LOG(WARNING) << "Unknown filesystem type is requested:" << type; + return FilePath(); + } + return base_path.AppendASCII(GetStorageIdentifierFromURL(origin_url)) + .AppendASCII(type_string); +} + } // namespace fileapi COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ |