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

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

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

Powered by Google App Engine
This is Rietveld 408576698