• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "WebString.h"
36 
37 namespace WebKit {
38 
39 class WebFileSystemCallbacks;
40 class WebFileWriter;
41 class WebFileWriterClient;
42 
43 // FIXME(zelidrag): Remove this define once Chromium side catches up.
44 #define WEB_FILE_SYSTEM_TYPE_EXTERNAL
45 
46 class WebFileSystem {
47 public:
48     enum Type {
49         TypeTemporary,
50         TypePersistent,
51         TypeExternal,
52     };
53 
54     // Moves a file or directory at |srcPath| to |destPath|.
55     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
56     // WebFileSystemCallbacks::didFail() must be called otherwise.
move(const WebString & srcPath,const WebString & destPath,WebFileSystemCallbacks *)57     virtual void move(const WebString& srcPath, const WebString& destPath, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
58 
59     // Copies a file or directory at |srcPath| to |destPath|.
60     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
61     // WebFileSystemCallbacks::didFail() must be called otherwise.
copy(const WebString & srcPath,const WebString & destPath,WebFileSystemCallbacks *)62     virtual void copy(const WebString& srcPath, const WebString& destPath, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
63 
64     // Deletes a file or directory at a given |path|.
65     // It is an error to try to remove a directory that is not empty.
66     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
67     // WebFileSystemCallbacks::didFail() must be called otherwise.
remove(const WebString & path,WebFileSystemCallbacks *)68     virtual void remove(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
69 
70     // Deletes a file or directory recursively at a given |path|.
71     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
72     // WebFileSystemCallbacks::didFail() must be called otherwise.
removeRecursively(const WebString & path,WebFileSystemCallbacks *)73     virtual void removeRecursively(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
74 
75     // Retrieves the metadata information of the file or directory at the given |path|.
76     // WebFileSystemCallbacks::didReadMetadata() must be called with a valid metadata when the retrieval is completed successfully.
77     // WebFileSystemCallbacks::didFail() must be called otherwise.
readMetadata(const WebString & path,WebFileSystemCallbacks *)78     virtual void readMetadata(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
79 
80     // Creates a file at given |path|.
81     // If the |path| doesn't exist, it creates a new file at |path|.
82     // If |exclusive| is true, it fails if the |path| already exists.
83     // If |exclusive| is false, it succeeds if the |path| already exists or
84     // it has successfully created a new file at |path|.
85     //
86     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
87     // WebFileSystemCallbacks::didFail() must be called otherwise.
createFile(const WebString & path,bool exclusive,WebFileSystemCallbacks *)88     virtual void createFile(const WebString& path, bool exclusive, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
89 
90     // Creates a directory at a given |path|.
91     // If the |path| doesn't exist, it creates a new directory at |path|.
92     // If |exclusive| is true, it fails if the |path| already exists.
93     // If |exclusive| is false, it succeeds if the |path| already exists or it has successfully created a new directory at |path|.
94     //
95     // WebFileSystemCallbacks::didSucceed() must be called when
96     // the operation is completed successfully.
97     // WebFileSystemCallbacks::didFail() must be called otherwise.
createDirectory(const WebString & path,bool exclusive,WebFileSystemCallbacks *)98     virtual void createDirectory(const WebString& path, bool exclusive, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
99 
100     // Checks if a file exists at a given |path|.
101     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
102     // WebFileSystemCallbacks::didFail() must be called otherwise.
fileExists(const WebString & path,WebFileSystemCallbacks *)103     virtual void fileExists(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
104 
105     // Checks if a directory exists at a given |path|.
106     // WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
107     // WebFileSystemCallbacks::didFail() must be called otherwise.
directoryExists(const WebString & path,WebFileSystemCallbacks *)108     virtual void directoryExists(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
109 
110     // Reads directory entries of a given directory at |path|.
111     // WebFileSystemCallbacks::didReadDirectory() must be called when the operation is completed successfully.
112     // WebFileSystemCallbacks::didFail() must be called otherwise.
readDirectory(const WebString & path,WebFileSystemCallbacks *)113     virtual void readDirectory(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
114 
115     // Creates a WebFileWriter that can be used to write to the given file.
116     // This is a fast, synchronous call, and should not stat the filesystem.
createFileWriter(const WebString & path,WebFileWriterClient *)117     virtual WebFileWriter* createFileWriter(const WebString& path, WebFileWriterClient*) { WEBKIT_ASSERT_NOT_REACHED(); return 0; }
118 
119 protected:
~WebFileSystem()120     virtual ~WebFileSystem() { }
121 };
122 
123 } // namespace WebKit
124 
125 #endif
126