diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-20 12:42:44 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-20 12:42:44 +0000 |
commit | 3c48b53f15d8438e6cac36dc28cd491e488424a5 (patch) | |
tree | 4ff1bababd8bbde1036fffb4a2e38275e0e65898 /webkit | |
parent | fe5ed19f21f9773d8c93d115035097a5f72161f5 (diff) | |
download | chromium_src-3c48b53f15d8438e6cac36dc28cd491e488424a5.zip chromium_src-3c48b53f15d8438e6cac36dc28cd491e488424a5.tar.gz chromium_src-3c48b53f15d8438e6cac36dc28cd491e488424a5.tar.bz2 |
Cleanup: Reorder methods in SandboxMountPointProvider
- To follow coding style to put overriding methods together in .h
- To make the method order match in .cc/.h
BUG=none
TEST=no functional changes
Review URL: http://codereview.chromium.org/8965041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115118 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/fileapi/sandbox_mount_point_provider.cc | 148 | ||||
-rw-r--r-- | webkit/fileapi/sandbox_mount_point_provider.h | 42 |
2 files changed, 90 insertions, 100 deletions
diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc index 661d760..6a0667de 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.cc +++ b/webkit/fileapi/sandbox_mount_point_provider.cc @@ -279,34 +279,6 @@ const FilePath::CharType SandboxMountPointProvider::kRenamedOldFileSystemDirectory[] = FILE_PATH_LITERAL("FS.old"); -SandboxMountPointProvider::SandboxMountPointProvider( - FileSystemPathManager* path_manager, - scoped_refptr<base::MessageLoopProxy> file_message_loop, - const FilePath& profile_path) - : FileSystemQuotaUtil(file_message_loop), - path_manager_(path_manager), - file_message_loop_(file_message_loop), - profile_path_(profile_path), - sandbox_file_util_( - new ObfuscatedFileUtil( - profile_path.Append(kNewFileSystemDirectory), - QuotaFileUtil::CreateDefault())) { -} - -SandboxMountPointProvider::~SandboxMountPointProvider() { - if (!file_message_loop_->BelongsToCurrentThread()) - file_message_loop_->ReleaseSoon(FROM_HERE, sandbox_file_util_.release()); -} - -bool SandboxMountPointProvider::IsAccessAllowed(const GURL& origin_url, - FileSystemType type, - const FilePath& unused) { - if (type != kFileSystemTypeTemporary && type != kFileSystemTypePersistent) - return false; - // We essentially depend on quota to do our access controls. - return path_manager_->IsAllowedScheme(origin_url); -} - class SandboxMountPointProvider::GetFileSystemRootPathTask : public base::RefCountedThreadSafe< SandboxMountPointProvider::GetFileSystemRootPathTask> { @@ -387,53 +359,32 @@ class SandboxMountPointProvider::GetFileSystemRootPathTask FileSystemPathManager::GetRootPathCallback callback_; }; -FilePath SandboxMountPointProvider::old_base_path() const { - return profile_path_.Append(kOldFileSystemDirectory); -} - -FilePath SandboxMountPointProvider::new_base_path() const { - return profile_path_.Append(kNewFileSystemDirectory); +SandboxMountPointProvider::SandboxMountPointProvider( + FileSystemPathManager* path_manager, + scoped_refptr<base::MessageLoopProxy> file_message_loop, + const FilePath& profile_path) + : FileSystemQuotaUtil(file_message_loop), + path_manager_(path_manager), + file_message_loop_(file_message_loop), + profile_path_(profile_path), + sandbox_file_util_( + new ObfuscatedFileUtil( + profile_path.Append(kNewFileSystemDirectory), + QuotaFileUtil::CreateDefault())) { } -FilePath SandboxMountPointProvider::renamed_old_base_path() const { - return profile_path_.Append(kRenamedOldFileSystemDirectory); +SandboxMountPointProvider::~SandboxMountPointProvider() { + if (!file_message_loop_->BelongsToCurrentThread()) + file_message_loop_->ReleaseSoon(FROM_HERE, sandbox_file_util_.release()); } -bool SandboxMountPointProvider::IsRestrictedFileName(const FilePath& filename) - const { - if (filename.value().empty()) +bool SandboxMountPointProvider::IsAccessAllowed(const GURL& origin_url, + FileSystemType type, + const FilePath& unused) { + if (type != kFileSystemTypeTemporary && type != kFileSystemTypePersistent) return false; - - std::string filename_lower = StringToLowerASCII( - FilePathStringToASCII(filename.value())); - - for (size_t i = 0; i < arraysize(kRestrictedNames); ++i) { - // Exact match. - if (filename_lower == kRestrictedNames[i]) - return true; - } - - for (size_t i = 0; i < arraysize(kRestrictedChars); ++i) { - if (filename.value().find(kRestrictedChars[i]) != - FilePath::StringType::npos) - return true; - } - - return false; -} - -std::vector<FilePath> SandboxMountPointProvider::GetRootDirectories() const { - NOTREACHED(); - // TODO(ericu): Implement this method and check for access permissions as - // fileBrowserPrivate extension API does. We currently have another mechanism, - // but we should switch over. This may also need to call MigrateIfNeeded(). - return std::vector<FilePath>(); -} - -SandboxMountPointProvider::OriginEnumerator* -SandboxMountPointProvider::CreateOriginEnumerator() const { - MigrateIfNeeded(sandbox_file_util_, old_base_path()); - return new ObfuscatedOriginEnumerator(sandbox_file_util_.get()); + // We essentially depend on quota to do our access controls. + return path_manager_->IsAllowedScheme(origin_url); } void SandboxMountPointProvider::ValidateFileSystemRootAndGetURL( @@ -482,6 +433,59 @@ SandboxMountPointProvider::ValidateFileSystemRootAndGetPathOnFileThread( origin_url, type, create); } +bool SandboxMountPointProvider::IsRestrictedFileName(const FilePath& filename) + const { + if (filename.value().empty()) + return false; + + std::string filename_lower = StringToLowerASCII( + FilePathStringToASCII(filename.value())); + + for (size_t i = 0; i < arraysize(kRestrictedNames); ++i) { + // Exact match. + if (filename_lower == kRestrictedNames[i]) + return true; + } + + for (size_t i = 0; i < arraysize(kRestrictedChars); ++i) { + if (filename.value().find(kRestrictedChars[i]) != + FilePath::StringType::npos) + return true; + } + + return false; +} + +std::vector<FilePath> SandboxMountPointProvider::GetRootDirectories() const { + NOTREACHED(); + // TODO(ericu): Implement this method and check for access permissions as + // fileBrowserPrivate extension API does. We currently have another mechanism, + // but we should switch over. This may also need to call MigrateIfNeeded(). + return std::vector<FilePath>(); +} + +FileSystemFileUtil* SandboxMountPointProvider::GetFileUtil() { + return sandbox_file_util_.get(); +} + +FilePath SandboxMountPointProvider::old_base_path() const { + return profile_path_.Append(kOldFileSystemDirectory); +} + +FilePath SandboxMountPointProvider::new_base_path() const { + return profile_path_.Append(kNewFileSystemDirectory); +} + +FilePath SandboxMountPointProvider::renamed_old_base_path() const { + return profile_path_.Append(kRenamedOldFileSystemDirectory); +} + +SandboxMountPointProvider::OriginEnumerator* +SandboxMountPointProvider::CreateOriginEnumerator() const { + MigrateIfNeeded(sandbox_file_util_, old_base_path()); + return new ObfuscatedOriginEnumerator(sandbox_file_util_.get()); +} + FilePath SandboxMountPointProvider::GetBaseDirectoryForOriginAndType( const GURL& origin_url, fileapi::FileSystemType type, bool create) const { @@ -640,10 +644,6 @@ void SandboxMountPointProvider::InvalidateUsageCache( FileSystemUsageCache::IncrementDirty(usage_file_path); } -FileSystemFileUtil* SandboxMountPointProvider::GetFileUtil() { - return sandbox_file_util_.get(); -} - FilePath SandboxMountPointProvider::GetUsageCachePathForOriginAndType( const GURL& origin_url, fileapi::FileSystemType type) const { FilePath base_path = diff --git a/webkit/fileapi/sandbox_mount_point_provider.h b/webkit/fileapi/sandbox_mount_point_provider.h index 11a4773..5fa76ab2 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.h +++ b/webkit/fileapi/sandbox_mount_point_provider.h @@ -49,51 +49,43 @@ class SandboxMountPointProvider virtual bool HasFileSystemType(FileSystemType type) const = 0; }; + // The legacy [pre-obfuscation] FileSystem directory name, kept around for + // migration and migration testing. + static const FilePath::CharType kOldFileSystemDirectory[]; + // The FileSystem directory name. + static const FilePath::CharType kNewFileSystemDirectory[]; + // Where we move the old filesystem directory if migration fails. + static const FilePath::CharType kRenamedOldFileSystemDirectory[]; + SandboxMountPointProvider( FileSystemPathManager* path_manager, scoped_refptr<base::MessageLoopProxy> file_message_loop, const FilePath& profile_path); virtual ~SandboxMountPointProvider(); - // Checks if access to |virtual_path| is allowed from |origin_url|. - virtual bool IsAccessAllowed(const GURL& origin_url, - FileSystemType type, - const FilePath& virtual_path) OVERRIDE; - - // Retrieves the root path for the given |origin_url| and |type|, and - // calls the given |callback| with the root path and name. - // If |create| is true this also creates the directory if it doesn't exist. + // FileSystemMountPointProvider overrides. + virtual bool IsAccessAllowed( + const GURL& origin_url, + FileSystemType type, + const FilePath& virtual_path) OVERRIDE; virtual void ValidateFileSystemRootAndGetURL( const GURL& origin_url, FileSystemType type, bool create, const FileSystemPathManager::GetRootPathCallback& callback) OVERRIDE; - - // Like GetFileSystemRootPath, but synchronous, and can be called only while - // running on the file thread. virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread( const GURL& origin_url, FileSystemType type, const FilePath& unused, bool create) OVERRIDE; - - // The legacy [pre-obfuscation] FileSystem directory name, kept around for - // migration and migration testing. - static const FilePath::CharType kOldFileSystemDirectory[]; - // The FileSystem directory name. - static const FilePath::CharType kNewFileSystemDirectory[]; - // Where we move the old filesystem directory if migration fails. - static const FilePath::CharType kRenamedOldFileSystemDirectory[]; + virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; + virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; + virtual FileSystemFileUtil* GetFileUtil() OVERRIDE; FilePath old_base_path() const; FilePath new_base_path() const; FilePath renamed_old_base_path() const; - // Checks if a given |name| contains any restricted names/chars in it. - virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; - - virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; - // Returns an origin enumerator of this provider. // This method can only be called on the file thread. OriginEnumerator* CreateOriginEnumerator() const; @@ -109,8 +101,6 @@ class SandboxMountPointProvider FileSystemType type, bool create) const; - virtual FileSystemFileUtil* GetFileUtil() OVERRIDE; - // Deletes the data on the origin and reports the amount of deleted data // to the quota manager via |proxy|. bool DeleteOriginDataOnFileThread( |