| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/webfilesystem_impl.h" | 5 #include "content/child/fileapi/webfilesystem_impl.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" | 
| 9 #include "base/logging.h" | 9 #include "base/logging.h" | 
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" | 
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" | 
| 12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" | 
| 13 #include "base/threading/thread_local.h" | 13 #include "base/threading/thread_local.h" | 
|  | 14 #include "content/child/blink_glue.h" | 
| 14 #include "content/child/child_thread.h" | 15 #include "content/child/child_thread.h" | 
| 15 #include "content/child/fileapi/file_system_dispatcher.h" | 16 #include "content/child/fileapi/file_system_dispatcher.h" | 
| 16 #include "content/child/fileapi/webfilewriter_impl.h" | 17 #include "content/child/fileapi/webfilewriter_impl.h" | 
| 17 #include "content/common/fileapi/file_system_messages.h" | 18 #include "content/common/fileapi/file_system_messages.h" | 
| 18 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 19 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 
| 19 #include "third_party/WebKit/public/platform/WebFileSystemCallbacks.h" | 20 #include "third_party/WebKit/public/platform/WebFileSystemCallbacks.h" | 
| 20 #include "third_party/WebKit/public/platform/WebString.h" | 21 #include "third_party/WebKit/public/platform/WebString.h" | 
| 21 #include "third_party/WebKit/public/platform/WebURL.h" | 22 #include "third_party/WebKit/public/platform/WebURL.h" | 
| 22 #include "url/gurl.h" | 23 #include "url/gurl.h" | 
| 23 #include "webkit/child/worker_task_runner.h" | 24 #include "webkit/child/worker_task_runner.h" | 
| 24 #include "webkit/common/fileapi/directory_entry.h" | 25 #include "webkit/common/fileapi/directory_entry.h" | 
| 25 #include "webkit/common/fileapi/file_system_util.h" | 26 #include "webkit/common/fileapi/file_system_util.h" | 
| 26 #include "webkit/glue/webkit_glue.h" |  | 
| 27 | 27 | 
| 28 using blink::WebFileInfo; | 28 using blink::WebFileInfo; | 
| 29 using blink::WebFileSystemCallbacks; | 29 using blink::WebFileSystemCallbacks; | 
| 30 using blink::WebFileSystemEntry; | 30 using blink::WebFileSystemEntry; | 
| 31 using blink::WebString; | 31 using blink::WebString; | 
| 32 using blink::WebURL; | 32 using blink::WebURL; | 
| 33 using blink::WebVector; | 33 using blink::WebVector; | 
| 34 using webkit_glue::WorkerTaskRunner; | 34 using webkit_glue::WorkerTaskRunner; | 
| 35 | 35 | 
| 36 namespace content { | 36 namespace content { | 
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 181         thread_id, callbacks_id, waitable_results, | 181         thread_id, callbacks_id, waitable_results, | 
| 182         &WebFileSystemCallbacks::didFail, | 182         &WebFileSystemCallbacks::didFail, | 
| 183         MakeTuple(fileapi::FileErrorToWebFileError(error))); | 183         MakeTuple(fileapi::FileErrorToWebFileError(error))); | 
| 184   } | 184   } | 
| 185 } | 185 } | 
| 186 | 186 | 
| 187 void ReadMetadataCallbackAdapter(int thread_id, int callbacks_id, | 187 void ReadMetadataCallbackAdapter(int thread_id, int callbacks_id, | 
| 188                                  WaitableCallbackResults* waitable_results, | 188                                  WaitableCallbackResults* waitable_results, | 
| 189                                  const base::File::Info& file_info) { | 189                                  const base::File::Info& file_info) { | 
| 190   WebFileInfo web_file_info; | 190   WebFileInfo web_file_info; | 
| 191   webkit_glue::FileInfoToWebFileInfo(file_info, &web_file_info); | 191   FileInfoToWebFileInfo(file_info, &web_file_info); | 
| 192   CallbackFileSystemCallbacks( | 192   CallbackFileSystemCallbacks( | 
| 193       thread_id, callbacks_id, waitable_results, | 193       thread_id, callbacks_id, waitable_results, | 
| 194       &WebFileSystemCallbacks::didReadMetadata, | 194       &WebFileSystemCallbacks::didReadMetadata, | 
| 195       MakeTuple(web_file_info)); | 195       MakeTuple(web_file_info)); | 
| 196 } | 196 } | 
| 197 | 197 | 
| 198 void ReadDirectoryCallbackAdapater( | 198 void ReadDirectoryCallbackAdapater( | 
| 199     int thread_id, int callbacks_id, WaitableCallbackResults* waitable_results, | 199     int thread_id, int callbacks_id, WaitableCallbackResults* waitable_results, | 
| 200     const std::vector<fileapi::DirectoryEntry>& entries, | 200     const std::vector<fileapi::DirectoryEntry>& entries, | 
| 201     bool has_more) { | 201     bool has_more) { | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 258     int request_id) { | 258     int request_id) { | 
| 259   WebFileSystemImpl* filesystem = | 259   WebFileSystemImpl* filesystem = | 
| 260       WebFileSystemImpl::ThreadSpecificInstance(NULL); | 260       WebFileSystemImpl::ThreadSpecificInstance(NULL); | 
| 261   if (!filesystem) | 261   if (!filesystem) | 
| 262     return; | 262     return; | 
| 263 | 263 | 
| 264   WebFileSystemCallbacks callbacks = | 264   WebFileSystemCallbacks callbacks = | 
| 265       filesystem->GetAndUnregisterCallbacks(callbacks_id); | 265       filesystem->GetAndUnregisterCallbacks(callbacks_id); | 
| 266 | 266 | 
| 267   WebFileInfo web_file_info; | 267   WebFileInfo web_file_info; | 
| 268   webkit_glue::FileInfoToWebFileInfo(file_info, &web_file_info); | 268   FileInfoToWebFileInfo(file_info, &web_file_info); | 
| 269   web_file_info.platformPath = platform_path.AsUTF16Unsafe(); | 269   web_file_info.platformPath = platform_path.AsUTF16Unsafe(); | 
| 270   callbacks.didCreateSnapshotFile(web_file_info); | 270   callbacks.didCreateSnapshotFile(web_file_info); | 
| 271 | 271 | 
| 272   // TODO(michaeln,kinuko): Use ThreadSafeSender when Blob becomes | 272   // TODO(michaeln,kinuko): Use ThreadSafeSender when Blob becomes | 
| 273   // non-bridge model. | 273   // non-bridge model. | 
| 274   main_thread_loop->PostTask( | 274   main_thread_loop->PostTask( | 
| 275       FROM_HERE, base::Bind(&DidReceiveSnapshotFile, request_id)); | 275       FROM_HERE, base::Bind(&DidReceiveSnapshotFile, request_id)); | 
| 276 } | 276 } | 
| 277 | 277 | 
| 278 void CreateSnapshotFileCallbackAdapter( | 278 void CreateSnapshotFileCallbackAdapter( | 
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 605     int callbacks_id) { | 605     int callbacks_id) { | 
| 606   DCHECK(CalledOnValidThread()); | 606   DCHECK(CalledOnValidThread()); | 
| 607   CallbacksMap::iterator found = callbacks_.find(callbacks_id); | 607   CallbacksMap::iterator found = callbacks_.find(callbacks_id); | 
| 608   DCHECK(found != callbacks_.end()); | 608   DCHECK(found != callbacks_.end()); | 
| 609   WebFileSystemCallbacks callbacks = found->second; | 609   WebFileSystemCallbacks callbacks = found->second; | 
| 610   callbacks_.erase(found); | 610   callbacks_.erase(found); | 
| 611   return callbacks; | 611   return callbacks; | 
| 612 } | 612 } | 
| 613 | 613 | 
| 614 }  // namespace content | 614 }  // namespace content | 
| OLD | NEW | 
|---|