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

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

Issue 539143002: Migrate webkit/browser/ to storage/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android build Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_BROWSER_FILEAPI_FILE_SYSTEM_BACKEND_H_ 5 #include "storage/browser/fileapi/file_system_backend.h"
6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_BACKEND_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback_forward.h"
12 #include "base/files/file.h"
13 #include "base/files/file_path.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "webkit/browser/fileapi/file_permission_policy.h"
16 #include "webkit/browser/fileapi/open_file_system_mode.h"
17 #include "webkit/browser/storage_browser_export.h"
18 #include "webkit/common/fileapi/file_system_types.h"
19
20 class GURL;
21
22 namespace storage {
23
24 class AsyncFileUtil;
25 class CopyOrMoveFileValidatorFactory;
26 class FileSystemURL;
27 class FileStreamReader;
28 class FileStreamWriter;
29 class FileSystemContext;
30 class FileSystemFileUtil;
31 class FileSystemOperation;
32 class FileSystemQuotaUtil;
33 class WatcherManager;
34
35 // Callback to take GURL.
36 typedef base::Callback<void(const GURL& url)> URLCallback;
37
38 // An interface for defining a file system backend.
39 //
40 // NOTE: when you implement a new FileSystemBackend for your own
41 // FileSystem module, please contact to kinuko@chromium.org.
42 //
43 class STORAGE_EXPORT FileSystemBackend {
44 public:
45 // Callback for InitializeFileSystem.
46 typedef base::Callback<void(const GURL& root_url,
47 const std::string& name,
48 base::File::Error error)>
49 OpenFileSystemCallback;
50 virtual ~FileSystemBackend() {}
51
52 // Returns true if this filesystem backend can handle |type|.
53 // One filesystem backend may be able to handle multiple filesystem types.
54 virtual bool CanHandleType(FileSystemType type) const = 0;
55
56 // This method is called right after the backend is registered in the
57 // FileSystemContext and before any other methods are called. Each backend can
58 // do additional initialization which depends on FileSystemContext here.
59 virtual void Initialize(FileSystemContext* context) = 0;
60
61 // Resolves the filesystem root URL and the name for the given |url|.
62 // This verifies if it is allowed to request (or create) the filesystem and if
63 // it can access (or create) the root directory.
64 // If |mode| is CREATE_IF_NONEXISTENT calling this may also create the root
65 // directory (and/or related database entries etc) for the filesystem if it
66 // doesn't exist.
67 virtual void ResolveURL(const FileSystemURL& url,
68 OpenFileSystemMode mode,
69 const OpenFileSystemCallback& callback) = 0;
70
71 // Returns the specialized AsyncFileUtil for this backend.
72 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) = 0;
73
74 // Returns the specialized WatcherManager for this backend.
75 virtual WatcherManager* GetWatcherManager(FileSystemType type) = 0;
76
77 // Returns the specialized CopyOrMoveFileValidatorFactory for this backend
78 // and |type|. If |error_code| is File::FILE_OK and the result is NULL,
79 // then no validator is required.
80 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
81 FileSystemType type, base::File::Error* error_code) = 0;
82
83 // Returns a new instance of the specialized FileSystemOperation for this
84 // backend 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::File::Error* error_code) const = 0;
93
94 // Returns true if Blobs accessing |url| should use FileStreamReader.
95 // If false, Blobs are accessed using a snapshot file by calling
96 // AsyncFileUtil::CreateSnapshotFile.
97 virtual bool SupportsStreaming(const FileSystemURL& url) const = 0;
98
99 // Returns true if specified |type| of filesystem can handle Copy()
100 // of the files in the same file system instead of streaming
101 // read/write implementation.
102 virtual bool HasInplaceCopyImplementation(FileSystemType type) const = 0;
103
104 // Creates a new file stream reader for a given filesystem URL |url| with an
105 // offset |offset|. |expected_modification_time| specifies the expected last
106 // modification if the value is non-null, the reader will check the underlying
107 // file's actual modification time to see if the file has been modified, and
108 // if it does any succeeding read operations should fail with
109 // ERR_UPLOAD_FILE_CHANGED error.
110 // This method itself does *not* check if the given path exists and is a
111 // regular file.
112 // The |length| argument says how many bytes are going to be read using the
113 // instance of the file stream reader. If unknown, then equal to -1.
114 virtual scoped_ptr<storage::FileStreamReader> CreateFileStreamReader(
115 const FileSystemURL& url,
116 int64 offset,
117 const base::Time& expected_modification_time,
118 FileSystemContext* context) const = 0;
119
120 // Creates a new file stream writer for a given filesystem URL |url| with an
121 // offset |offset|.
122 // This method itself does *not* check if the given path exists and is a
123 // regular file.
124 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter(
125 const FileSystemURL& url,
126 int64 offset,
127 FileSystemContext* context) const = 0;
128
129 // Returns the specialized FileSystemQuotaUtil for this backend.
130 // This could return NULL if this backend does not support quota.
131 virtual FileSystemQuotaUtil* GetQuotaUtil() = 0;
132 };
133
134 // An interface to control external file system access permissions.
135 // TODO(satorux): Move this out of 'webkit/browser/fileapi'. crbug.com/257279
136 class ExternalFileSystemBackend : public FileSystemBackend {
137 public:
138 // Returns true if |url| is allowed to be accessed.
139 // This is supposed to perform ExternalFileSystem-specific security
140 // checks.
141 virtual bool IsAccessAllowed(const storage::FileSystemURL& url) const = 0;
142 // Returns the list of top level directories that are exposed by this
143 // provider. This list is used to set appropriate child process file access
144 // permissions.
145 virtual std::vector<base::FilePath> GetRootDirectories() const = 0;
146 // Grants access to all external file system from extension identified with
147 // |extension_id|.
148 virtual void GrantFullAccessToExtension(const std::string& extension_id) = 0;
149 // Grants access to |virtual_path| from |origin_url|.
150 virtual void GrantFileAccessToExtension(
151 const std::string& extension_id,
152 const base::FilePath& virtual_path) = 0;
153 // Revokes file access from extension identified with |extension_id|.
154 virtual void RevokeAccessForExtension(
155 const std::string& extension_id) = 0;
156 // Gets virtual path by known filesystem path. Returns false when filesystem
157 // path is not exposed by this provider.
158 virtual bool GetVirtualPath(const base::FilePath& file_system_path,
159 base::FilePath* virtual_path) = 0;
160 // Gets a redirect URL for contents. e.g. Google Drive URL for hosted
161 // documents. Returns empty URL if the entry does not have the redirect URL.
162 virtual void GetRedirectURLForContents(
163 const storage::FileSystemURL& url,
164 const storage::URLCallback& callback) = 0;
165 };
166
167 } // namespace storage
168
169 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_BACKEND_H_
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/file_stream_writer.h ('k') | webkit/browser/fileapi/file_system_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698