| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_SYSTEM_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_SYSTEM_BACKEND_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_SYSTEM_BACKEND_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_SYSTEM_BACKEND_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "webkit/browser/fileapi/file_system_backend.h" | 14 #include "storage/browser/fileapi/file_system_backend.h" |
| 15 #include "webkit/browser/quota/special_storage_policy.h" | 15 #include "storage/browser/quota/special_storage_policy.h" |
| 16 #include "webkit/common/fileapi/file_system_types.h" | 16 #include "storage/common/fileapi/file_system_types.h" |
| 17 | 17 |
| 18 namespace fileapi { | 18 namespace storage { |
| 19 class CopyOrMoveFileValidatorFactory; | 19 class CopyOrMoveFileValidatorFactory; |
| 20 class ExternalMountPoints; | 20 class ExternalMountPoints; |
| 21 class FileSystemURL; | 21 class FileSystemURL; |
| 22 } // namespace fileapi | 22 } // namespace storage |
| 23 | 23 |
| 24 namespace chromeos { | 24 namespace chromeos { |
| 25 | 25 |
| 26 class FileSystemBackendDelegate; | 26 class FileSystemBackendDelegate; |
| 27 class FileAccessPermissions; | 27 class FileAccessPermissions; |
| 28 | 28 |
| 29 // FileSystemBackend is a Chrome OS specific implementation of | 29 // FileSystemBackend is a Chrome OS specific implementation of |
| 30 // ExternalFileSystemBackend. This class is responsible for a | 30 // ExternalFileSystemBackend. This class is responsible for a |
| 31 // number of things, including: | 31 // number of things, including: |
| 32 // | 32 // |
| (...skipping 18 matching lines...) Expand all Loading... |
| 51 // | 51 // |
| 52 // "drive" is a mount point for Google Drive. Drive is integrated with the | 52 // "drive" is a mount point for Google Drive. Drive is integrated with the |
| 53 // FileSystem API layer via drive::FileSystemProxy. This mount point is added | 53 // FileSystem API layer via drive::FileSystemProxy. This mount point is added |
| 54 // by drive::DriveIntegrationService. | 54 // by drive::DriveIntegrationService. |
| 55 // | 55 // |
| 56 // These mount points are placed under the "external" namespace, and file | 56 // These mount points are placed under the "external" namespace, and file |
| 57 // system URLs for these mount points look like: | 57 // system URLs for these mount points look like: |
| 58 // | 58 // |
| 59 // filesystem:<origin>/external/<mount_name>/... | 59 // filesystem:<origin>/external/<mount_name>/... |
| 60 // | 60 // |
| 61 class FileSystemBackend : public fileapi::ExternalFileSystemBackend { | 61 class FileSystemBackend : public storage::ExternalFileSystemBackend { |
| 62 public: | 62 public: |
| 63 using fileapi::FileSystemBackend::OpenFileSystemCallback; | 63 using storage::FileSystemBackend::OpenFileSystemCallback; |
| 64 | 64 |
| 65 // FileSystemBackend will take an ownership of a |mount_points| | 65 // FileSystemBackend will take an ownership of a |mount_points| |
| 66 // reference. On the other hand, |system_mount_points| will be kept as a raw | 66 // reference. On the other hand, |system_mount_points| will be kept as a raw |
| 67 // pointer and it should outlive FileSystemBackend instance. | 67 // pointer and it should outlive FileSystemBackend instance. |
| 68 // The ownerships of |drive_delegate| and |file_system_provider_delegate| are | 68 // The ownerships of |drive_delegate| and |file_system_provider_delegate| are |
| 69 // also taken. | 69 // also taken. |
| 70 FileSystemBackend( | 70 FileSystemBackend( |
| 71 FileSystemBackendDelegate* drive_delegate, | 71 FileSystemBackendDelegate* drive_delegate, |
| 72 FileSystemBackendDelegate* file_system_provider_delegate, | 72 FileSystemBackendDelegate* file_system_provider_delegate, |
| 73 FileSystemBackendDelegate* mtp_delegate, | 73 FileSystemBackendDelegate* mtp_delegate, |
| 74 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, | 74 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, |
| 75 scoped_refptr<fileapi::ExternalMountPoints> mount_points, | 75 scoped_refptr<storage::ExternalMountPoints> mount_points, |
| 76 fileapi::ExternalMountPoints* system_mount_points); | 76 storage::ExternalMountPoints* system_mount_points); |
| 77 virtual ~FileSystemBackend(); | 77 virtual ~FileSystemBackend(); |
| 78 | 78 |
| 79 // Adds system mount points, such as "archive", and "removable". This | 79 // Adds system mount points, such as "archive", and "removable". This |
| 80 // function is no-op if these mount points are already present. | 80 // function is no-op if these mount points are already present. |
| 81 void AddSystemMountPoints(); | 81 void AddSystemMountPoints(); |
| 82 | 82 |
| 83 // Returns true if CrosMountpointProvider can handle |url|, i.e. its | 83 // Returns true if CrosMountpointProvider can handle |url|, i.e. its |
| 84 // file system type matches with what this provider supports. | 84 // file system type matches with what this provider supports. |
| 85 // This could be called on any threads. | 85 // This could be called on any threads. |
| 86 static bool CanHandleURL(const fileapi::FileSystemURL& url); | 86 static bool CanHandleURL(const storage::FileSystemURL& url); |
| 87 | 87 |
| 88 // fileapi::FileSystemBackend overrides. | 88 // storage::FileSystemBackend overrides. |
| 89 virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE; | 89 virtual bool CanHandleType(storage::FileSystemType type) const OVERRIDE; |
| 90 virtual void Initialize(fileapi::FileSystemContext* context) OVERRIDE; | 90 virtual void Initialize(storage::FileSystemContext* context) OVERRIDE; |
| 91 virtual void ResolveURL(const fileapi::FileSystemURL& url, | 91 virtual void ResolveURL(const storage::FileSystemURL& url, |
| 92 fileapi::OpenFileSystemMode mode, | 92 storage::OpenFileSystemMode mode, |
| 93 const OpenFileSystemCallback& callback) OVERRIDE; | 93 const OpenFileSystemCallback& callback) OVERRIDE; |
| 94 virtual fileapi::AsyncFileUtil* GetAsyncFileUtil( | 94 virtual storage::AsyncFileUtil* GetAsyncFileUtil( |
| 95 fileapi::FileSystemType type) OVERRIDE; | 95 storage::FileSystemType type) OVERRIDE; |
| 96 virtual fileapi::CopyOrMoveFileValidatorFactory* | 96 virtual storage::CopyOrMoveFileValidatorFactory* |
| 97 GetCopyOrMoveFileValidatorFactory( | 97 GetCopyOrMoveFileValidatorFactory(storage::FileSystemType type, |
| 98 fileapi::FileSystemType type, | 98 base::File::Error* error_code) OVERRIDE; |
| 99 base::File::Error* error_code) OVERRIDE; | 99 virtual storage::FileSystemOperation* CreateFileSystemOperation( |
| 100 virtual fileapi::FileSystemOperation* CreateFileSystemOperation( | 100 const storage::FileSystemURL& url, |
| 101 const fileapi::FileSystemURL& url, | 101 storage::FileSystemContext* context, |
| 102 fileapi::FileSystemContext* context, | |
| 103 base::File::Error* error_code) const OVERRIDE; | 102 base::File::Error* error_code) const OVERRIDE; |
| 104 virtual bool SupportsStreaming( | 103 virtual bool SupportsStreaming( |
| 105 const fileapi::FileSystemURL& url) const OVERRIDE; | 104 const storage::FileSystemURL& url) const OVERRIDE; |
| 106 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( | 105 virtual scoped_ptr<storage::FileStreamReader> CreateFileStreamReader( |
| 107 const fileapi::FileSystemURL& path, | 106 const storage::FileSystemURL& path, |
| 108 int64 offset, | 107 int64 offset, |
| 109 const base::Time& expected_modification_time, | 108 const base::Time& expected_modification_time, |
| 110 fileapi::FileSystemContext* context) const OVERRIDE; | 109 storage::FileSystemContext* context) const OVERRIDE; |
| 111 virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter( | 110 virtual scoped_ptr<storage::FileStreamWriter> CreateFileStreamWriter( |
| 112 const fileapi::FileSystemURL& url, | 111 const storage::FileSystemURL& url, |
| 113 int64 offset, | 112 int64 offset, |
| 114 fileapi::FileSystemContext* context) const OVERRIDE; | 113 storage::FileSystemContext* context) const OVERRIDE; |
| 115 virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; | 114 virtual storage::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; |
| 116 | 115 |
| 117 // fileapi::ExternalFileSystemBackend overrides. | 116 // storage::ExternalFileSystemBackend overrides. |
| 118 virtual bool IsAccessAllowed(const fileapi::FileSystemURL& url) | 117 virtual bool IsAccessAllowed( |
| 119 const OVERRIDE; | 118 const storage::FileSystemURL& url) const OVERRIDE; |
| 120 virtual std::vector<base::FilePath> GetRootDirectories() const OVERRIDE; | 119 virtual std::vector<base::FilePath> GetRootDirectories() const OVERRIDE; |
| 121 virtual void GrantFullAccessToExtension( | 120 virtual void GrantFullAccessToExtension( |
| 122 const std::string& extension_id) OVERRIDE; | 121 const std::string& extension_id) OVERRIDE; |
| 123 virtual void GrantFileAccessToExtension( | 122 virtual void GrantFileAccessToExtension( |
| 124 const std::string& extension_id, | 123 const std::string& extension_id, |
| 125 const base::FilePath& virtual_path) OVERRIDE; | 124 const base::FilePath& virtual_path) OVERRIDE; |
| 126 virtual void RevokeAccessForExtension( | 125 virtual void RevokeAccessForExtension( |
| 127 const std::string& extension_id) OVERRIDE; | 126 const std::string& extension_id) OVERRIDE; |
| 128 virtual bool GetVirtualPath(const base::FilePath& filesystem_path, | 127 virtual bool GetVirtualPath(const base::FilePath& filesystem_path, |
| 129 base::FilePath* virtual_path) OVERRIDE; | 128 base::FilePath* virtual_path) OVERRIDE; |
| 130 | 129 |
| 131 private: | 130 private: |
| 132 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 131 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
| 133 scoped_ptr<FileAccessPermissions> file_access_permissions_; | 132 scoped_ptr<FileAccessPermissions> file_access_permissions_; |
| 134 scoped_ptr<fileapi::AsyncFileUtil> local_file_util_; | 133 scoped_ptr<storage::AsyncFileUtil> local_file_util_; |
| 135 | 134 |
| 136 // The delegate instance for the drive file system related operations. | 135 // The delegate instance for the drive file system related operations. |
| 137 scoped_ptr<FileSystemBackendDelegate> drive_delegate_; | 136 scoped_ptr<FileSystemBackendDelegate> drive_delegate_; |
| 138 | 137 |
| 139 // The delegate instance for the provided file system related operations. | 138 // The delegate instance for the provided file system related operations. |
| 140 scoped_ptr<FileSystemBackendDelegate> file_system_provider_delegate_; | 139 scoped_ptr<FileSystemBackendDelegate> file_system_provider_delegate_; |
| 141 | 140 |
| 142 // The delegate instance for the MTP file system related operations. | 141 // The delegate instance for the MTP file system related operations. |
| 143 scoped_ptr<FileSystemBackendDelegate> mtp_delegate_; | 142 scoped_ptr<FileSystemBackendDelegate> mtp_delegate_; |
| 144 | 143 |
| 145 // Mount points specific to the owning context (i.e. per-profile mount | 144 // Mount points specific to the owning context (i.e. per-profile mount |
| 146 // points). | 145 // points). |
| 147 // | 146 // |
| 148 // It is legal to have mount points with the same name as in | 147 // It is legal to have mount points with the same name as in |
| 149 // system_mount_points_. Also, mount point paths may overlap with mount point | 148 // system_mount_points_. Also, mount point paths may overlap with mount point |
| 150 // paths in system_mount_points_. In both cases mount points in | 149 // paths in system_mount_points_. In both cases mount points in |
| 151 // |mount_points_| will have a priority. | 150 // |mount_points_| will have a priority. |
| 152 // E.g. if |mount_points_| map 'foo1' to '/foo/foo1' and | 151 // E.g. if |mount_points_| map 'foo1' to '/foo/foo1' and |
| 153 // |file_system_mount_points_| map 'xxx' to '/foo/foo1/xxx', |GetVirtualPaths| | 152 // |file_system_mount_points_| map 'xxx' to '/foo/foo1/xxx', |GetVirtualPaths| |
| 154 // will resolve '/foo/foo1/xxx/yyy' as 'foo1/xxx/yyy' (i.e. the mapping from | 153 // will resolve '/foo/foo1/xxx/yyy' as 'foo1/xxx/yyy' (i.e. the mapping from |
| 155 // |mount_points_| will be used). | 154 // |mount_points_| will be used). |
| 156 scoped_refptr<fileapi::ExternalMountPoints> mount_points_; | 155 scoped_refptr<storage::ExternalMountPoints> mount_points_; |
| 157 | 156 |
| 158 // Globally visible mount points. System MountPonts instance should outlive | 157 // Globally visible mount points. System MountPonts instance should outlive |
| 159 // all FileSystemBackend instances, so raw pointer is safe. | 158 // all FileSystemBackend instances, so raw pointer is safe. |
| 160 fileapi::ExternalMountPoints* system_mount_points_; | 159 storage::ExternalMountPoints* system_mount_points_; |
| 161 | 160 |
| 162 DISALLOW_COPY_AND_ASSIGN(FileSystemBackend); | 161 DISALLOW_COPY_AND_ASSIGN(FileSystemBackend); |
| 163 }; | 162 }; |
| 164 | 163 |
| 165 } // namespace chromeos | 164 } // namespace chromeos |
| 166 | 165 |
| 167 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_SYSTEM_BACKEND_H_ | 166 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_SYSTEM_BACKEND_H_ |
| OLD | NEW |