| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 5 #ifndef WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ |
| 6 #define WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 6 #define WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "webkit/fileapi/file_system_mount_point_provider.h" | 15 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 16 #include "webkit/fileapi/file_system_options.h" |
| 16 #include "webkit/fileapi/file_system_quota_util.h" | 17 #include "webkit/fileapi/file_system_quota_util.h" |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class MessageLoopProxy; | 20 class MessageLoopProxy; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace quota { | 23 namespace quota { |
| 23 class QuotaManagerProxy; | 24 class QuotaManagerProxy; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace fileapi { | 27 namespace fileapi { |
| 27 | 28 |
| 28 class ObfuscatedFileUtil; | 29 class ObfuscatedFileUtil; |
| 29 | 30 |
| 30 // An interface to construct or crack sandboxed filesystem paths for | 31 // An interface to construct or crack sandboxed filesystem paths for |
| 31 // TEMPORARY or PERSISTENT filesystems, which are placed under the user's | 32 // TEMPORARY or PERSISTENT filesystems, which are placed under the user's |
| 32 // profile directory in a sandboxed way. | 33 // profile directory in a sandboxed way. |
| 33 // This interface also lets one enumerate and remove storage for the origins | 34 // This interface also lets one enumerate and remove storage for the origins |
| 34 // that use the filesystem. | 35 // that use the filesystem. |
| 35 class SandboxMountPointProvider | 36 class SandboxMountPointProvider |
| 36 : public FileSystemMountPointProvider, | 37 : public FileSystemMountPointProvider, |
| 37 public FileSystemQuotaUtil { | 38 public FileSystemQuotaUtil { |
| 38 public: | 39 public: |
| 40 typedef FileSystemMountPointProvider::GetRootPathCallback GetRootPathCallback; |
| 41 |
| 39 // Origin enumerator interface. | 42 // Origin enumerator interface. |
| 40 // An instance of this interface is assumed to be called on the file thread. | 43 // An instance of this interface is assumed to be called on the file thread. |
| 41 class OriginEnumerator { | 44 class OriginEnumerator { |
| 42 public: | 45 public: |
| 43 virtual ~OriginEnumerator() {} | 46 virtual ~OriginEnumerator() {} |
| 44 | 47 |
| 45 // Returns the next origin. Returns empty if there are no more origins. | 48 // Returns the next origin. Returns empty if there are no more origins. |
| 46 virtual GURL Next() = 0; | 49 virtual GURL Next() = 0; |
| 47 | 50 |
| 48 // Returns the current origin's information. | 51 // Returns the current origin's information. |
| 49 virtual bool HasFileSystemType(FileSystemType type) const = 0; | 52 virtual bool HasFileSystemType(FileSystemType type) const = 0; |
| 50 }; | 53 }; |
| 51 | 54 |
| 52 // The legacy [pre-obfuscation] FileSystem directory name, kept around for | 55 // The legacy [pre-obfuscation] FileSystem directory name, kept around for |
| 53 // migration and migration testing. | 56 // migration and migration testing. |
| 54 static const FilePath::CharType kOldFileSystemDirectory[]; | 57 static const FilePath::CharType kOldFileSystemDirectory[]; |
| 55 // The FileSystem directory name. | 58 // The FileSystem directory name. |
| 56 static const FilePath::CharType kNewFileSystemDirectory[]; | 59 static const FilePath::CharType kNewFileSystemDirectory[]; |
| 57 // Where we move the old filesystem directory if migration fails. | 60 // Where we move the old filesystem directory if migration fails. |
| 58 static const FilePath::CharType kRenamedOldFileSystemDirectory[]; | 61 static const FilePath::CharType kRenamedOldFileSystemDirectory[]; |
| 59 | 62 |
| 60 SandboxMountPointProvider( | 63 SandboxMountPointProvider( |
| 61 FileSystemPathManager* path_manager, | |
| 62 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 64 scoped_refptr<base::MessageLoopProxy> file_message_loop, |
| 63 const FilePath& profile_path); | 65 const FilePath& profile_path, |
| 66 const FileSystemOptions& file_system_options); |
| 64 virtual ~SandboxMountPointProvider(); | 67 virtual ~SandboxMountPointProvider(); |
| 65 | 68 |
| 66 // FileSystemMountPointProvider overrides. | 69 // FileSystemMountPointProvider overrides. |
| 67 virtual bool IsAccessAllowed( | 70 virtual bool IsAccessAllowed( |
| 68 const GURL& origin_url, | 71 const GURL& origin_url, |
| 69 FileSystemType type, | 72 FileSystemType type, |
| 70 const FilePath& virtual_path) OVERRIDE; | 73 const FilePath& virtual_path) OVERRIDE; |
| 71 virtual void ValidateFileSystemRootAndGetURL( | 74 virtual void ValidateFileSystemRootAndGetURL( |
| 72 const GURL& origin_url, | 75 const GURL& origin_url, |
| 73 FileSystemType type, | 76 FileSystemType type, |
| 74 bool create, | 77 bool create, |
| 75 const FileSystemPathManager::GetRootPathCallback& callback) OVERRIDE; | 78 const GetRootPathCallback& callback) OVERRIDE; |
| 76 virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread( | 79 virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread( |
| 77 const GURL& origin_url, | 80 const GURL& origin_url, |
| 78 FileSystemType type, | 81 FileSystemType type, |
| 79 const FilePath& unused, | 82 const FilePath& unused, |
| 80 bool create) OVERRIDE; | 83 bool create) OVERRIDE; |
| 81 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; | 84 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; |
| 82 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; | 85 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; |
| 83 virtual FileSystemFileUtil* GetFileUtil() OVERRIDE; | 86 virtual FileSystemFileUtil* GetFileUtil() OVERRIDE; |
| 84 | 87 |
| 85 FilePath old_base_path() const; | 88 FilePath old_base_path() const; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 144 |
| 142 private: | 145 private: |
| 143 // Returns a path to the usage cache file. | 146 // Returns a path to the usage cache file. |
| 144 FilePath GetUsageCachePathForOriginAndType( | 147 FilePath GetUsageCachePathForOriginAndType( |
| 145 const GURL& origin_url, | 148 const GURL& origin_url, |
| 146 FileSystemType type) const; | 149 FileSystemType type) const; |
| 147 | 150 |
| 148 FilePath OldCreateFileSystemRootPath( | 151 FilePath OldCreateFileSystemRootPath( |
| 149 const GURL& origin_url, FileSystemType type); | 152 const GURL& origin_url, FileSystemType type); |
| 150 | 153 |
| 154 // Returns true if the given |url|'s scheme is allowed to access |
| 155 // filesystem. |
| 156 bool IsAllowedScheme(const GURL& url) const; |
| 157 |
| 151 class GetFileSystemRootPathTask; | 158 class GetFileSystemRootPathTask; |
| 152 | 159 |
| 153 friend class FileSystemTestOriginHelper; | 160 friend class FileSystemTestOriginHelper; |
| 154 friend class SandboxMountPointProviderMigrationTest; | 161 friend class SandboxMountPointProviderMigrationTest; |
| 155 friend class SandboxMountPointProviderOriginEnumeratorTest; | 162 friend class SandboxMountPointProviderOriginEnumeratorTest; |
| 156 | 163 |
| 157 // The path_manager_ isn't owned by this instance; this instance is owned by | |
| 158 // the path_manager_, and they have the same lifetime. | |
| 159 FileSystemPathManager* path_manager_; | |
| 160 | |
| 161 scoped_refptr<base::MessageLoopProxy> file_message_loop_; | 164 scoped_refptr<base::MessageLoopProxy> file_message_loop_; |
| 162 | 165 |
| 163 const FilePath profile_path_; | 166 const FilePath profile_path_; |
| 164 | 167 |
| 168 FileSystemOptions file_system_options_; |
| 169 |
| 165 scoped_refptr<ObfuscatedFileUtil> sandbox_file_util_; | 170 scoped_refptr<ObfuscatedFileUtil> sandbox_file_util_; |
| 166 | 171 |
| 167 // Acccessed only on the file thread. | 172 // Acccessed only on the file thread. |
| 168 std::set<GURL> visited_origins_; | 173 std::set<GURL> visited_origins_; |
| 169 | 174 |
| 170 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); | 175 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); |
| 171 }; | 176 }; |
| 172 | 177 |
| 173 } // namespace fileapi | 178 } // namespace fileapi |
| 174 | 179 |
| 175 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 180 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ |
| OLD | NEW |