Chromium Code Reviews| Index: content/child/fileapi/file_system_dispatcher.cc |
| diff --git a/content/child/fileapi/file_system_dispatcher.cc b/content/child/fileapi/file_system_dispatcher.cc |
| index 5c7d7c94e1807b89fc0a13622e1d32e0e326816e..87dfb00d6c4e17e41de924bd2c3ed1de51e4d7bb 100644 |
| --- a/content/child/fileapi/file_system_dispatcher.cc |
| +++ b/content/child/fileapi/file_system_dispatcher.cc |
| @@ -6,12 +6,32 @@ |
| #include "base/callback.h" |
| #include "base/file_util.h" |
| +#include "base/message_loop/message_loop_proxy.h" |
| #include "base/process.h" |
| #include "content/child/child_thread.h" |
| #include "content/common/fileapi/file_system_messages.h" |
| namespace content { |
| +namespace { |
| + |
| +void DidReceiveSnapshotFile( |
| + int request_id, |
| + base::MessageLoopProxy* message_loop) { |
|
michaeln
2013/07/24 00:54:08
You might be able to use the ThreadSafeSender here
kinuko
2013/07/24 09:29:09
Done.
|
| + if (!message_loop->RunsTasksOnCurrentThread()) { |
| + message_loop->PostTask(FROM_HERE, |
| + base::Bind(&DidReceiveSnapshotFile, request_id, |
| + make_scoped_refptr(message_loop))); |
| + return; |
| + } |
| + if (ChildThread::current()) { |
| + ChildThread::current()->Send( |
| + new FileSystemHostMsg_DidReceiveSnapshotFile(request_id)); |
| + } |
| +} |
| + |
| +} // namespace |
| + |
| class FileSystemDispatcher::CallbackDispatcher { |
| public: |
| typedef CallbackDispatcher self; |
| @@ -88,8 +108,9 @@ class FileSystemDispatcher::CallbackDispatcher { |
| void DidCreateSnapshotFile( |
| const base::PlatformFileInfo& file_info, |
| - const base::FilePath& platform_path) { |
| - snapshot_callback_.Run(file_info, platform_path); |
| + const base::FilePath& platform_path, |
| + const base::Closure& did_receive_snapshot) { |
| + snapshot_callback_.Run(file_info, platform_path, did_receive_snapshot); |
|
michaeln
2013/07/24 01:38:58
What method/function is snapshot_callback_ this wi
kinuko
2013/07/24 09:29:09
I thought returning a closure is clearer about wha
|
| } |
| void DidReadDirectory( |
| @@ -363,10 +384,11 @@ void FileSystemDispatcher::OnDidCreateSnapshotFile( |
| const base::FilePath& platform_path) { |
| CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); |
| DCHECK(dispatcher); |
| - dispatcher->DidCreateSnapshotFile(file_info, platform_path); |
| + dispatcher->DidCreateSnapshotFile( |
| + file_info, platform_path, |
| + base::Bind(&DidReceiveSnapshotFile, request_id, |
| + base::MessageLoopProxy::current())); |
| dispatchers_.Remove(request_id); |
| - ChildThread::current()->Send( |
| - new FileSystemHostMsg_DidReceiveSnapshotFile(request_id)); |
| } |
| void FileSystemDispatcher::OnDidReadDirectory( |