| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_options.h" |
| 17 #include "webkit/fileapi/file_system_quota_util.h" | 17 #include "webkit/fileapi/file_system_quota_util.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class MessageLoopProxy; | 20 class SingleThreadTaskRunner; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace quota { | 23 namespace quota { |
| 24 class QuotaManagerProxy; | 24 class QuotaManagerProxy; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace fileapi { | 27 namespace fileapi { |
| 28 | 28 |
| 29 class ObfuscatedFileUtil; | 29 class ObfuscatedFileUtil; |
| 30 | 30 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // The legacy [pre-obfuscation] FileSystem directory name, kept around for | 56 // The legacy [pre-obfuscation] FileSystem directory name, kept around for |
| 57 // migration and migration testing. | 57 // migration and migration testing. |
| 58 static const FilePath::CharType kOldFileSystemDirectory[]; | 58 static const FilePath::CharType kOldFileSystemDirectory[]; |
| 59 // The FileSystem directory name. | 59 // The FileSystem directory name. |
| 60 static const FilePath::CharType kNewFileSystemDirectory[]; | 60 static const FilePath::CharType kNewFileSystemDirectory[]; |
| 61 // Where we move the old filesystem directory if migration fails. | 61 // Where we move the old filesystem directory if migration fails. |
| 62 static const FilePath::CharType kRenamedOldFileSystemDirectory[]; | 62 static const FilePath::CharType kRenamedOldFileSystemDirectory[]; |
| 63 | 63 |
| 64 // |file_task_runner| is used to validate the root directory and delete the |
| 65 // obfuscated file util. |
| 64 SandboxMountPointProvider( | 66 SandboxMountPointProvider( |
| 65 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 67 base::SingleThreadTaskRunner* file_task_runner, |
| 66 const FilePath& profile_path, | 68 const FilePath& profile_path, |
| 67 const FileSystemOptions& file_system_options); | 69 const FileSystemOptions& file_system_options); |
| 68 virtual ~SandboxMountPointProvider(); | 70 virtual ~SandboxMountPointProvider(); |
| 69 | 71 |
| 70 // FileSystemMountPointProvider overrides. | 72 // FileSystemMountPointProvider overrides. |
| 71 virtual void ValidateFileSystemRoot( | 73 virtual void ValidateFileSystemRoot( |
| 72 const GURL& origin_url, | 74 const GURL& origin_url, |
| 73 FileSystemType type, | 75 FileSystemType type, |
| 74 bool create, | 76 bool create, |
| 75 const ValidateFileSystemCallback& callback) OVERRIDE; | 77 const ValidateFileSystemCallback& callback) OVERRIDE; |
| 76 virtual FilePath GetFileSystemRootPathOnFileThread( | 78 virtual FilePath GetFileSystemRootPathOnFileThread( |
| 77 const GURL& origin_url, | 79 const GURL& origin_url, |
| 78 FileSystemType type, | 80 FileSystemType type, |
| 79 const FilePath& virtual_path, | 81 const FilePath& virtual_path, |
| 80 bool create) OVERRIDE; | 82 bool create) OVERRIDE; |
| 81 virtual bool IsAccessAllowed( | 83 virtual bool IsAccessAllowed( |
| 82 const GURL& origin_url, | 84 const GURL& origin_url, |
| 83 FileSystemType type, | 85 FileSystemType type, |
| 84 const FilePath& virtual_path) OVERRIDE; | 86 const FilePath& virtual_path) OVERRIDE; |
| 85 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; | 87 virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE; |
| 86 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; | 88 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; |
| 87 virtual FileSystemFileUtil* GetFileUtil() OVERRIDE; | 89 virtual FileSystemFileUtil* GetFileUtil() OVERRIDE; |
| 88 virtual FilePath GetPathForPermissionsCheck(const FilePath& virtual_path) | 90 virtual FilePath GetPathForPermissionsCheck(const FilePath& virtual_path) |
| 89 const OVERRIDE; | 91 const OVERRIDE; |
| 90 virtual FileSystemOperationInterface* CreateFileSystemOperation( | 92 virtual FileSystemOperationInterface* CreateFileSystemOperation( |
| 91 const GURL& origin_url, | 93 const GURL& origin_url, |
| 92 FileSystemType file_system_type, | 94 FileSystemType file_system_type, |
| 93 const FilePath& virtual_path, | 95 const FilePath& virtual_path, |
| 94 base::MessageLoopProxy* file_proxy, | 96 base::TaskRunner* task_runner, |
| 95 FileSystemContext* context) const OVERRIDE; | 97 FileSystemContext* context) const OVERRIDE; |
| 96 virtual webkit_blob::FileReader* CreateFileReader( | 98 virtual webkit_blob::FileReader* CreateFileReader( |
| 97 const GURL& url, | 99 const GURL& url, |
| 98 int64 offset, | 100 int64 offset, |
| 99 base::MessageLoopProxy* file_proxy, | 101 base::TaskRunner* task_runner, |
| 100 FileSystemContext* context) const OVERRIDE; | 102 FileSystemContext* context) const OVERRIDE; |
| 101 | 103 |
| 102 FilePath old_base_path() const; | 104 FilePath old_base_path() const; |
| 103 FilePath new_base_path() const; | 105 FilePath new_base_path() const; |
| 104 FilePath renamed_old_base_path() const; | 106 FilePath renamed_old_base_path() const; |
| 105 | 107 |
| 106 // Returns an origin enumerator of this provider. | 108 // Returns an origin enumerator of this provider. |
| 107 // This method can only be called on the file thread. | 109 // This method can only be called on the file thread. |
| 108 OriginEnumerator* CreateOriginEnumerator() const; | 110 OriginEnumerator* CreateOriginEnumerator() const; |
| 109 | 111 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 const GURL& origin_url, FileSystemType type); | 168 const GURL& origin_url, FileSystemType type); |
| 167 | 169 |
| 168 // Returns true if the given |url|'s scheme is allowed to access | 170 // Returns true if the given |url|'s scheme is allowed to access |
| 169 // filesystem. | 171 // filesystem. |
| 170 bool IsAllowedScheme(const GURL& url) const; | 172 bool IsAllowedScheme(const GURL& url) const; |
| 171 | 173 |
| 172 friend class FileSystemTestOriginHelper; | 174 friend class FileSystemTestOriginHelper; |
| 173 friend class SandboxMountPointProviderMigrationTest; | 175 friend class SandboxMountPointProviderMigrationTest; |
| 174 friend class SandboxMountPointProviderOriginEnumeratorTest; | 176 friend class SandboxMountPointProviderOriginEnumeratorTest; |
| 175 | 177 |
| 176 scoped_refptr<base::MessageLoopProxy> file_message_loop_; | 178 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
| 177 | 179 |
| 178 const FilePath profile_path_; | 180 const FilePath profile_path_; |
| 179 | 181 |
| 180 FileSystemOptions file_system_options_; | 182 FileSystemOptions file_system_options_; |
| 181 | 183 |
| 182 scoped_refptr<ObfuscatedFileUtil> sandbox_file_util_; | 184 scoped_refptr<ObfuscatedFileUtil> sandbox_file_util_; |
| 183 | 185 |
| 184 // Acccessed only on the file thread. | 186 // Acccessed only on the file thread. |
| 185 std::set<GURL> visited_origins_; | 187 std::set<GURL> visited_origins_; |
| 186 | 188 |
| 187 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); | 189 DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); |
| 188 }; | 190 }; |
| 189 | 191 |
| 190 } // namespace fileapi | 192 } // namespace fileapi |
| 191 | 193 |
| 192 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ | 194 #endif // WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ |
| OLD | NEW |