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 18 matching lines...) Expand all Loading... |
29 */ | 29 */ |
30 | 30 |
31 #ifndef FileSystemCallbacks_h | 31 #ifndef FileSystemCallbacks_h |
32 #define FileSystemCallbacks_h | 32 #define FileSystemCallbacks_h |
33 | 33 |
34 #include "modules/filesystem/EntriesCallback.h" | 34 #include "modules/filesystem/EntriesCallback.h" |
35 #include "platform/AsyncFileSystemCallbacks.h" | 35 #include "platform/AsyncFileSystemCallbacks.h" |
36 #include "platform/FileSystemType.h" | 36 #include "platform/FileSystemType.h" |
37 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
38 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
| 39 #include <memory> |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
41 | 42 |
42 class DOMFileSystemBase; | 43 class DOMFileSystemBase; |
43 class DirectoryReaderBase; | 44 class DirectoryReaderBase; |
44 class EntriesCallback; | 45 class EntriesCallback; |
45 class EntryCallback; | 46 class EntryCallback; |
46 class ErrorCallback; | 47 class ErrorCallback; |
47 class BlobCallback; | 48 class BlobCallback; |
48 class FileMetadata; | 49 class FileMetadata; |
(...skipping 27 matching lines...) Expand all Loading... |
76 Persistent<ErrorCallback> m_errorCallback; | 77 Persistent<ErrorCallback> m_errorCallback; |
77 Persistent<DOMFileSystemBase> m_fileSystem; | 78 Persistent<DOMFileSystemBase> m_fileSystem; |
78 Persistent<ExecutionContext> m_executionContext; | 79 Persistent<ExecutionContext> m_executionContext; |
79 int m_asyncOperationId; | 80 int m_asyncOperationId; |
80 }; | 81 }; |
81 | 82 |
82 // Subclasses ---------------------------------------------------------------- | 83 // Subclasses ---------------------------------------------------------------- |
83 | 84 |
84 class EntryCallbacks final : public FileSystemCallbacksBase { | 85 class EntryCallbacks final : public FileSystemCallbacksBase { |
85 public: | 86 public: |
86 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCall
back*, ExecutionContext*, DOMFileSystemBase*, const String& expectedPath, bool i
sDirectory); | 87 static std::unique_ptr<AsyncFileSystemCallbacks> create(EntryCallback*, Erro
rCallback*, ExecutionContext*, DOMFileSystemBase*, const String& expectedPath, b
ool isDirectory); |
87 void didSucceed() override; | 88 void didSucceed() override; |
88 | 89 |
89 private: | 90 private: |
90 EntryCallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*, DOMFileSys
temBase*, const String& expectedPath, bool isDirectory); | 91 EntryCallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*, DOMFileSys
temBase*, const String& expectedPath, bool isDirectory); |
91 Persistent<EntryCallback> m_successCallback; | 92 Persistent<EntryCallback> m_successCallback; |
92 String m_expectedPath; | 93 String m_expectedPath; |
93 bool m_isDirectory; | 94 bool m_isDirectory; |
94 }; | 95 }; |
95 | 96 |
96 class EntriesCallbacks final : public FileSystemCallbacksBase { | 97 class EntriesCallbacks final : public FileSystemCallbacksBase { |
97 public: | 98 public: |
98 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntriesCallback*, ErrorCa
llback*, ExecutionContext*, DirectoryReaderBase*, const String& basePath); | 99 static std::unique_ptr<AsyncFileSystemCallbacks> create(EntriesCallback*, Er
rorCallback*, ExecutionContext*, DirectoryReaderBase*, const String& basePath); |
99 void didReadDirectoryEntry(const String& name, bool isDirectory) override; | 100 void didReadDirectoryEntry(const String& name, bool isDirectory) override; |
100 void didReadDirectoryEntries(bool hasMore) override; | 101 void didReadDirectoryEntries(bool hasMore) override; |
101 | 102 |
102 private: | 103 private: |
103 EntriesCallbacks(EntriesCallback*, ErrorCallback*, ExecutionContext*, Direct
oryReaderBase*, const String& basePath); | 104 EntriesCallbacks(EntriesCallback*, ErrorCallback*, ExecutionContext*, Direct
oryReaderBase*, const String& basePath); |
104 Persistent<EntriesCallback> m_successCallback; | 105 Persistent<EntriesCallback> m_successCallback; |
105 Persistent<DirectoryReaderBase> m_directoryReader; | 106 Persistent<DirectoryReaderBase> m_directoryReader; |
106 String m_basePath; | 107 String m_basePath; |
107 PersistentHeapVector<Member<Entry>> m_entries; | 108 PersistentHeapVector<Member<Entry>> m_entries; |
108 }; | 109 }; |
109 | 110 |
110 class FileSystemCallbacks final : public FileSystemCallbacksBase { | 111 class FileSystemCallbacks final : public FileSystemCallbacksBase { |
111 public: | 112 public: |
112 static PassOwnPtr<AsyncFileSystemCallbacks> create(FileSystemCallback*, Erro
rCallback*, ExecutionContext*, FileSystemType); | 113 static std::unique_ptr<AsyncFileSystemCallbacks> create(FileSystemCallback*,
ErrorCallback*, ExecutionContext*, FileSystemType); |
113 void didOpenFileSystem(const String& name, const KURL& rootURL) override; | 114 void didOpenFileSystem(const String& name, const KURL& rootURL) override; |
114 | 115 |
115 private: | 116 private: |
116 FileSystemCallbacks(FileSystemCallback*, ErrorCallback*, ExecutionContext*,
FileSystemType); | 117 FileSystemCallbacks(FileSystemCallback*, ErrorCallback*, ExecutionContext*,
FileSystemType); |
117 Persistent<FileSystemCallback> m_successCallback; | 118 Persistent<FileSystemCallback> m_successCallback; |
118 FileSystemType m_type; | 119 FileSystemType m_type; |
119 }; | 120 }; |
120 | 121 |
121 class ResolveURICallbacks final : public FileSystemCallbacksBase { | 122 class ResolveURICallbacks final : public FileSystemCallbacksBase { |
122 public: | 123 public: |
123 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCall
back*, ExecutionContext*); | 124 static std::unique_ptr<AsyncFileSystemCallbacks> create(EntryCallback*, Erro
rCallback*, ExecutionContext*); |
124 void didResolveURL(const String& name, const KURL& rootURL, FileSystemType,
const String& filePath, bool isDirectry) override; | 125 void didResolveURL(const String& name, const KURL& rootURL, FileSystemType,
const String& filePath, bool isDirectry) override; |
125 | 126 |
126 private: | 127 private: |
127 ResolveURICallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*); | 128 ResolveURICallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*); |
128 Persistent<EntryCallback> m_successCallback; | 129 Persistent<EntryCallback> m_successCallback; |
129 }; | 130 }; |
130 | 131 |
131 class MetadataCallbacks final : public FileSystemCallbacksBase { | 132 class MetadataCallbacks final : public FileSystemCallbacksBase { |
132 public: | 133 public: |
133 static PassOwnPtr<AsyncFileSystemCallbacks> create(MetadataCallback*, ErrorC
allback*, ExecutionContext*, DOMFileSystemBase*); | 134 static std::unique_ptr<AsyncFileSystemCallbacks> create(MetadataCallback*, E
rrorCallback*, ExecutionContext*, DOMFileSystemBase*); |
134 void didReadMetadata(const FileMetadata&) override; | 135 void didReadMetadata(const FileMetadata&) override; |
135 | 136 |
136 private: | 137 private: |
137 MetadataCallbacks(MetadataCallback*, ErrorCallback*, ExecutionContext*, DOMF
ileSystemBase*); | 138 MetadataCallbacks(MetadataCallback*, ErrorCallback*, ExecutionContext*, DOMF
ileSystemBase*); |
138 Persistent<MetadataCallback> m_successCallback; | 139 Persistent<MetadataCallback> m_successCallback; |
139 }; | 140 }; |
140 | 141 |
141 class FileWriterBaseCallbacks final : public FileSystemCallbacksBase { | 142 class FileWriterBaseCallbacks final : public FileSystemCallbacksBase { |
142 public: | 143 public: |
143 static PassOwnPtr<AsyncFileSystemCallbacks> create(FileWriterBase*, FileWrit
erBaseCallback*, ErrorCallback*, ExecutionContext*); | 144 static std::unique_ptr<AsyncFileSystemCallbacks> create(FileWriterBase*, Fil
eWriterBaseCallback*, ErrorCallback*, ExecutionContext*); |
144 void didCreateFileWriter(PassOwnPtr<WebFileWriter>, long long length) overri
de; | 145 void didCreateFileWriter(std::unique_ptr<WebFileWriter>, long long length) o
verride; |
145 | 146 |
146 private: | 147 private: |
147 FileWriterBaseCallbacks(FileWriterBase*, FileWriterBaseCallback*, ErrorCallb
ack*, ExecutionContext*); | 148 FileWriterBaseCallbacks(FileWriterBase*, FileWriterBaseCallback*, ErrorCallb
ack*, ExecutionContext*); |
148 Persistent<FileWriterBase> m_fileWriter; | 149 Persistent<FileWriterBase> m_fileWriter; |
149 Persistent<FileWriterBaseCallback> m_successCallback; | 150 Persistent<FileWriterBaseCallback> m_successCallback; |
150 }; | 151 }; |
151 | 152 |
152 class SnapshotFileCallback final : public FileSystemCallbacksBase { | 153 class SnapshotFileCallback final : public FileSystemCallbacksBase { |
153 public: | 154 public: |
154 static PassOwnPtr<AsyncFileSystemCallbacks> create(DOMFileSystemBase*, const
String& name, const KURL&, BlobCallback*, ErrorCallback*, ExecutionContext*); | 155 static std::unique_ptr<AsyncFileSystemCallbacks> create(DOMFileSystemBase*,
const String& name, const KURL&, BlobCallback*, ErrorCallback*, ExecutionContext
*); |
155 virtual void didCreateSnapshotFile(const FileMetadata&, PassRefPtr<BlobDataH
andle> snapshot); | 156 virtual void didCreateSnapshotFile(const FileMetadata&, PassRefPtr<BlobDataH
andle> snapshot); |
156 | 157 |
157 private: | 158 private: |
158 SnapshotFileCallback(DOMFileSystemBase*, const String& name, const KURL&, Bl
obCallback*, ErrorCallback*, ExecutionContext*); | 159 SnapshotFileCallback(DOMFileSystemBase*, const String& name, const KURL&, Bl
obCallback*, ErrorCallback*, ExecutionContext*); |
159 String m_name; | 160 String m_name; |
160 KURL m_url; | 161 KURL m_url; |
161 Persistent<BlobCallback> m_successCallback; | 162 Persistent<BlobCallback> m_successCallback; |
162 }; | 163 }; |
163 | 164 |
164 class VoidCallbacks final : public FileSystemCallbacksBase { | 165 class VoidCallbacks final : public FileSystemCallbacksBase { |
165 public: | 166 public: |
166 static PassOwnPtr<AsyncFileSystemCallbacks> create(VoidCallback*, ErrorCallb
ack*, ExecutionContext*, DOMFileSystemBase*); | 167 static std::unique_ptr<AsyncFileSystemCallbacks> create(VoidCallback*, Error
Callback*, ExecutionContext*, DOMFileSystemBase*); |
167 void didSucceed() override; | 168 void didSucceed() override; |
168 | 169 |
169 private: | 170 private: |
170 VoidCallbacks(VoidCallback*, ErrorCallback*, ExecutionContext*, DOMFileSyste
mBase*); | 171 VoidCallbacks(VoidCallback*, ErrorCallback*, ExecutionContext*, DOMFileSyste
mBase*); |
171 Persistent<VoidCallback> m_successCallback; | 172 Persistent<VoidCallback> m_successCallback; |
172 }; | 173 }; |
173 | 174 |
174 } // namespace blink | 175 } // namespace blink |
175 | 176 |
176 #endif // FileSystemCallbacks_h | 177 #endif // FileSystemCallbacks_h |
OLD | NEW |