| 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> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 public: | 42 public: |
| 43 virtual ~OriginEnumerator() {} | 43 virtual ~OriginEnumerator() {} |
| 44 | 44 |
| 45 // Returns the next origin. Returns empty if there are no more origins. | 45 // Returns the next origin. Returns empty if there are no more origins. |
| 46 virtual GURL Next() = 0; | 46 virtual GURL Next() = 0; |
| 47 | 47 |
| 48 // Returns the current origin's information. | 48 // Returns the current origin's information. |
| 49 virtual bool HasFileSystemType(FileSystemType type) const = 0; | 49 virtual bool HasFileSystemType(FileSystemType type) const = 0; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 SandboxMountPointProvider( | |
| 53 FileSystemPathManager* path_manager, | |
| 54 scoped_refptr<base::MessageLoopProxy> file_message_loop, | |
| 55 const FilePath& profile_path); | |
| 56 virtual ~SandboxMountPointProvider(); | |
| 57 | |
| 58 // Checks if access to |virtual_path| is allowed from |origin_url|. | |
| 59 virtual bool IsAccessAllowed(const GURL& origin_url, | |
| 60 FileSystemType type, | |
| 61 const FilePath& virtual_path) OVERRIDE; | |
| 62 | |
| 63 // Retrieves the root path for the given |origin_url| and |type|, and | |
| 64 // calls the given |callback| with the root path and name. | |
| 65 // If |create| is true this also creates the directory if it doesn't exist. | |
| 66 virtual void ValidateFileSystemRootAndGetURL( | |
| 67 const GURL& origin_url, | |
| 68 FileSystemType type, | |
| 69 bool create, | |
| 70 const FileSystemPathManager::GetRootPathCallback& callback) OVERRIDE; | |
| 71 | |
| 72 // Like GetFileSystemRootPath, but synchronous, and can be called only while | |
| 73 // running on the file thread. | |
| 74 virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread( | |
| 75 const GURL& origin_url, | |
| 76 FileSystemType type, | |
| 77 const FilePath& unused, | |
| 78 bool create) OVERRIDE; | |
| 79 | |
| 80 // The legacy [pre-obfuscation] FileSystem directory name, kept around for | 52 // The legacy [pre-obfuscation] FileSystem directory name, kept around for |
| 81 // migration and migration testing. | 53 // migration and migration testing. |
| 82 static const FilePath::CharType kOldFileSystemDirectory[]; | 54 static const FilePath::CharType kOldFileSystemDirectory[]; |
| 83 // The FileSystem directory name. | 55 // The FileSystem directory name. |
| 84 static const FilePath::CharType kNewFileSystemDirectory[]; | 56 static const FilePath::CharType kNewFileSystemDirectory[]; |
| 85 // Where we move the old filesystem directory if migration fails. | 57 // Where we move the old filesystem directory if migration fails. |
| 86 static const FilePath::CharType kRenamedOldFileSystemDirectory[]; | 58 static const FilePath::CharType kRenamedOldFileSystemDirectory[]; |
| 87 | 59 |
| 60 SandboxMountPointProvider( |
| 61 FileSystemPathManager* path_manager, |
| 62 scoped_refptr<base::MessageLoopProxy> file_message_loop, |
| 63 const FilePath& profile_path); |
| 64 virtual ~SandboxMountPointProvider(); |
| 65 |
| 66 // FileSystemMountPointProvider overrides. |
| 67 virtual bool IsAccessAllowed(const GURL& origin_url, |
| 68 FileSystemType type, |
| 69 const FilePath& virtual_path) OVERRIDE; |
| 70 virtual void ValidateFileSystemRootAndGetURL( |
| 71 const GURL& origin_url, |
| 72 FileSystemType type, |
| 73 bool create, |
| 74 const FileSystemPathManager::GetRootPathCallback& callback) OVERRIDE; |
| 75 virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread( |
| 76 const GURL& origin_url, |
| 77 FileSystemType type, |
| 78 const FilePath& unused, |
| 79 bool create) OVERRIDE; |
| 80 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; |
| 81 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; |
| 82 virtual FileSystemFileUtil* GetFileUtil() OVERRIDE; |
| 83 |
| 88 FilePath old_base_path() const; | 84 FilePath old_base_path() const; |
| 89 FilePath new_base_path() const; | 85 FilePath new_base_path() const; |
| 90 FilePath renamed_old_base_path() const; | 86 FilePath renamed_old_base_path() const; |
| 91 | 87 |
| 92 // Checks if a given |name| contains any restricted names/chars in it. | |
| 93 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; | |
| 94 | |
| 95 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; | |
| 96 | |
| 97 // Returns an origin enumerator of this provider. | 88 // Returns an origin enumerator of this provider. |
| 98 // This method can only be called on the file thread. | 89 // This method can only be called on the file thread. |
| 99 OriginEnumerator* CreateOriginEnumerator() const; | 90 OriginEnumerator* CreateOriginEnumerator() const; |
| 100 | 91 |
| 101 // Gets a base directory path of the sandboxed filesystem that is | 92 // Gets a base directory path of the sandboxed filesystem that is |
| 102 // specified by |origin_url| and |type|. | 93 // specified by |origin_url| and |type|. |
| 103 // (The path is similar to the origin's root path but doesn't contain | 94 // (The path is similar to the origin's root path but doesn't contain |
| 104 // the 'unique' part.) | 95 // the 'unique' part.) |
| 105 // Returns an empty path if the given type is invalid. | 96 // Returns an empty path if the given type is invalid. |
| 106 // This method can only be called on the file thread. | 97 // This method can only be called on the file thread. |
| 107 FilePath GetBaseDirectoryForOriginAndType( | 98 FilePath GetBaseDirectoryForOriginAndType( |
| 108 const GURL& origin_url, | 99 const GURL& origin_url, |
| 109 FileSystemType type, | 100 FileSystemType type, |
| 110 bool create) const; | 101 bool create) const; |
| 111 | 102 |
| 112 virtual FileSystemFileUtil* GetFileUtil() OVERRIDE; | |
| 113 | |
| 114 // Deletes the data on the origin and reports the amount of deleted data | 103 // Deletes the data on the origin and reports the amount of deleted data |
| 115 // to the quota manager via |proxy|. | 104 // to the quota manager via |proxy|. |
| 116 bool DeleteOriginDataOnFileThread( | 105 bool DeleteOriginDataOnFileThread( |
| 117 quota::QuotaManagerProxy* proxy, | 106 quota::QuotaManagerProxy* proxy, |
| 118 const GURL& origin_url, | 107 const GURL& origin_url, |
| 119 FileSystemType type); | 108 FileSystemType type); |
| 120 | 109 |
| 121 // Quota util methods. | 110 // Quota util methods. |
| 122 virtual void GetOriginsForTypeOnFileThread( | 111 virtual void GetOriginsForTypeOnFileThread( |
| 123 FileSystemType type, | 112 FileSystemType type, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 165 |
| 177 // Acccessed only on the file thread. | 166 // Acccessed only on the file thread. |
| 178 std::set<GURL> visited_origins_; | 167 std::set<GURL> visited_origins_; |
| 179 | 168 |
| 180 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); | 169 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); |
| 181 }; | 170 }; |
| 182 | 171 |
| 183 } // namespace fileapi | 172 } // namespace fileapi |
| 184 | 173 |
| 185 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 174 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ |
| OLD | NEW |