initial import
[vuplus_webkit] / Source / WebKit / chromium / public / WebFileSystem.h
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29  */
30
31 #ifndef WebFileSystem_h
32 #define WebFileSystem_h
33
34 #include "WebCommon.h"
35 #include "WebURL.h"
36
37 namespace WebKit {
38
39 class WebFileSystemCallbacks;
40 class WebFileWriter;
41 class WebFileWriterClient;
42
43 class WebFileSystem {
44 public:
45     enum Type {
46         TypeTemporary,
47         TypePersistent,
48         TypeExternal,
49     };
50
51     // Moves a file or directory at |srcPath| to |destPath|.
52     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
53     // WebFileSystemCallbacks::didFail() must be called otherwise.
54     virtual void move(const WebURL& srcPath, const WebURL& destPath, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
55
56     // Copies a file or directory at |srcPath| to |destPath|.
57     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
58     // WebFileSystemCallbacks::didFail() must be called otherwise.
59     virtual void copy(const WebURL& srcPath, const WebURL& destPath, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
60
61     // Deletes a file or directory at a given |path|.
62     // It is an error to try to remove a directory that is not empty.
63     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
64     // WebFileSystemCallbacks::didFail() must be called otherwise.
65     virtual void remove(const WebURL& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
66
67     // Deletes a file or directory recursively at a given |path|.
68     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
69     // WebFileSystemCallbacks::didFail() must be called otherwise.
70     virtual void removeRecursively(const WebURL& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
71
72     // Retrieves the metadata information of the file or directory at the given |path|.
73     // WebFileSystemCallbacks::didReadMetadata() must be called with a valid metadata when the retrieval is completed successfully.
74     // WebFileSystemCallbacks::didFail() must be called otherwise.
75     virtual void readMetadata(const WebURL& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
76
77     // Creates a file at given |path|.
78     // If the |path| doesn't exist, it creates a new file at |path|.
79     // If |exclusive| is true, it fails if the |path| already exists.
80     // If |exclusive| is false, it succeeds if the |path| already exists or
81     // it has successfully created a new file at |path|.
82     //
83     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
84     // WebFileSystemCallbacks::didFail() must be called otherwise.
85     virtual void createFile(const WebURL& path, bool exclusive, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
86
87     // Creates a directory at a given |path|.
88     // If the |path| doesn't exist, it creates a new directory at |path|.
89     // If |exclusive| is true, it fails if the |path| already exists.
90     // If |exclusive| is false, it succeeds if the |path| already exists or it has successfully created a new directory at |path|.
91     //
92     // WebFileSystemCallbacks::didSucceed() must be called when
93     // the operation is completed successfully.
94     // WebFileSystemCallbacks::didFail() must be called otherwise.
95     virtual void createDirectory(const WebURL& path, bool exclusive, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
96
97     // Checks if a file exists at a given |path|.
98     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
99     // WebFileSystemCallbacks::didFail() must be called otherwise.
100     virtual void fileExists(const WebURL& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
101
102     // Checks if a directory exists at a given |path|.
103     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
104     // WebFileSystemCallbacks::didFail() must be called otherwise.
105     virtual void directoryExists(const WebURL& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
106
107     // Reads directory entries of a given directory at |path|.
108     // WebFileSystemCallbacks::didReadDirectory() must be called when the operation is completed successfully.
109     // WebFileSystemCallbacks::didFail() must be called otherwise.
110     virtual void readDirectory(const WebURL& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
111
112     // Creates a WebFileWriter that can be used to write to the given file.
113     // This is a fast, synchronous call, and should not stat the filesystem.
114     virtual WebFileWriter* createFileWriter(const WebURL& path, WebFileWriterClient*) { WEBKIT_ASSERT_NOT_REACHED(); return 0; }
115
116 protected:
117     virtual ~WebFileSystem() { }
118 };
119
120 } // namespace WebKit
121
122 #endif