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

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

Issue 23704004: Make WebFileSystemCallbacks not self-destruct, deprecate AsyncFileSystem (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months 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 | Annotate | Revision Log
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 13 matching lines...) Expand all
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/platform/AsyncFileSystem.h"
35 #include "modules/filesystem/FileSystemFlags.h" 34 #include "modules/filesystem/FileSystemFlags.h"
36 #include "modules/filesystem/FileSystemType.h" 35 #include "modules/filesystem/FileSystemType.h"
37 #include "weborigin/KURL.h" 36 #include "weborigin/KURL.h"
38 #include "wtf/PassRefPtr.h" 37 #include "wtf/PassRefPtr.h"
39 #include "wtf/RefCounted.h" 38 #include "wtf/RefCounted.h"
40 #include "wtf/text/WTFString.h" 39 #include "wtf/text/WTFString.h"
41 40
41 namespace WebKit {
42 class WebFileSystem;
43 }
44
42 namespace WebCore { 45 namespace WebCore {
43 46
44 class DirectoryEntry; 47 class DirectoryEntry;
45 class DirectoryReaderBase; 48 class DirectoryReaderBase;
46 class EntriesCallback; 49 class EntriesCallback;
47 class EntryBase; 50 class EntryBase;
48 class EntryCallback; 51 class EntryCallback;
49 class ErrorCallback; 52 class ErrorCallback;
50 class MetadataCallback; 53 class MetadataCallback;
51 class ScriptExecutionContext; 54 class ScriptExecutionContext;
52 class SecurityOrigin; 55 class SecurityOrigin;
53 class VoidCallback; 56 class VoidCallback;
54 57
55 // A common base class for DOMFileSystem and DOMFileSystemSync. 58 // A common base class for DOMFileSystem and DOMFileSystemSync.
56 class DOMFileSystemBase : public RefCounted<DOMFileSystemBase> { 59 class DOMFileSystemBase : public RefCounted<DOMFileSystemBase> {
57 public: 60 public:
58 enum SynchronousType { 61 enum SynchronousType {
59 Synchronous, 62 Synchronous,
60 Asynchronous, 63 Asynchronous,
61 }; 64 };
62 65
63 // Path prefixes that are used in the filesystem URLs (that can be obtained by toURL()). 66 // Path prefixes that are used in the filesystem URLs (that can be obtained by toURL()).
64 // http://www.w3.org/TR/file-system-api/#widl-Entry-toURL 67 // http://www.w3.org/TR/file-system-api/#widl-Entry-toURL
65 static const char persistentPathPrefix[]; 68 static const char persistentPathPrefix[];
66 static const char temporaryPathPrefix[]; 69 static const char temporaryPathPrefix[];
67 static const char isolatedPathPrefix[]; 70 static const char isolatedPathPrefix[];
68 static const char externalPathPrefix[]; 71 static const char externalPathPrefix[];
69 72
70 static PassRefPtr<DOMFileSystemBase> create(ScriptExecutionContext* context, const String& name, FileSystemType type, const KURL& rootURL, PassOwnPtr<AsyncF ileSystem> asyncFileSystem) 73 static PassRefPtr<DOMFileSystemBase> create(ScriptExecutionContext* context, const String& name, FileSystemType type, const KURL& rootURL)
71 { 74 {
72 return adoptRef(new DOMFileSystemBase(context, name, type, rootURL, asyn cFileSystem)); 75 return adoptRef(new DOMFileSystemBase(context, name, type, rootURL));
73 } 76 }
74 virtual ~DOMFileSystemBase(); 77 virtual ~DOMFileSystemBase();
75 78
76 const String& name() const { return m_name; } 79 const String& name() const { return m_name; }
77 FileSystemType type() const { return m_type; } 80 FileSystemType type() const { return m_type; }
78 KURL rootURL() const { return m_filesystemRootURL; } 81 KURL rootURL() const { return m_filesystemRootURL; }
79 AsyncFileSystem* asyncFileSystem() const { return m_asyncFileSystem.get(); } 82 WebKit::WebFileSystem* fileSystem() const;
80 SecurityOrigin* securityOrigin() const; 83 SecurityOrigin* securityOrigin() const;
81 84
82 // The clonable flag is used in the structured clone algorithm to test 85 // The clonable flag is used in the structured clone algorithm to test
83 // whether the FileSystem API object is permitted to be cloned. It defaults 86 // whether the FileSystem API object is permitted to be cloned. It defaults
84 // to false, and must be explicitly set by internal code permit cloning. 87 // to false, and must be explicitly set by internal code permit cloning.
85 void makeClonable() { m_clonable = true; } 88 void makeClonable() { m_clonable = true; }
86 bool clonable() const { return m_clonable; } 89 bool clonable() const { return m_clonable; }
87 90
88 static bool isValidType(FileSystemType); 91 static bool isValidType(FileSystemType);
89 static bool crackFileSystemURL(const KURL&, FileSystemType&, String& filePat h); 92 static bool crackFileSystemURL(const KURL&, FileSystemType&, String& filePat h);
90 bool supportsToURL() const; 93 bool supportsToURL() const;
91 KURL createFileSystemURL(const EntryBase*) const; 94 KURL createFileSystemURL(const EntryBase*) const;
92 KURL createFileSystemURL(const String& fullPath) const; 95 KURL createFileSystemURL(const String& fullPath) const;
93 96
94 // Actual FileSystem API implementations. All the validity checks on virtual paths are done at this level. 97 // Actual FileSystem API implementations. All the validity checks on virtual paths are done at this level.
95 // They return false for immediate errors that don't involve lower AsyncFile System layer (e.g. for name validation errors). Otherwise they return true (but later may call back with an runtime error). 98 // They return false for immediate errors that don't involve lower WebFileSy stem layer (e.g. for name validation errors). Otherwise they return true (but la ter may call back with an runtime error).
96 bool getMetadata(const EntryBase*, PassRefPtr<MetadataCallback>, PassRefPtr< ErrorCallback>, SynchronousType = Asynchronous); 99 bool getMetadata(const EntryBase*, PassRefPtr<MetadataCallback>, PassRefPtr< ErrorCallback>, SynchronousType = Asynchronous);
97 bool move(const EntryBase* source, EntryBase* parent, const String& name, Pa ssRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, SynchronousType = Asynchrono us); 100 bool move(const EntryBase* source, EntryBase* parent, const String& name, Pa ssRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, SynchronousType = Asynchrono us);
98 bool copy(const EntryBase* source, EntryBase* parent, const String& name, Pa ssRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, SynchronousType = Asynchrono us); 101 bool copy(const EntryBase* source, EntryBase* parent, const String& name, Pa ssRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, SynchronousType = Asynchrono us);
99 bool remove(const EntryBase*, PassRefPtr<VoidCallback>, PassRefPtr<ErrorCall back>, SynchronousType = Asynchronous); 102 bool remove(const EntryBase*, PassRefPtr<VoidCallback>, PassRefPtr<ErrorCall back>, SynchronousType = Asynchronous);
100 bool removeRecursively(const EntryBase*, PassRefPtr<VoidCallback>, PassRefPt r<ErrorCallback>, SynchronousType = Asynchronous); 103 bool removeRecursively(const EntryBase*, PassRefPtr<VoidCallback>, PassRefPt r<ErrorCallback>, SynchronousType = Asynchronous);
101 bool getParent(const EntryBase*, PassRefPtr<EntryCallback>, PassRefPtr<Error Callback>); 104 bool getParent(const EntryBase*, PassRefPtr<EntryCallback>, PassRefPtr<Error Callback>);
102 bool getFile(const EntryBase*, const String& path, const FileSystemFlags&, P assRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, SynchronousType = Asynchron ous); 105 bool getFile(const EntryBase*, const String& path, const FileSystemFlags&, P assRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, SynchronousType = Asynchron ous);
103 bool getDirectory(const EntryBase*, const String& path, const FileSystemFlag s&, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, SynchronousType = Asyn chronous); 106 bool getDirectory(const EntryBase*, const String& path, const FileSystemFlag s&, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, SynchronousType = Asyn chronous);
104 bool readDirectory(PassRefPtr<DirectoryReaderBase>, const String& path, Pass RefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, SynchronousType = Asynchrono us); 107 bool readDirectory(PassRefPtr<DirectoryReaderBase>, const String& path, Pass RefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, SynchronousType = Asynchrono us);
105 108
106 protected: 109 protected:
107 DOMFileSystemBase(ScriptExecutionContext*, const String& name, FileSystemTyp e, const KURL& rootURL, PassOwnPtr<AsyncFileSystem>); 110 DOMFileSystemBase(ScriptExecutionContext*, const String& name, FileSystemTyp e, const KURL& rootURL);
108 friend class DOMFileSystemSync; 111 friend class DOMFileSystemSync;
109 112
110 ScriptExecutionContext* m_context; 113 ScriptExecutionContext* m_context;
111 String m_name; 114 String m_name;
112 FileSystemType m_type; 115 FileSystemType m_type;
113 KURL m_filesystemRootURL; 116 KURL m_filesystemRootURL;
114 bool m_clonable; 117 bool m_clonable;
115
116 mutable OwnPtr<AsyncFileSystem> m_asyncFileSystem;
117 }; 118 };
118 119
119 inline bool operator==(const DOMFileSystemBase& a, const DOMFileSystemBase& b) { return a.name() == b.name() && a.type() == b.type() && a.rootURL() == b.rootURL (); } 120 inline bool operator==(const DOMFileSystemBase& a, const DOMFileSystemBase& b) { return a.name() == b.name() && a.type() == b.type() && a.rootURL() == b.rootURL (); }
120 121
121 } // namespace WebCore 122 } // namespace WebCore
122 123
123 #endif // DOMFileSystemBase_h 124 #endif // DOMFileSystemBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698