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

Side by Side Diff: third_party/WebKit/Source/modules/filesystem/DOMFileSystemBase.h

Issue 2297043002: Web expose FileSystemFileEntry, FileSystemDirectoryEntry and friends (Closed)
Patch Set: Rebased Created 4 years 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
(Empty)
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 DOMFileSystemBase_h
32 #define DOMFileSystemBase_h
33
34 #include "core/fileapi/FileError.h"
35 #include "modules/ModulesExport.h"
36 #include "modules/filesystem/FileSystemFlags.h"
37 #include "platform/FileSystemType.h"
38 #include "platform/heap/Handle.h"
39 #include "platform/weborigin/KURL.h"
40 #include "wtf/text/WTFString.h"
41
42 namespace blink {
43 class WebFileSystem;
44 }
45
46 namespace blink {
47
48 class DirectoryReaderBase;
49 class EntriesCallback;
50 class EntryBase;
51 class EntryCallback;
52 class ErrorCallbackBase;
53 class File;
54 class FileMetadata;
55 class MetadataCallback;
56 class ExecutionContext;
57 class SecurityOrigin;
58 class VoidCallback;
59
60 // A common base class for DOMFileSystem and DOMFileSystemSync.
61 class MODULES_EXPORT DOMFileSystemBase
62 : public GarbageCollectedFinalized<DOMFileSystemBase> {
63 public:
64 enum SynchronousType {
65 Synchronous,
66 Asynchronous,
67 };
68
69 // Path prefixes that are used in the filesystem URLs (that can be obtained by
70 // toURL()). http://www.w3.org/TR/file-system-api/#widl-Entry-toURL
71 static const char persistentPathPrefix[];
72 static const char temporaryPathPrefix[];
73 static const char isolatedPathPrefix[];
74 static const char externalPathPrefix[];
75
76 virtual ~DOMFileSystemBase();
77
78 // These are called when a new callback is created and resolved in
79 // FileSystem API, so that subclasses can track the number of pending
80 // callbacks if necessary.
81 virtual void addPendingCallbacks() {}
82 virtual void removePendingCallbacks() {}
83
84 // Overridden by subclasses to handle sync vs async error-handling.
85 virtual void reportError(ErrorCallbackBase*, FileError::ErrorCode) = 0;
86
87 const String& name() const { return m_name; }
88 FileSystemType type() const { return m_type; }
89 KURL rootURL() const { return m_filesystemRootURL; }
90 WebFileSystem* fileSystem() const;
91 SecurityOrigin* getSecurityOrigin() const;
92
93 // The clonable flag is used in the structured clone algorithm to test
94 // whether the FileSystem API object is permitted to be cloned. It defaults
95 // to false, and must be explicitly set by internal code permit cloning.
96 void makeClonable() { m_clonable = true; }
97 bool clonable() const { return m_clonable; }
98
99 static bool isValidType(FileSystemType);
100 static KURL createFileSystemRootURL(const String& origin, FileSystemType);
101 bool supportsToURL() const;
102 KURL createFileSystemURL(const EntryBase*) const;
103 KURL createFileSystemURL(const String& fullPath) const;
104 static bool pathToAbsolutePath(FileSystemType,
105 const EntryBase*,
106 String path,
107 String& absolutePath);
108 static bool pathPrefixToFileSystemType(const String& pathPrefix,
109 FileSystemType&);
110 static File* createFile(const FileMetadata&,
111 const KURL& fileSystemURL,
112 FileSystemType,
113 const String name);
114
115 // Actual FileSystem API implementations. All the validity checks on virtual
116 // paths are done at this level.
117 void getMetadata(const EntryBase*,
118 MetadataCallback*,
119 ErrorCallbackBase*,
120 SynchronousType = Asynchronous);
121 void move(const EntryBase* source,
122 EntryBase* parent,
123 const String& name,
124 EntryCallback*,
125 ErrorCallbackBase*,
126 SynchronousType = Asynchronous);
127 void copy(const EntryBase* source,
128 EntryBase* parent,
129 const String& name,
130 EntryCallback*,
131 ErrorCallbackBase*,
132 SynchronousType = Asynchronous);
133 void remove(const EntryBase*,
134 VoidCallback*,
135 ErrorCallbackBase*,
136 SynchronousType = Asynchronous);
137 void removeRecursively(const EntryBase*,
138 VoidCallback*,
139 ErrorCallbackBase*,
140 SynchronousType = Asynchronous);
141 void getParent(const EntryBase*, EntryCallback*, ErrorCallbackBase*);
142 void getFile(const EntryBase*,
143 const String& path,
144 const FileSystemFlags&,
145 EntryCallback*,
146 ErrorCallbackBase*,
147 SynchronousType = Asynchronous);
148 void getDirectory(const EntryBase*,
149 const String& path,
150 const FileSystemFlags&,
151 EntryCallback*,
152 ErrorCallbackBase*,
153 SynchronousType = Asynchronous);
154 int readDirectory(DirectoryReaderBase*,
155 const String& path,
156 EntriesCallback*,
157 ErrorCallbackBase*,
158 SynchronousType = Asynchronous);
159 bool waitForAdditionalResult(int callbacksId);
160
161 DECLARE_VIRTUAL_TRACE();
162
163 protected:
164 DOMFileSystemBase(ExecutionContext*,
165 const String& name,
166 FileSystemType,
167 const KURL& rootURL);
168
169 friend class DOMFileSystemBaseTest;
170 friend class DOMFileSystemSync;
171
172 Member<ExecutionContext> m_context;
173 String m_name;
174 FileSystemType m_type;
175 KURL m_filesystemRootURL;
176 bool m_clonable;
177 };
178
179 inline bool operator==(const DOMFileSystemBase& a, const DOMFileSystemBase& b) {
180 return a.name() == b.name() && a.type() == b.type() &&
181 a.rootURL() == b.rootURL();
182 }
183
184 } // namespace blink
185
186 #endif // DOMFileSystemBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698