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/child/fileapi/file_system_dispatcher.h" | 5 #include "content/child/fileapi/file_system_dispatcher.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop/message_loop_proxy.h" | |
10 #include "base/process/process.h" | 9 #include "base/process/process.h" |
11 #include "content/child/child_thread.h" | 10 #include "content/child/child_thread.h" |
12 #include "content/common/fileapi/file_system_messages.h" | 11 #include "content/common/fileapi/file_system_messages.h" |
13 | 12 |
14 namespace content { | 13 namespace content { |
15 | 14 |
16 class FileSystemDispatcher::CallbackDispatcher { | 15 class FileSystemDispatcher::CallbackDispatcher { |
17 public: | 16 public: |
18 typedef CallbackDispatcher self; | 17 typedef CallbackDispatcher self; |
19 typedef FileSystemDispatcher::StatusCallback StatusCallback; | 18 typedef FileSystemDispatcher::StatusCallback StatusCallback; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 error_callback_.Run(error_code); | 81 error_callback_.Run(error_code); |
83 } | 82 } |
84 | 83 |
85 void DidReadMetadata( | 84 void DidReadMetadata( |
86 const base::PlatformFileInfo& file_info) { | 85 const base::PlatformFileInfo& file_info) { |
87 metadata_callback_.Run(file_info); | 86 metadata_callback_.Run(file_info); |
88 } | 87 } |
89 | 88 |
90 void DidCreateSnapshotFile( | 89 void DidCreateSnapshotFile( |
91 const base::PlatformFileInfo& file_info, | 90 const base::PlatformFileInfo& file_info, |
92 const base::FilePath& platform_path, | 91 const base::FilePath& platform_path) { |
93 int request_id) { | 92 snapshot_callback_.Run(file_info, platform_path); |
94 snapshot_callback_.Run(file_info, platform_path, request_id); | |
95 } | 93 } |
96 | 94 |
97 void DidReadDirectory( | 95 void DidReadDirectory( |
98 const std::vector<fileapi::DirectoryEntry>& entries, | 96 const std::vector<fileapi::DirectoryEntry>& entries, |
99 bool has_more) { | 97 bool has_more) { |
100 directory_callback_.Run(entries, has_more); | 98 directory_callback_.Run(entries, has_more); |
101 } | 99 } |
102 | 100 |
103 void DidOpenFileSystem(const std::string& name, | 101 void DidOpenFileSystem(const std::string& name, |
104 const GURL& root) { | 102 const GURL& root) { |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 DCHECK(dispatcher); | 356 DCHECK(dispatcher); |
359 dispatcher->DidReadMetadata(file_info); | 357 dispatcher->DidReadMetadata(file_info); |
360 dispatchers_.Remove(request_id); | 358 dispatchers_.Remove(request_id); |
361 } | 359 } |
362 | 360 |
363 void FileSystemDispatcher::OnDidCreateSnapshotFile( | 361 void FileSystemDispatcher::OnDidCreateSnapshotFile( |
364 int request_id, const base::PlatformFileInfo& file_info, | 362 int request_id, const base::PlatformFileInfo& file_info, |
365 const base::FilePath& platform_path) { | 363 const base::FilePath& platform_path) { |
366 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); | 364 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); |
367 DCHECK(dispatcher); | 365 DCHECK(dispatcher); |
368 dispatcher->DidCreateSnapshotFile(file_info, platform_path, request_id); | 366 dispatcher->DidCreateSnapshotFile(file_info, platform_path); |
369 dispatchers_.Remove(request_id); | 367 dispatchers_.Remove(request_id); |
| 368 ChildThread::current()->Send( |
| 369 new FileSystemHostMsg_DidReceiveSnapshotFile(request_id)); |
370 } | 370 } |
371 | 371 |
372 void FileSystemDispatcher::OnDidReadDirectory( | 372 void FileSystemDispatcher::OnDidReadDirectory( |
373 int request_id, | 373 int request_id, |
374 const std::vector<fileapi::DirectoryEntry>& entries, | 374 const std::vector<fileapi::DirectoryEntry>& entries, |
375 bool has_more) { | 375 bool has_more) { |
376 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); | 376 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); |
377 DCHECK(dispatcher); | 377 DCHECK(dispatcher); |
378 dispatcher->DidReadDirectory(entries, has_more); | 378 dispatcher->DidReadDirectory(entries, has_more); |
379 dispatchers_.Remove(request_id); | 379 dispatchers_.Remove(request_id); |
(...skipping 23 matching lines...) Expand all Loading... |
403 quota::QuotaLimitType quota_policy) { | 403 quota::QuotaLimitType quota_policy) { |
404 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); | 404 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); |
405 DCHECK(dispatcher); | 405 DCHECK(dispatcher); |
406 dispatcher->DidOpenFile(IPC::PlatformFileForTransitToPlatformFile(file), | 406 dispatcher->DidOpenFile(IPC::PlatformFileForTransitToPlatformFile(file), |
407 file_open_id, | 407 file_open_id, |
408 quota_policy); | 408 quota_policy); |
409 dispatchers_.Remove(request_id); | 409 dispatchers_.Remove(request_id); |
410 } | 410 } |
411 | 411 |
412 } // namespace content | 412 } // namespace content |
OLD | NEW |