OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/fileapi/file_system_dispatcher.h" | 5 #include "content/common/fileapi/file_system_dispatcher.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/process.h" | 8 #include "base/process.h" |
9 #include "content/common/child_thread.h" | 9 #include "content/common/child_thread.h" |
10 #include "content/common/fileapi/file_system_messages.h" | 10 #include "content/common/fileapi/file_system_messages.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return false; | 178 return false; |
179 } | 179 } |
180 | 180 |
181 if (request_id_out) | 181 if (request_id_out) |
182 *request_id_out = request_id; | 182 *request_id_out = request_id; |
183 return true; | 183 return true; |
184 } | 184 } |
185 | 185 |
186 bool FileSystemDispatcher::Write( | 186 bool FileSystemDispatcher::Write( |
187 const GURL& path, | 187 const GURL& path, |
188 const GURL& blob_url, | 188 const std::string& blob_uuid, |
189 int64 offset, | 189 int64 offset, |
190 int* request_id_out, | 190 int* request_id_out, |
191 fileapi::FileSystemCallbackDispatcher* dispatcher) { | 191 fileapi::FileSystemCallbackDispatcher* dispatcher) { |
192 int request_id = dispatchers_.Add(dispatcher); | 192 int request_id = dispatchers_.Add(dispatcher); |
193 if (!ChildThread::current()->Send( | 193 if (!ChildThread::current()->Send( |
194 new FileSystemHostMsg_Write(request_id, path, blob_url, offset))) { | 194 new FileSystemHostMsg_Write(request_id, path, blob_uuid, offset))) { |
195 dispatchers_.Remove(request_id); // destroys |dispatcher| | 195 dispatchers_.Remove(request_id); // destroys |dispatcher| |
196 return false; | 196 return false; |
197 } | 197 } |
198 | 198 |
199 if (request_id_out) | 199 if (request_id_out) |
200 *request_id_out = request_id; | 200 *request_id_out = request_id; |
201 return true; | 201 return true; |
202 } | 202 } |
203 | 203 |
204 bool FileSystemDispatcher::Cancel( | 204 bool FileSystemDispatcher::Cancel( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 244 |
245 return true; | 245 return true; |
246 } | 246 } |
247 | 247 |
248 bool FileSystemDispatcher::NotifyCloseFile(const GURL& file_path) { | 248 bool FileSystemDispatcher::NotifyCloseFile(const GURL& file_path) { |
249 return ChildThread::current()->Send( | 249 return ChildThread::current()->Send( |
250 new FileSystemHostMsg_NotifyCloseFile(file_path)); | 250 new FileSystemHostMsg_NotifyCloseFile(file_path)); |
251 } | 251 } |
252 | 252 |
253 bool FileSystemDispatcher::CreateSnapshotFile( | 253 bool FileSystemDispatcher::CreateSnapshotFile( |
254 const GURL& blob_url, | |
255 const GURL& file_path, | 254 const GURL& file_path, |
256 fileapi::FileSystemCallbackDispatcher* dispatcher) { | 255 fileapi::FileSystemCallbackDispatcher* dispatcher) { |
257 int request_id = dispatchers_.Add(dispatcher); | 256 int request_id = dispatchers_.Add(dispatcher); |
258 if (!ChildThread::current()->Send( | 257 if (!ChildThread::current()->Send( |
259 new FileSystemHostMsg_CreateSnapshotFile( | 258 new FileSystemHostMsg_CreateSnapshotFile( |
260 request_id, blob_url, file_path))) { | 259 request_id, file_path))) { |
261 dispatchers_.Remove(request_id); // destroys |dispatcher| | 260 dispatchers_.Remove(request_id); // destroys |dispatcher| |
262 return false; | 261 return false; |
263 } | 262 } |
264 return true; | 263 return true; |
265 } | 264 } |
266 | 265 |
267 void FileSystemDispatcher::OnDidOpenFileSystem(int request_id, | 266 void FileSystemDispatcher::OnDidOpenFileSystem(int request_id, |
268 const std::string& name, | 267 const std::string& name, |
269 const GURL& root) { | 268 const GURL& root) { |
270 DCHECK(root.is_valid()); | 269 DCHECK(root.is_valid()); |
(...skipping 15 matching lines...) Expand all Loading... |
286 void FileSystemDispatcher::OnDidReadMetadata( | 285 void FileSystemDispatcher::OnDidReadMetadata( |
287 int request_id, const base::PlatformFileInfo& file_info, | 286 int request_id, const base::PlatformFileInfo& file_info, |
288 const FilePath& platform_path) { | 287 const FilePath& platform_path) { |
289 fileapi::FileSystemCallbackDispatcher* dispatcher = | 288 fileapi::FileSystemCallbackDispatcher* dispatcher = |
290 dispatchers_.Lookup(request_id); | 289 dispatchers_.Lookup(request_id); |
291 DCHECK(dispatcher); | 290 DCHECK(dispatcher); |
292 dispatcher->DidReadMetadata(file_info, platform_path); | 291 dispatcher->DidReadMetadata(file_info, platform_path); |
293 dispatchers_.Remove(request_id); | 292 dispatchers_.Remove(request_id); |
294 } | 293 } |
295 | 294 |
| 295 void FileSystemDispatcher::OnDidCreateSnapshotFile( |
| 296 int request_id, const base::PlatformFileInfo& file_info, |
| 297 const FilePath& platform_path) { |
| 298 fileapi::FileSystemCallbackDispatcher* dispatcher = |
| 299 dispatchers_.Lookup(request_id); |
| 300 DCHECK(dispatcher); |
| 301 dispatcher->DidCreateSnapshotFile(file_info, platform_path); |
| 302 dispatchers_.Remove(request_id); |
| 303 ChildThread::current()->Send( |
| 304 new FileSystemHostMsg_DidReceiveSnapshotFile(request_id)); |
| 305 } |
| 306 |
296 void FileSystemDispatcher::OnDidReadDirectory( | 307 void FileSystemDispatcher::OnDidReadDirectory( |
297 int request_id, | 308 int request_id, |
298 const std::vector<base::FileUtilProxy::Entry>& entries, | 309 const std::vector<base::FileUtilProxy::Entry>& entries, |
299 bool has_more) { | 310 bool has_more) { |
300 fileapi::FileSystemCallbackDispatcher* dispatcher = | 311 fileapi::FileSystemCallbackDispatcher* dispatcher = |
301 dispatchers_.Lookup(request_id); | 312 dispatchers_.Lookup(request_id); |
302 DCHECK(dispatcher); | 313 DCHECK(dispatcher); |
303 dispatcher->DidReadDirectory(entries, has_more); | 314 dispatcher->DidReadDirectory(entries, has_more); |
304 dispatchers_.Remove(request_id); | 315 dispatchers_.Remove(request_id); |
305 } | 316 } |
(...skipping 20 matching lines...) Expand all Loading... |
326 void FileSystemDispatcher::OnDidOpenFile( | 337 void FileSystemDispatcher::OnDidOpenFile( |
327 int request_id, IPC::PlatformFileForTransit file) { | 338 int request_id, IPC::PlatformFileForTransit file) { |
328 fileapi::FileSystemCallbackDispatcher* dispatcher = | 339 fileapi::FileSystemCallbackDispatcher* dispatcher = |
329 dispatchers_.Lookup(request_id); | 340 dispatchers_.Lookup(request_id); |
330 DCHECK(dispatcher); | 341 DCHECK(dispatcher); |
331 dispatcher->DidOpenFile(IPC::PlatformFileForTransitToPlatformFile(file)); | 342 dispatcher->DidOpenFile(IPC::PlatformFileForTransitToPlatformFile(file)); |
332 dispatchers_.Remove(request_id); | 343 dispatchers_.Remove(request_id); |
333 } | 344 } |
334 | 345 |
335 } // namespace content | 346 } // namespace content |
OLD | NEW |