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 "webkit/browser/fileapi/file_system_backend.h" |
15 #include "webkit/browser/quota/special_storage_policy.h" | 15 #include "webkit/browser/quota/special_storage_policy.h" |
16 #include "webkit/common/fileapi/file_system_types.h" | 16 #include "webkit/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<storage::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 bool HasInplaceCopyImplementation( | 105 virtual bool HasInplaceCopyImplementation( |
107 fileapi::FileSystemType type) const OVERRIDE; | 106 storage::FileSystemType type) const OVERRIDE; |
108 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( | 107 virtual scoped_ptr<storage::FileStreamReader> CreateFileStreamReader( |
109 const fileapi::FileSystemURL& path, | 108 const storage::FileSystemURL& path, |
110 int64 offset, | 109 int64 offset, |
111 const base::Time& expected_modification_time, | 110 const base::Time& expected_modification_time, |
112 fileapi::FileSystemContext* context) const OVERRIDE; | 111 storage::FileSystemContext* context) const OVERRIDE; |
113 virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter( | 112 virtual scoped_ptr<storage::FileStreamWriter> CreateFileStreamWriter( |
114 const fileapi::FileSystemURL& url, | 113 const storage::FileSystemURL& url, |
115 int64 offset, | 114 int64 offset, |
116 fileapi::FileSystemContext* context) const OVERRIDE; | 115 storage::FileSystemContext* context) const OVERRIDE; |
117 virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; | 116 virtual storage::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; |
118 | 117 |
119 // fileapi::ExternalFileSystemBackend overrides. | 118 // storage::ExternalFileSystemBackend overrides. |
120 virtual bool IsAccessAllowed(const fileapi::FileSystemURL& url) | 119 virtual bool IsAccessAllowed( |
121 const OVERRIDE; | 120 const storage::FileSystemURL& url) const OVERRIDE; |
122 virtual std::vector<base::FilePath> GetRootDirectories() const OVERRIDE; | 121 virtual std::vector<base::FilePath> GetRootDirectories() const OVERRIDE; |
123 virtual void GrantFullAccessToExtension( | 122 virtual void GrantFullAccessToExtension( |
124 const std::string& extension_id) OVERRIDE; | 123 const std::string& extension_id) OVERRIDE; |
125 virtual void GrantFileAccessToExtension( | 124 virtual void GrantFileAccessToExtension( |
126 const std::string& extension_id, | 125 const std::string& extension_id, |
127 const base::FilePath& virtual_path) OVERRIDE; | 126 const base::FilePath& virtual_path) OVERRIDE; |
128 virtual void RevokeAccessForExtension( | 127 virtual void RevokeAccessForExtension( |
129 const std::string& extension_id) OVERRIDE; | 128 const std::string& extension_id) OVERRIDE; |
130 virtual bool GetVirtualPath(const base::FilePath& filesystem_path, | 129 virtual bool GetVirtualPath(const base::FilePath& filesystem_path, |
131 base::FilePath* virtual_path) OVERRIDE; | 130 base::FilePath* virtual_path) OVERRIDE; |
132 | 131 |
133 private: | 132 private: |
134 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 133 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; |
135 scoped_ptr<FileAccessPermissions> file_access_permissions_; | 134 scoped_ptr<FileAccessPermissions> file_access_permissions_; |
136 scoped_ptr<fileapi::AsyncFileUtil> local_file_util_; | 135 scoped_ptr<storage::AsyncFileUtil> local_file_util_; |
137 | 136 |
138 // The delegate instance for the drive file system related operations. | 137 // The delegate instance for the drive file system related operations. |
139 scoped_ptr<FileSystemBackendDelegate> drive_delegate_; | 138 scoped_ptr<FileSystemBackendDelegate> drive_delegate_; |
140 | 139 |
141 // The delegate instance for the provided file system related operations. | 140 // The delegate instance for the provided file system related operations. |
142 scoped_ptr<FileSystemBackendDelegate> file_system_provider_delegate_; | 141 scoped_ptr<FileSystemBackendDelegate> file_system_provider_delegate_; |
143 | 142 |
144 // The delegate instance for the MTP file system related operations. | 143 // The delegate instance for the MTP file system related operations. |
145 scoped_ptr<FileSystemBackendDelegate> mtp_delegate_; | 144 scoped_ptr<FileSystemBackendDelegate> mtp_delegate_; |
146 | 145 |
147 // Mount points specific to the owning context (i.e. per-profile mount | 146 // Mount points specific to the owning context (i.e. per-profile mount |
148 // points). | 147 // points). |
149 // | 148 // |
150 // It is legal to have mount points with the same name as in | 149 // It is legal to have mount points with the same name as in |
151 // system_mount_points_. Also, mount point paths may overlap with mount point | 150 // system_mount_points_. Also, mount point paths may overlap with mount point |
152 // paths in system_mount_points_. In both cases mount points in | 151 // paths in system_mount_points_. In both cases mount points in |
153 // |mount_points_| will have a priority. | 152 // |mount_points_| will have a priority. |
154 // E.g. if |mount_points_| map 'foo1' to '/foo/foo1' and | 153 // E.g. if |mount_points_| map 'foo1' to '/foo/foo1' and |
155 // |file_system_mount_points_| map 'xxx' to '/foo/foo1/xxx', |GetVirtualPaths| | 154 // |file_system_mount_points_| map 'xxx' to '/foo/foo1/xxx', |GetVirtualPaths| |
156 // will resolve '/foo/foo1/xxx/yyy' as 'foo1/xxx/yyy' (i.e. the mapping from | 155 // will resolve '/foo/foo1/xxx/yyy' as 'foo1/xxx/yyy' (i.e. the mapping from |
157 // |mount_points_| will be used). | 156 // |mount_points_| will be used). |
158 scoped_refptr<fileapi::ExternalMountPoints> mount_points_; | 157 scoped_refptr<storage::ExternalMountPoints> mount_points_; |
159 | 158 |
160 // Globally visible mount points. System MountPonts instance should outlive | 159 // Globally visible mount points. System MountPonts instance should outlive |
161 // all FileSystemBackend instances, so raw pointer is safe. | 160 // all FileSystemBackend instances, so raw pointer is safe. |
162 fileapi::ExternalMountPoints* system_mount_points_; | 161 storage::ExternalMountPoints* system_mount_points_; |
163 | 162 |
164 DISALLOW_COPY_AND_ASSIGN(FileSystemBackend); | 163 DISALLOW_COPY_AND_ASSIGN(FileSystemBackend); |
165 }; | 164 }; |
166 | 165 |
167 } // namespace chromeos | 166 } // namespace chromeos |
168 | 167 |
169 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_SYSTEM_BACKEND_H_ | 168 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_SYSTEM_BACKEND_H_ |
OLD | NEW |