| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebFileSystem_h | 31 #ifndef WebFileSystem_h |
| 32 #define WebFileSystem_h | 32 #define WebFileSystem_h |
| 33 | 33 |
| 34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
| 35 #include "WebFileSystemCallbacks.h" |
| 35 #include "WebFileSystemType.h" | 36 #include "WebFileSystemType.h" |
| 36 #include "WebURL.h" | 37 #include "WebURL.h" |
| 37 | 38 |
| 38 namespace WebKit { | 39 namespace WebKit { |
| 39 | 40 |
| 40 // FIXME: Delete this flag after we complete switching to the new code. | 41 // FIXME: Remove this after the switch is over. |
| 41 #define USE_THREADLOCAL_WEBFILESYSTEM | 42 #define NON_SELFDESTRUCT_WEBFILESYSTEMCALLBACKS |
| 42 | 43 |
| 43 // FIXME: Move these classes into platform. | |
| 44 class WebFileSystemCallbacks; | |
| 45 class WebFileWriter; | 44 class WebFileWriter; |
| 46 class WebFileWriterClient; | 45 class WebFileWriterClient; |
| 47 | 46 |
| 48 class WebFileSystem { | 47 class WebFileSystem { |
| 49 public: | 48 public: |
| 50 enum Type { | 49 enum Type { |
| 51 TypeTemporary, | 50 TypeTemporary, |
| 52 TypePersistent, | 51 TypePersistent, |
| 53 | 52 |
| 54 // Indicates an isolated filesystem which only exposes a set of files. | 53 // Indicates an isolated filesystem which only exposes a set of files. |
| 55 TypeIsolated, | 54 TypeIsolated, |
| 56 | 55 |
| 57 // Indicates a non-sandboxed filesystem. | 56 // Indicates a non-sandboxed filesystem. |
| 58 TypeExternal, | 57 TypeExternal, |
| 59 }; | 58 }; |
| 60 | 59 |
| 61 // Opens a FileSystem. | 60 // Opens a FileSystem. |
| 62 // WebFileSystemCallbacks::didOpenFileSystem() must be called with | 61 // WebFileSystemCallbacks::didOpenFileSystem() must be called with |
| 63 // a name and root path for the requested FileSystem when the operation | 62 // a name and root path for the requested FileSystem when the operation |
| 64 // is completed successfully. WebFileSystemCallbacks::didFail() must be | 63 // is completed successfully. WebFileSystemCallbacks::didFail() must be |
| 65 // called otherwise. The create bool is for indicating whether or not to | 64 // called otherwise. The create bool is for indicating whether or not to |
| 66 // create root path for file systems if it do not exist. | 65 // create root path for file systems if it do not exist. |
| 67 virtual void openFileSystem(const WebURL& storagePartition, const WebFileSys
temType, bool create, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } | 66 virtual void openFileSystem(const WebURL& storagePartition, const WebFileSys
temType, bool create, WebFileSystemCallbacks) { WEBKIT_ASSERT_NOT_REACHED(); } |
| 68 | 67 |
| 69 // Deletes FileSystem. | 68 // Deletes FileSystem. |
| 70 // WebFileSystemCallbacks::didSucceed() must be called when the operation | 69 // WebFileSystemCallbacks::didSucceed() must be called when the operation |
| 71 // is completed successfully. WebFileSystemCallbacks::didFail() must be | 70 // is completed successfully. WebFileSystemCallbacks::didFail() must be |
| 72 // called otherwise. | 71 // called otherwise. |
| 73 // All in-flight operations and following operations may fail after the | 72 // All in-flight operations and following operations may fail after the |
| 74 // FileSystem is deleted. | 73 // FileSystem is deleted. |
| 75 virtual void deleteFileSystem(const WebURL& storagePartition, const WebFileS
ystemType, WebFileSystemCallbacks*) { } | 74 virtual void deleteFileSystem(const WebURL& storagePartition, const WebFileS
ystemType, WebFileSystemCallbacks) { } |
| 76 | 75 |
| 77 // Moves a file or directory at |srcPath| to |destPath|. | 76 // Moves a file or directory at |srcPath| to |destPath|. |
| 78 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. | 77 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. |
| 79 // WebFileSystemCallbacks::didFail() must be called otherwise. | 78 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 80 virtual void move(const WebURL& srcPath, const WebURL& destPath, WebFileSyst
emCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } | 79 virtual void move(const WebURL& srcPath, const WebURL& destPath, WebFileSyst
emCallbacks) { WEBKIT_ASSERT_NOT_REACHED(); } |
| 81 | 80 |
| 82 // Copies a file or directory at |srcPath| to |destPath|. | 81 // Copies a file or directory at |srcPath| to |destPath|. |
| 83 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. | 82 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. |
| 84 // WebFileSystemCallbacks::didFail() must be called otherwise. | 83 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 85 virtual void copy(const WebURL& srcPath, const WebURL& destPath, WebFileSyst
emCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } | 84 virtual void copy(const WebURL& srcPath, const WebURL& destPath, WebFileSyst
emCallbacks) { WEBKIT_ASSERT_NOT_REACHED(); } |
| 86 | 85 |
| 87 // Deletes a file or directory at a given |path|. | 86 // Deletes a file or directory at a given |path|. |
| 88 // It is an error to try to remove a directory that is not empty. | 87 // It is an error to try to remove a directory that is not empty. |
| 89 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. | 88 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. |
| 90 // WebFileSystemCallbacks::didFail() must be called otherwise. | 89 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 91 virtual void remove(const WebURL& path, WebFileSystemCallbacks*) { WEBKIT_AS
SERT_NOT_REACHED(); } | 90 virtual void remove(const WebURL& path, WebFileSystemCallbacks) { WEBKIT_ASS
ERT_NOT_REACHED(); } |
| 92 | 91 |
| 93 // Deletes a file or directory recursively at a given |path|. | 92 // Deletes a file or directory recursively at a given |path|. |
| 94 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. | 93 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. |
| 95 // WebFileSystemCallbacks::didFail() must be called otherwise. | 94 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 96 virtual void removeRecursively(const WebURL& path, WebFileSystemCallbacks*)
{ WEBKIT_ASSERT_NOT_REACHED(); } | 95 virtual void removeRecursively(const WebURL& path, WebFileSystemCallbacks) {
WEBKIT_ASSERT_NOT_REACHED(); } |
| 97 | 96 |
| 98 // Retrieves the metadata information of the file or directory at the given
|path|. | 97 // Retrieves the metadata information of the file or directory at the given
|path|. |
| 99 // This may not always return the local platform path in remote filesystem c
ases. | 98 // This may not always return the local platform path in remote filesystem c
ases. |
| 100 // WebFileSystemCallbacks::didReadMetadata() must be called with a valid met
adata when the retrieval is completed successfully. | 99 // WebFileSystemCallbacks::didReadMetadata() must be called with a valid met
adata when the retrieval is completed successfully. |
| 101 // WebFileSystemCallbacks::didFail() must be called otherwise. | 100 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 102 virtual void readMetadata(const WebURL& path, WebFileSystemCallbacks*) { WEB
KIT_ASSERT_NOT_REACHED(); } | 101 virtual void readMetadata(const WebURL& path, WebFileSystemCallbacks) { WEBK
IT_ASSERT_NOT_REACHED(); } |
| 103 | 102 |
| 104 // Creates a file at given |path|. | 103 // Creates a file at given |path|. |
| 105 // If the |path| doesn't exist, it creates a new file at |path|. | 104 // If the |path| doesn't exist, it creates a new file at |path|. |
| 106 // If |exclusive| is true, it fails if the |path| already exists. | 105 // If |exclusive| is true, it fails if the |path| already exists. |
| 107 // If |exclusive| is false, it succeeds if the |path| already exists or | 106 // If |exclusive| is false, it succeeds if the |path| already exists or |
| 108 // it has successfully created a new file at |path|. | 107 // it has successfully created a new file at |path|. |
| 109 // | 108 // |
| 110 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. | 109 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. |
| 111 // WebFileSystemCallbacks::didFail() must be called otherwise. | 110 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 112 virtual void createFile(const WebURL& path, bool exclusive, WebFileSystemCal
lbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } | 111 virtual void createFile(const WebURL& path, bool exclusive, WebFileSystemCal
lbacks) { WEBKIT_ASSERT_NOT_REACHED(); } |
| 113 | 112 |
| 114 // Creates a directory at a given |path|. | 113 // Creates a directory at a given |path|. |
| 115 // If the |path| doesn't exist, it creates a new directory at |path|. | 114 // If the |path| doesn't exist, it creates a new directory at |path|. |
| 116 // If |exclusive| is true, it fails if the |path| already exists. | 115 // If |exclusive| is true, it fails if the |path| already exists. |
| 117 // If |exclusive| is false, it succeeds if the |path| already exists or it h
as successfully created a new directory at |path|. | 116 // If |exclusive| is false, it succeeds if the |path| already exists or it h
as successfully created a new directory at |path|. |
| 118 // | 117 // |
| 119 // WebFileSystemCallbacks::didSucceed() must be called when | 118 // WebFileSystemCallbacks::didSucceed() must be called when |
| 120 // the operation is completed successfully. | 119 // the operation is completed successfully. |
| 121 // WebFileSystemCallbacks::didFail() must be called otherwise. | 120 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 122 virtual void createDirectory(const WebURL& path, bool exclusive, WebFileSyst
emCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } | 121 virtual void createDirectory(const WebURL& path, bool exclusive, WebFileSyst
emCallbacks) { WEBKIT_ASSERT_NOT_REACHED(); } |
| 123 | 122 |
| 124 // Checks if a file exists at a given |path|. | 123 // Checks if a file exists at a given |path|. |
| 125 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. | 124 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. |
| 126 // WebFileSystemCallbacks::didFail() must be called otherwise. | 125 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 127 virtual void fileExists(const WebURL& path, WebFileSystemCallbacks*) { WEBKI
T_ASSERT_NOT_REACHED(); } | 126 virtual void fileExists(const WebURL& path, WebFileSystemCallbacks) { WEBKIT
_ASSERT_NOT_REACHED(); } |
| 128 | 127 |
| 129 // Checks if a directory exists at a given |path|. | 128 // Checks if a directory exists at a given |path|. |
| 130 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. | 129 // WebFileSystemCallbacks::didSucceed() must be called when the operation is
completed successfully. |
| 131 // WebFileSystemCallbacks::didFail() must be called otherwise. | 130 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 132 virtual void directoryExists(const WebURL& path, WebFileSystemCallbacks*) {
WEBKIT_ASSERT_NOT_REACHED(); } | 131 virtual void directoryExists(const WebURL& path, WebFileSystemCallbacks) { W
EBKIT_ASSERT_NOT_REACHED(); } |
| 133 | 132 |
| 134 // Reads directory entries of a given directory at |path|. | 133 // Reads directory entries of a given directory at |path|. |
| 135 // WebFileSystemCallbacks::didReadDirectory() must be called when the operat
ion is completed successfully. | 134 // WebFileSystemCallbacks::didReadDirectory() must be called when the operat
ion is completed successfully. |
| 136 // WebFileSystemCallbacks::didFail() must be called otherwise. | 135 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 137 virtual void readDirectory(const WebURL& path, WebFileSystemCallbacks*) { WE
BKIT_ASSERT_NOT_REACHED(); } | 136 virtual void readDirectory(const WebURL& path, WebFileSystemCallbacks) { WEB
KIT_ASSERT_NOT_REACHED(); } |
| 138 | 137 |
| 139 // Creates a WebFileWriter that can be used to write to the given file. | 138 // Creates a WebFileWriter that can be used to write to the given file. |
| 140 // This is a fast, synchronous call, and should not stat the filesystem. | 139 // This is a fast, synchronous call, and should not stat the filesystem. |
| 141 // FIXME: deprecate this after async version of createFileWriter is | 140 // FIXME: deprecate this after async version of createFileWriter is |
| 142 // implemented. | 141 // implemented. |
| 143 virtual WebFileWriter* createFileWriter(const WebURL& path, WebFileWriterCli
ent*) { WEBKIT_ASSERT_NOT_REACHED(); return 0; } | 142 virtual WebFileWriter* createFileWriter(const WebURL& path, WebFileWriterCli
ent*) { WEBKIT_ASSERT_NOT_REACHED(); return 0; } |
| 144 | 143 |
| 145 // Creates a WebFileWriter that can be used to write to the given file. | 144 // Creates a WebFileWriter that can be used to write to the given file. |
| 146 // WebFileSystemCallbacks::didCreateFileWriter() must be called with the cre
ated WebFileWriter when the operation is completed successfully. | 145 // WebFileSystemCallbacks::didCreateFileWriter() must be called with the cre
ated WebFileWriter when the operation is completed successfully. |
| 147 // WebFileSystemCallbacks::didFail() must be called otherwise. | 146 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 148 virtual void createFileWriter(const WebURL& path, WebFileWriterClient*, WebF
ileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } | 147 virtual void createFileWriter(const WebURL& path, WebFileWriterClient*, WebF
ileSystemCallbacks) { WEBKIT_ASSERT_NOT_REACHED(); } |
| 149 | 148 |
| 150 // Creates a snapshot file for a given file specified by |path|. It returns
the metadata of the created snapshot file. | 149 // Creates a snapshot file for a given file specified by |path|. It returns
the metadata of the created snapshot file. |
| 151 // The returned metadata should include a local platform path to the snapsho
t image. | 150 // The returned metadata should include a local platform path to the snapsho
t image. |
| 152 // In local filesystem cases the backend may simply return the metadata of t
he file itself (as well as readMetadata does), while in | 151 // In local filesystem cases the backend may simply return the metadata of t
he file itself (as well as readMetadata does), while in |
| 153 // remote filesystem case the backend may download the file into a temporary
snapshot file and return the metadata of the temporary file. | 152 // remote filesystem case the backend may download the file into a temporary
snapshot file and return the metadata of the temporary file. |
| 154 // The returned metadata is used to create a File object for the |path|. | 153 // The returned metadata is used to create a File object for the |path|. |
| 155 // The snapshot file is supposed to be deleted when the last reference to a
WebCore::File referring to it's path is dropped. | 154 // The snapshot file is supposed to be deleted when the last reference to a
WebCore::File referring to it's path is dropped. |
| 156 // WebFileSystemCallbacks::didCreateSnapshotFile() with the metadata of the
snapshot file must be called when the operation is completed successfully. | 155 // WebFileSystemCallbacks::didCreateSnapshotFile() with the metadata of the
snapshot file must be called when the operation is completed successfully. |
| 157 // WebFileSystemCallbacks::didFail() must be called otherwise. | 156 // WebFileSystemCallbacks::didFail() must be called otherwise. |
| 158 virtual void createSnapshotFileAndReadMetadata(const WebURL& path, WebFileSy
stemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); } | 157 virtual void createSnapshotFileAndReadMetadata(const WebURL& path, WebFileSy
stemCallbacks) { WEBKIT_ASSERT_NOT_REACHED(); } |
| 159 | 158 |
| 160 protected: | 159 protected: |
| 161 virtual ~WebFileSystem() { } | 160 virtual ~WebFileSystem() { } |
| 162 }; | 161 }; |
| 163 | 162 |
| 164 } // namespace WebKit | 163 } // namespace WebKit |
| 165 | 164 |
| 166 #endif | 165 #endif |
| OLD | NEW |