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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 class FileMetadata; | 48 class FileMetadata; |
49 class FileSystemCallback; | 49 class FileSystemCallback; |
50 class FileWriterBase; | 50 class FileWriterBase; |
51 class FileWriterBaseCallback; | 51 class FileWriterBaseCallback; |
52 class MetadataCallback; | 52 class MetadataCallback; |
53 class ExecutionContext; | 53 class ExecutionContext; |
54 class VoidCallback; | 54 class VoidCallback; |
55 | 55 |
56 class FileSystemCallbacksBase : public AsyncFileSystemCallbacks { | 56 class FileSystemCallbacksBase : public AsyncFileSystemCallbacks { |
57 public: | 57 public: |
58 virtual ~FileSystemCallbacksBase(); | 58 ~FileSystemCallbacksBase() override; |
59 | 59 |
60 // For ErrorCallback. | 60 // For ErrorCallback. |
61 virtual void didFail(int code) override final; | 61 void didFail(int code) final; |
62 | 62 |
63 // Other callback methods are implemented by each subclass. | 63 // Other callback methods are implemented by each subclass. |
64 | 64 |
65 protected: | 65 protected: |
66 FileSystemCallbacksBase(ErrorCallback*, DOMFileSystemBase*, ExecutionContext
*); | 66 FileSystemCallbacksBase(ErrorCallback*, DOMFileSystemBase*, ExecutionContext
*); |
67 | 67 |
68 bool shouldScheduleCallback() const; | 68 bool shouldScheduleCallback() const; |
69 | 69 |
70 template <typename CB, typename CBArg> | 70 template <typename CB, typename CBArg> |
71 void handleEventOrScheduleCallback(RawPtr<CB>, CBArg*); | 71 void handleEventOrScheduleCallback(RawPtr<CB>, CBArg*); |
72 | 72 |
73 template <typename CB> | 73 template <typename CB> |
74 void handleEventOrScheduleCallback(RawPtr<CB>); | 74 void handleEventOrScheduleCallback(RawPtr<CB>); |
75 | 75 |
76 Persistent<ErrorCallback> m_errorCallback; | 76 Persistent<ErrorCallback> m_errorCallback; |
77 Persistent<DOMFileSystemBase> m_fileSystem; | 77 Persistent<DOMFileSystemBase> m_fileSystem; |
78 RefPtrWillBePersistent<ExecutionContext> m_executionContext; | 78 RefPtrWillBePersistent<ExecutionContext> m_executionContext; |
79 int m_asyncOperationId; | 79 int m_asyncOperationId; |
80 }; | 80 }; |
81 | 81 |
82 // Subclasses ---------------------------------------------------------------- | 82 // Subclasses ---------------------------------------------------------------- |
83 | 83 |
84 class EntryCallbacks final : public FileSystemCallbacksBase { | 84 class EntryCallbacks final : public FileSystemCallbacksBase { |
85 public: | 85 public: |
86 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCall
back*, ExecutionContext*, DOMFileSystemBase*, const String& expectedPath, bool i
sDirectory); | 86 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCall
back*, ExecutionContext*, DOMFileSystemBase*, const String& expectedPath, bool i
sDirectory); |
87 virtual void didSucceed() override; | 87 void didSucceed() override; |
88 | 88 |
89 private: | 89 private: |
90 EntryCallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*, DOMFileSys
temBase*, const String& expectedPath, bool isDirectory); | 90 EntryCallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*, DOMFileSys
temBase*, const String& expectedPath, bool isDirectory); |
91 Persistent<EntryCallback> m_successCallback; | 91 Persistent<EntryCallback> m_successCallback; |
92 String m_expectedPath; | 92 String m_expectedPath; |
93 bool m_isDirectory; | 93 bool m_isDirectory; |
94 }; | 94 }; |
95 | 95 |
96 class EntriesCallbacks final : public FileSystemCallbacksBase { | 96 class EntriesCallbacks final : public FileSystemCallbacksBase { |
97 public: | 97 public: |
98 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntriesCallback*, ErrorCa
llback*, ExecutionContext*, DirectoryReaderBase*, const String& basePath); | 98 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntriesCallback*, ErrorCa
llback*, ExecutionContext*, DirectoryReaderBase*, const String& basePath); |
99 virtual void didReadDirectoryEntry(const String& name, bool isDirectory) ove
rride; | 99 void didReadDirectoryEntry(const String& name, bool isDirectory) override; |
100 virtual void didReadDirectoryEntries(bool hasMore) override; | 100 void didReadDirectoryEntries(bool hasMore) override; |
101 | 101 |
102 private: | 102 private: |
103 EntriesCallbacks(EntriesCallback*, ErrorCallback*, ExecutionContext*, Direct
oryReaderBase*, const String& basePath); | 103 EntriesCallbacks(EntriesCallback*, ErrorCallback*, ExecutionContext*, Direct
oryReaderBase*, const String& basePath); |
104 Persistent<EntriesCallback> m_successCallback; | 104 Persistent<EntriesCallback> m_successCallback; |
105 Persistent<DirectoryReaderBase> m_directoryReader; | 105 Persistent<DirectoryReaderBase> m_directoryReader; |
106 String m_basePath; | 106 String m_basePath; |
107 PersistentHeapVector<Member<Entry>> m_entries; | 107 PersistentHeapVector<Member<Entry>> m_entries; |
108 }; | 108 }; |
109 | 109 |
110 class FileSystemCallbacks final : public FileSystemCallbacksBase { | 110 class FileSystemCallbacks final : public FileSystemCallbacksBase { |
111 public: | 111 public: |
112 static PassOwnPtr<AsyncFileSystemCallbacks> create(FileSystemCallback*, Erro
rCallback*, ExecutionContext*, FileSystemType); | 112 static PassOwnPtr<AsyncFileSystemCallbacks> create(FileSystemCallback*, Erro
rCallback*, ExecutionContext*, FileSystemType); |
113 virtual void didOpenFileSystem(const String& name, const KURL& rootURL) over
ride; | 113 void didOpenFileSystem(const String& name, const KURL& rootURL) override; |
114 | 114 |
115 private: | 115 private: |
116 FileSystemCallbacks(FileSystemCallback*, ErrorCallback*, ExecutionContext*,
FileSystemType); | 116 FileSystemCallbacks(FileSystemCallback*, ErrorCallback*, ExecutionContext*,
FileSystemType); |
117 Persistent<FileSystemCallback> m_successCallback; | 117 Persistent<FileSystemCallback> m_successCallback; |
118 FileSystemType m_type; | 118 FileSystemType m_type; |
119 }; | 119 }; |
120 | 120 |
121 class ResolveURICallbacks final : public FileSystemCallbacksBase { | 121 class ResolveURICallbacks final : public FileSystemCallbacksBase { |
122 public: | 122 public: |
123 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCall
back*, ExecutionContext*); | 123 static PassOwnPtr<AsyncFileSystemCallbacks> create(EntryCallback*, ErrorCall
back*, ExecutionContext*); |
124 virtual void didResolveURL(const String& name, const KURL& rootURL, FileSyst
emType, const String& filePath, bool isDirectry) override; | 124 void didResolveURL(const String& name, const KURL& rootURL, FileSystemType,
const String& filePath, bool isDirectry) override; |
125 | 125 |
126 private: | 126 private: |
127 ResolveURICallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*); | 127 ResolveURICallbacks(EntryCallback*, ErrorCallback*, ExecutionContext*); |
128 Persistent<EntryCallback> m_successCallback; | 128 Persistent<EntryCallback> m_successCallback; |
129 }; | 129 }; |
130 | 130 |
131 class MetadataCallbacks final : public FileSystemCallbacksBase { | 131 class MetadataCallbacks final : public FileSystemCallbacksBase { |
132 public: | 132 public: |
133 static PassOwnPtr<AsyncFileSystemCallbacks> create(MetadataCallback*, ErrorC
allback*, ExecutionContext*, DOMFileSystemBase*); | 133 static PassOwnPtr<AsyncFileSystemCallbacks> create(MetadataCallback*, ErrorC
allback*, ExecutionContext*, DOMFileSystemBase*); |
134 virtual void didReadMetadata(const FileMetadata&) override; | 134 void didReadMetadata(const FileMetadata&) override; |
135 | 135 |
136 private: | 136 private: |
137 MetadataCallbacks(MetadataCallback*, ErrorCallback*, ExecutionContext*, DOMF
ileSystemBase*); | 137 MetadataCallbacks(MetadataCallback*, ErrorCallback*, ExecutionContext*, DOMF
ileSystemBase*); |
138 Persistent<MetadataCallback> m_successCallback; | 138 Persistent<MetadataCallback> m_successCallback; |
139 }; | 139 }; |
140 | 140 |
141 class FileWriterBaseCallbacks final : public FileSystemCallbacksBase { | 141 class FileWriterBaseCallbacks final : public FileSystemCallbacksBase { |
142 public: | 142 public: |
143 static PassOwnPtr<AsyncFileSystemCallbacks> create(FileWriterBase*, FileWrit
erBaseCallback*, ErrorCallback*, ExecutionContext*); | 143 static PassOwnPtr<AsyncFileSystemCallbacks> create(FileWriterBase*, FileWrit
erBaseCallback*, ErrorCallback*, ExecutionContext*); |
144 virtual void didCreateFileWriter(PassOwnPtr<WebFileWriter>, long long length
) override; | 144 void didCreateFileWriter(PassOwnPtr<WebFileWriter>, long long length) overri
de; |
145 | 145 |
146 private: | 146 private: |
147 FileWriterBaseCallbacks(FileWriterBase*, FileWriterBaseCallback*, ErrorCallb
ack*, ExecutionContext*); | 147 FileWriterBaseCallbacks(FileWriterBase*, FileWriterBaseCallback*, ErrorCallb
ack*, ExecutionContext*); |
148 Persistent<FileWriterBase> m_fileWriter; | 148 Persistent<FileWriterBase> m_fileWriter; |
149 Persistent<FileWriterBaseCallback> m_successCallback; | 149 Persistent<FileWriterBaseCallback> m_successCallback; |
150 }; | 150 }; |
151 | 151 |
152 class SnapshotFileCallback final : public FileSystemCallbacksBase { | 152 class SnapshotFileCallback final : public FileSystemCallbacksBase { |
153 public: | 153 public: |
154 static PassOwnPtr<AsyncFileSystemCallbacks> create(DOMFileSystemBase*, const
String& name, const KURL&, FileCallback*, ErrorCallback*, ExecutionContext*); | 154 static PassOwnPtr<AsyncFileSystemCallbacks> create(DOMFileSystemBase*, const
String& name, const KURL&, FileCallback*, ErrorCallback*, ExecutionContext*); |
155 virtual void didCreateSnapshotFile(const FileMetadata&, PassRefPtr<BlobDataH
andle> snapshot); | 155 virtual void didCreateSnapshotFile(const FileMetadata&, PassRefPtr<BlobDataH
andle> snapshot); |
156 | 156 |
157 private: | 157 private: |
158 SnapshotFileCallback(DOMFileSystemBase*, const String& name, const KURL&, Fi
leCallback*, ErrorCallback*, ExecutionContext*); | 158 SnapshotFileCallback(DOMFileSystemBase*, const String& name, const KURL&, Fi
leCallback*, ErrorCallback*, ExecutionContext*); |
159 String m_name; | 159 String m_name; |
160 KURL m_url; | 160 KURL m_url; |
161 Persistent<FileCallback> m_successCallback; | 161 Persistent<FileCallback> m_successCallback; |
162 }; | 162 }; |
163 | 163 |
164 class VoidCallbacks final : public FileSystemCallbacksBase { | 164 class VoidCallbacks final : public FileSystemCallbacksBase { |
165 public: | 165 public: |
166 static PassOwnPtr<AsyncFileSystemCallbacks> create(VoidCallback*, ErrorCallb
ack*, ExecutionContext*, DOMFileSystemBase*); | 166 static PassOwnPtr<AsyncFileSystemCallbacks> create(VoidCallback*, ErrorCallb
ack*, ExecutionContext*, DOMFileSystemBase*); |
167 virtual void didSucceed() override; | 167 void didSucceed() override; |
168 | 168 |
169 private: | 169 private: |
170 VoidCallbacks(VoidCallback*, ErrorCallback*, ExecutionContext*, DOMFileSyste
mBase*); | 170 VoidCallbacks(VoidCallback*, ErrorCallback*, ExecutionContext*, DOMFileSyste
mBase*); |
171 Persistent<VoidCallback> m_successCallback; | 171 Persistent<VoidCallback> m_successCallback; |
172 }; | 172 }; |
173 | 173 |
174 } // namespace blink | 174 } // namespace blink |
175 | 175 |
176 #endif // FileSystemCallbacks_h | 176 #endif // FileSystemCallbacks_h |
OLD | NEW |