Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: webkit/browser/fileapi/file_system_mount_point_provider.h

Issue 18344013: fileapi: Rename FileSystemMountProvider to FileSystemBackend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_MOUNT_POINT_PROVIDER_H_
6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_MOUNT_POINT_PROVIDER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback_forward.h"
12 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/platform_file.h"
15 #include "webkit/browser/fileapi/file_permission_policy.h"
16 #include "webkit/browser/fileapi/open_file_system_mode.h"
17 #include "webkit/browser/webkit_storage_browser_export.h"
18 #include "webkit/common/fileapi/file_system_types.h"
19
20 class GURL;
21
22 namespace webkit_blob {
23 class FileStreamReader;
24 }
25
26 namespace fileapi {
27
28 class AsyncFileUtil;
29 class CopyOrMoveFileValidatorFactory;
30 class FileSystemURL;
31 class FileStreamWriter;
32 class FileSystemContext;
33 class FileSystemFileUtil;
34 class FileSystemOperation;
35 class FileSystemQuotaUtil;
36 class RemoteFileSystemProxyInterface;
37
38 // An interface to provide mount-point-specific path-related utilities
39 // and specialized FileSystemFileUtil instance.
40 //
41 // NOTE: when you implement a new MountPointProvider for your own
42 // FileSystem module, please contact to kinuko@chromium.org.
43 //
44 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemMountPointProvider {
45 public:
46 // Callback for OpenFileSystem.
47 typedef base::Callback<void(base::PlatformFileError error)>
48 OpenFileSystemCallback;
49 typedef base::Callback<void(base::PlatformFileError error)>
50 DeleteFileSystemCallback;
51 virtual ~FileSystemMountPointProvider() {}
52
53 // Returns true if this mount point provider can handle |type|.
54 // One mount point provider may be able to handle multiple filesystem types.
55 virtual bool CanHandleType(FileSystemType type) const = 0;
56
57 // Initializes the filesystem for the given |origin_url| and |type|.
58 // This verifies if it is allowed to request (or create) the filesystem
59 // and if it can access (or create) the root directory of the mount point.
60 // If |mode| is CREATE_IF_NONEXISTENT calling this may also create
61 // the root directory (and/or related database entries etc) for
62 // the filesystem if it doesn't exist.
63 virtual void OpenFileSystem(
64 const GURL& origin_url,
65 FileSystemType type,
66 OpenFileSystemMode mode,
67 const OpenFileSystemCallback& callback) = 0;
68
69 // Returns the specialized FileSystemFileUtil for this mount point.
70 // It is ok to return NULL if the filesystem doesn't support synchronous
71 // version of FileUtil.
72 virtual FileSystemFileUtil* GetFileUtil(FileSystemType type) = 0;
73
74 // Returns the specialized AsyncFileUtil for this mount point.
75 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) = 0;
76
77 // Returns the specialized CopyOrMoveFileValidatorFactory for this mount
78 // point and |type|. If |error_code| is PLATFORM_FILE_OK and the result
79 // is NULL, then no validator is required.
80 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
81 FileSystemType type, base::PlatformFileError* error_code) = 0;
82
83 // Returns a new instance of the specialized FileSystemOperation for this
84 // mount point based on the given triplet of |origin_url|, |file_system_type|
85 // and |virtual_path|. On failure to create a file system operation, set
86 // |error_code| correspondingly.
87 // This method is usually dispatched by
88 // FileSystemContext::CreateFileSystemOperation.
89 virtual FileSystemOperation* CreateFileSystemOperation(
90 const FileSystemURL& url,
91 FileSystemContext* context,
92 base::PlatformFileError* error_code) const = 0;
93
94 // Creates a new file stream reader for a given filesystem URL |url| with an
95 // offset |offset|. |expected_modification_time| specifies the expected last
96 // modification if the value is non-null, the reader will check the underlying
97 // file's actual modification time to see if the file has been modified, and
98 // if it does any succeeding read operations should fail with
99 // ERR_UPLOAD_FILE_CHANGED error.
100 // This method itself does *not* check if the given path exists and is a
101 // regular file.
102 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
103 const FileSystemURL& url,
104 int64 offset,
105 const base::Time& expected_modification_time,
106 FileSystemContext* context) const = 0;
107
108 // Creates a new file stream writer for a given filesystem URL |url| with an
109 // offset |offset|.
110 // This method itself does *not* check if the given path exists and is a
111 // regular file.
112 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter(
113 const FileSystemURL& url,
114 int64 offset,
115 FileSystemContext* context) const = 0;
116
117 // Returns the specialized FileSystemQuotaUtil for this mount point.
118 // This could return NULL if this mount point does not support quota.
119 virtual FileSystemQuotaUtil* GetQuotaUtil() = 0;
120
121 // Deletes the filesystem for the given |origin_url| and |type|.
122 virtual void DeleteFileSystem(
123 const GURL& origin_url,
124 FileSystemType type,
125 FileSystemContext* context,
126 const DeleteFileSystemCallback& callback) = 0;
127 };
128
129 // An interface to control external file system access permissions.
130 class ExternalFileSystemMountPointProvider
131 : public FileSystemMountPointProvider {
132 public:
133 // Returns true if |url| is allowed to be accessed.
134 // This is supposed to perform ExternalFileSystem-specific security
135 // checks.
136 virtual bool IsAccessAllowed(const fileapi::FileSystemURL& url) const = 0;
137 // Returns the list of top level directories that are exposed by this
138 // provider. This list is used to set appropriate child process file access
139 // permissions.
140 virtual std::vector<base::FilePath> GetRootDirectories() const = 0;
141 // Grants access to all external file system from extension identified with
142 // |extension_id|.
143 virtual void GrantFullAccessToExtension(const std::string& extension_id) = 0;
144 // Grants access to |virtual_path| from |origin_url|.
145 virtual void GrantFileAccessToExtension(
146 const std::string& extension_id,
147 const base::FilePath& virtual_path) = 0;
148 // Revokes file access from extension identified with |extension_id|.
149 virtual void RevokeAccessForExtension(
150 const std::string& extension_id) = 0;
151 // Gets virtual path by known filesystem path. Returns false when filesystem
152 // path is not exposed by this provider.
153 virtual bool GetVirtualPath(const base::FilePath& file_system_path,
154 base::FilePath* virtual_path) = 0;
155 };
156
157 } // namespace fileapi
158
159 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_MOUNT_POINT_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698