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