OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 requestFileSystemAccessInternal( | 98 requestFileSystemAccessInternal( |
99 context, | 99 context, |
100 WTF::bind(&LocalFileSystem::fileSystemAllowedInternal, | 100 WTF::bind(&LocalFileSystem::fileSystemAllowedInternal, |
101 wrapCrossThreadPersistent(this), wrapPersistent(context), type, | 101 wrapCrossThreadPersistent(this), wrapPersistent(context), type, |
102 wrapPersistent(wrapper)), | 102 wrapPersistent(wrapper)), |
103 WTF::bind(&LocalFileSystem::fileSystemNotAllowedInternal, | 103 WTF::bind(&LocalFileSystem::fileSystemNotAllowedInternal, |
104 wrapCrossThreadPersistent(this), wrapPersistent(context), | 104 wrapCrossThreadPersistent(this), wrapPersistent(context), |
105 wrapPersistent(wrapper))); | 105 wrapPersistent(wrapper))); |
106 } | 106 } |
107 | 107 |
108 void LocalFileSystem::deleteFileSystem( | |
109 ExecutionContext* context, | |
110 FileSystemType type, | |
111 std::unique_ptr<AsyncFileSystemCallbacks> callbacks) { | |
112 ASSERT(context); | |
113 SECURITY_DCHECK(context->isDocument()); | |
114 | |
115 CallbackWrapper* wrapper = new CallbackWrapper(std::move(callbacks)); | |
116 requestFileSystemAccessInternal( | |
117 context, | |
118 WTF::bind(&LocalFileSystem::deleteFileSystemInternal, | |
119 wrapCrossThreadPersistent(this), wrapPersistent(context), type, | |
120 wrapPersistent(wrapper)), | |
121 WTF::bind(&LocalFileSystem::fileSystemNotAllowedInternal, | |
122 wrapCrossThreadPersistent(this), wrapPersistent(context), | |
123 wrapPersistent(wrapper))); | |
124 } | |
125 | |
126 WebFileSystem* LocalFileSystem::getFileSystem() const { | 108 WebFileSystem* LocalFileSystem::getFileSystem() const { |
127 Platform* platform = Platform::current(); | 109 Platform* platform = Platform::current(); |
128 if (!platform) | 110 if (!platform) |
129 return nullptr; | 111 return nullptr; |
130 | 112 |
131 return platform->fileSystem(); | 113 return platform->fileSystem(); |
132 } | 114 } |
133 | 115 |
134 void LocalFileSystem::requestFileSystemAccessInternal( | 116 void LocalFileSystem::requestFileSystemAccessInternal( |
135 ExecutionContext* context, | 117 ExecutionContext* context, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 const KURL& fileSystemURL, | 169 const KURL& fileSystemURL, |
188 CallbackWrapper* callbacks) { | 170 CallbackWrapper* callbacks) { |
189 WebFileSystem* fileSystem = getFileSystem(); | 171 WebFileSystem* fileSystem = getFileSystem(); |
190 if (!fileSystem) { | 172 if (!fileSystem) { |
191 fileSystemNotAvailable(context, callbacks); | 173 fileSystemNotAvailable(context, callbacks); |
192 return; | 174 return; |
193 } | 175 } |
194 fileSystem->resolveURL(fileSystemURL, callbacks->release()); | 176 fileSystem->resolveURL(fileSystemURL, callbacks->release()); |
195 } | 177 } |
196 | 178 |
197 void LocalFileSystem::deleteFileSystemInternal(ExecutionContext* context, | |
198 FileSystemType type, | |
199 CallbackWrapper* callbacks) { | |
200 WebFileSystem* fileSystem = getFileSystem(); | |
201 if (!fileSystem) { | |
202 fileSystemNotAvailable(context, callbacks); | |
203 return; | |
204 } | |
205 KURL storagePartition = | |
206 KURL(KURL(), context->getSecurityOrigin()->toString()); | |
207 fileSystem->deleteFileSystem(storagePartition, | |
208 static_cast<WebFileSystemType>(type), | |
209 callbacks->release()); | |
210 } | |
211 | |
212 LocalFileSystem::LocalFileSystem(LocalFrame& frame, | 179 LocalFileSystem::LocalFileSystem(LocalFrame& frame, |
213 std::unique_ptr<FileSystemClient> client) | 180 std::unique_ptr<FileSystemClient> client) |
214 : Supplement<LocalFrame>(frame), m_client(std::move(client)) {} | 181 : Supplement<LocalFrame>(frame), m_client(std::move(client)) {} |
215 | 182 |
216 LocalFileSystem::LocalFileSystem(WorkerClients& workerClients, | 183 LocalFileSystem::LocalFileSystem(WorkerClients& workerClients, |
217 std::unique_ptr<FileSystemClient> client) | 184 std::unique_ptr<FileSystemClient> client) |
218 : Supplement<WorkerClients>(workerClients), m_client(std::move(client)) {} | 185 : Supplement<WorkerClients>(workerClients), m_client(std::move(client)) {} |
219 | 186 |
220 DEFINE_TRACE(LocalFileSystem) { | 187 DEFINE_TRACE(LocalFileSystem) { |
221 Supplement<LocalFrame>::trace(visitor); | 188 Supplement<LocalFrame>::trace(visitor); |
(...skipping 28 matching lines...) Expand all Loading... |
250 } | 217 } |
251 | 218 |
252 void provideLocalFileSystemToWorker(WorkerClients* workerClients, | 219 void provideLocalFileSystemToWorker(WorkerClients* workerClients, |
253 std::unique_ptr<FileSystemClient> client) { | 220 std::unique_ptr<FileSystemClient> client) { |
254 Supplement<WorkerClients>::provideTo( | 221 Supplement<WorkerClients>::provideTo( |
255 *workerClients, LocalFileSystem::supplementName(), | 222 *workerClients, LocalFileSystem::supplementName(), |
256 new LocalFileSystem(*workerClients, std::move(client))); | 223 new LocalFileSystem(*workerClients, std::move(client))); |
257 } | 224 } |
258 | 225 |
259 } // namespace blink | 226 } // namespace blink |
OLD | NEW |