| 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 13 matching lines...) Expand all Loading... |
| 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 DOMFileSystemBase_h |
| 32 #define DOMFileSystemBase_h | 32 #define DOMFileSystemBase_h |
| 33 | 33 |
| 34 #include "core/fileapi/FileError.h" |
| 34 #include "modules/ModulesExport.h" | 35 #include "modules/ModulesExport.h" |
| 35 #include "modules/filesystem/FileSystemFlags.h" | 36 #include "modules/filesystem/FileSystemFlags.h" |
| 36 #include "platform/FileSystemType.h" | 37 #include "platform/FileSystemType.h" |
| 37 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
| 38 #include "platform/weborigin/KURL.h" | 39 #include "platform/weborigin/KURL.h" |
| 39 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 class WebFileSystem; | 43 class WebFileSystem; |
| 43 } | 44 } |
| 44 | 45 |
| 45 namespace blink { | 46 namespace blink { |
| 46 | 47 |
| 47 class DirectoryReaderBase; | 48 class DirectoryReaderBase; |
| 48 class EntriesCallback; | 49 class EntriesCallback; |
| 49 class EntryBase; | 50 class EntryBase; |
| 50 class EntryCallback; | 51 class EntryCallback; |
| 51 class ErrorCallback; | 52 class ErrorCallbackBase; |
| 52 class File; | 53 class File; |
| 53 class FileError; | |
| 54 class FileMetadata; | 54 class FileMetadata; |
| 55 class MetadataCallback; | 55 class MetadataCallback; |
| 56 class ExecutionContext; | 56 class ExecutionContext; |
| 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 DOMFileSystem and DOMFileSystemSync. |
| 61 class MODULES_EXPORT DOMFileSystemBase : public GarbageCollectedFinalized<DOMFil
eSystemBase> { | 61 class MODULES_EXPORT DOMFileSystemBase : public GarbageCollectedFinalized<DOMFil
eSystemBase> { |
| 62 public: | 62 public: |
| 63 enum SynchronousType { | 63 enum SynchronousType { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 74 | 74 |
| 75 virtual ~DOMFileSystemBase(); | 75 virtual ~DOMFileSystemBase(); |
| 76 | 76 |
| 77 // These are called when a new callback is created and resolved in | 77 // These are called when a new callback is created and resolved in |
| 78 // FileSystem API, so that subclasses can track the number of pending | 78 // FileSystem API, so that subclasses can track the number of pending |
| 79 // callbacks if necessary. | 79 // callbacks if necessary. |
| 80 virtual void addPendingCallbacks() { } | 80 virtual void addPendingCallbacks() { } |
| 81 virtual void removePendingCallbacks() { } | 81 virtual void removePendingCallbacks() { } |
| 82 | 82 |
| 83 // Overridden by subclasses to handle sync vs async error-handling. | 83 // Overridden by subclasses to handle sync vs async error-handling. |
| 84 virtual void reportError(ErrorCallback*, FileError*) = 0; | 84 virtual void reportError(ErrorCallbackBase*, FileError::ErrorCode) = 0; |
| 85 | 85 |
| 86 const String& name() const { return m_name; } | 86 const String& name() const { return m_name; } |
| 87 FileSystemType type() const { return m_type; } | 87 FileSystemType type() const { return m_type; } |
| 88 KURL rootURL() const { return m_filesystemRootURL; } | 88 KURL rootURL() const { return m_filesystemRootURL; } |
| 89 WebFileSystem* fileSystem() const; | 89 WebFileSystem* fileSystem() const; |
| 90 SecurityOrigin* getSecurityOrigin() const; | 90 SecurityOrigin* getSecurityOrigin() const; |
| 91 | 91 |
| 92 // The clonable flag is used in the structured clone algorithm to test | 92 // The clonable flag is used in the structured clone algorithm to test |
| 93 // whether the FileSystem API object is permitted to be cloned. It defaults | 93 // whether the FileSystem API object is permitted to be cloned. It defaults |
| 94 // to false, and must be explicitly set by internal code permit cloning. | 94 // to false, and must be explicitly set by internal code permit cloning. |
| 95 void makeClonable() { m_clonable = true; } | 95 void makeClonable() { m_clonable = true; } |
| 96 bool clonable() const { return m_clonable; } | 96 bool clonable() const { return m_clonable; } |
| 97 | 97 |
| 98 static bool isValidType(FileSystemType); | 98 static bool isValidType(FileSystemType); |
| 99 static bool crackFileSystemURL(const KURL&, FileSystemType&, String& filePat
h); | 99 static bool crackFileSystemURL(const KURL&, FileSystemType&, String& filePat
h); |
| 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 EntryBase*) const; |
| 103 KURL createFileSystemURL(const String& fullPath) const; | 103 KURL createFileSystemURL(const String& fullPath) const; |
| 104 static bool pathToAbsolutePath(FileSystemType, const EntryBase*, String path
, String& absolutePath); | 104 static bool pathToAbsolutePath(FileSystemType, const EntryBase*, String path
, String& absolutePath); |
| 105 static bool pathPrefixToFileSystemType(const String& pathPrefix, FileSystemT
ype&); | 105 static bool pathPrefixToFileSystemType(const String& pathPrefix, FileSystemT
ype&); |
| 106 static File* createFile(const FileMetadata&, const KURL& fileSystemURL, File
SystemType, const String name); | 106 static File* createFile(const FileMetadata&, const KURL& fileSystemURL, File
SystemType, const String name); |
| 107 | 107 |
| 108 // Actual FileSystem API implementations. All the validity checks on virtual
paths are done at this level. | 108 // Actual FileSystem API implementations. All the validity checks on virtual
paths are done at this level. |
| 109 void getMetadata(const EntryBase*, MetadataCallback*, ErrorCallback*, Synchr
onousType = Asynchronous); | 109 void getMetadata(const EntryBase*, MetadataCallback*, ErrorCallbackBase*, Sy
nchronousType = Asynchronous); |
| 110 void move(const EntryBase* source, EntryBase* parent, const String& name, En
tryCallback*, ErrorCallback*, SynchronousType = Asynchronous); | 110 void move(const EntryBase* source, EntryBase* parent, const String& name, En
tryCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous); |
| 111 void copy(const EntryBase* source, EntryBase* parent, const String& name, En
tryCallback*, ErrorCallback*, SynchronousType = Asynchronous); | 111 void copy(const EntryBase* source, EntryBase* parent, const String& name, En
tryCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous); |
| 112 void remove(const EntryBase*, VoidCallback*, ErrorCallback*, SynchronousType
= Asynchronous); | 112 void remove(const EntryBase*, VoidCallback*, ErrorCallbackBase*, Synchronous
Type = Asynchronous); |
| 113 void removeRecursively(const EntryBase*, VoidCallback*, ErrorCallback*, Sync
hronousType = Asynchronous); | 113 void removeRecursively(const EntryBase*, VoidCallback*, ErrorCallbackBase*,
SynchronousType = Asynchronous); |
| 114 void getParent(const EntryBase*, EntryCallback*, ErrorCallback*); | 114 void getParent(const EntryBase*, EntryCallback*, ErrorCallbackBase*); |
| 115 void getFile(const EntryBase*, const String& path, const FileSystemFlags&, E
ntryCallback*, ErrorCallback*, SynchronousType = Asynchronous); | 115 void getFile(const EntryBase*, const String& path, const FileSystemFlags&, E
ntryCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous); |
| 116 void getDirectory(const EntryBase*, const String& path, const FileSystemFlag
s&, EntryCallback*, ErrorCallback*, SynchronousType = Asynchronous); | 116 void getDirectory(const EntryBase*, const String& path, const FileSystemFlag
s&, EntryCallback*, ErrorCallbackBase*, SynchronousType = Asynchronous); |
| 117 int readDirectory(DirectoryReaderBase*, const String& path, EntriesCallback*
, ErrorCallback*, SynchronousType = Asynchronous); | 117 int readDirectory(DirectoryReaderBase*, const String& path, EntriesCallback*
, ErrorCallbackBase*, SynchronousType = Asynchronous); |
| 118 bool waitForAdditionalResult(int callbacksId); | 118 bool waitForAdditionalResult(int callbacksId); |
| 119 | 119 |
| 120 DECLARE_VIRTUAL_TRACE(); | 120 DECLARE_VIRTUAL_TRACE(); |
| 121 | 121 |
| 122 protected: | 122 protected: |
| 123 DOMFileSystemBase(ExecutionContext*, const String& name, FileSystemType, con
st KURL& rootURL); | 123 DOMFileSystemBase(ExecutionContext*, const String& name, FileSystemType, con
st KURL& rootURL); |
| 124 | 124 |
| 125 friend class DOMFileSystemBaseTest; | 125 friend class DOMFileSystemBaseTest; |
| 126 friend class DOMFileSystemSync; | 126 friend class DOMFileSystemSync; |
| 127 | 127 |
| 128 Member<ExecutionContext> m_context; | 128 Member<ExecutionContext> m_context; |
| 129 String m_name; | 129 String m_name; |
| 130 FileSystemType m_type; | 130 FileSystemType m_type; |
| 131 KURL m_filesystemRootURL; | 131 KURL m_filesystemRootURL; |
| 132 bool m_clonable; | 132 bool m_clonable; |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 inline bool operator==(const DOMFileSystemBase& a, const DOMFileSystemBase& b) {
return a.name() == b.name() && a.type() == b.type() && a.rootURL() == b.rootURL
(); } | 135 inline bool operator==(const DOMFileSystemBase& a, const DOMFileSystemBase& b) {
return a.name() == b.name() && a.type() == b.type() && a.rootURL() == b.rootURL
(); } |
| 136 | 136 |
| 137 } // namespace blink | 137 } // namespace blink |
| 138 | 138 |
| 139 #endif // DOMFileSystemBase_h | 139 #endif // DOMFileSystemBase_h |
| OLD | NEW |