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 "webkit/fileapi/local_file_system_operation.h" | 5 #include "webkit/fileapi/local_file_system_operation.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "webkit/fileapi/file_system_task_runners.h" | 21 #include "webkit/fileapi/file_system_task_runners.h" |
22 #include "webkit/fileapi/file_system_types.h" | 22 #include "webkit/fileapi/file_system_types.h" |
23 #include "webkit/fileapi/file_system_url.h" | 23 #include "webkit/fileapi/file_system_url.h" |
24 #include "webkit/fileapi/file_system_util.h" | 24 #include "webkit/fileapi/file_system_util.h" |
25 #include "webkit/fileapi/file_writer_delegate.h" | 25 #include "webkit/fileapi/file_writer_delegate.h" |
26 #include "webkit/fileapi/remove_operation_delegate.h" | 26 #include "webkit/fileapi/remove_operation_delegate.h" |
27 #include "webkit/fileapi/sandbox_file_stream_writer.h" | 27 #include "webkit/fileapi/sandbox_file_stream_writer.h" |
28 #include "webkit/quota/quota_manager.h" | 28 #include "webkit/quota/quota_manager.h" |
29 #include "webkit/quota/quota_types.h" | 29 #include "webkit/quota/quota_types.h" |
30 | 30 |
| 31 using webkit_blob::ScopedFile; |
31 using webkit_blob::ShareableFileReference; | 32 using webkit_blob::ShareableFileReference; |
32 | 33 |
33 namespace fileapi { | 34 namespace fileapi { |
34 | 35 |
35 LocalFileSystemOperation::LocalFileSystemOperation( | 36 LocalFileSystemOperation::LocalFileSystemOperation( |
36 FileSystemContext* file_system_context, | 37 FileSystemContext* file_system_context, |
37 scoped_ptr<FileSystemOperationContext> operation_context) | 38 scoped_ptr<FileSystemOperationContext> operation_context) |
38 : file_system_context_(file_system_context), | 39 : file_system_context_(file_system_context), |
39 operation_context_(operation_context.Pass()), | 40 operation_context_(operation_context.Pass()), |
40 async_file_util_(NULL), | 41 async_file_util_(NULL), |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 if (rv == base::PLATFORM_FILE_OK) | 821 if (rv == base::PLATFORM_FILE_OK) |
821 CHECK_NE(base::kNullProcessHandle, peer_handle_); | 822 CHECK_NE(base::kNullProcessHandle, peer_handle_); |
822 callback.Run(rv, file.ReleaseValue(), peer_handle_); | 823 callback.Run(rv, file.ReleaseValue(), peer_handle_); |
823 } | 824 } |
824 | 825 |
825 void LocalFileSystemOperation::DidCreateSnapshotFile( | 826 void LocalFileSystemOperation::DidCreateSnapshotFile( |
826 const SnapshotFileCallback& callback, | 827 const SnapshotFileCallback& callback, |
827 base::PlatformFileError result, | 828 base::PlatformFileError result, |
828 const base::PlatformFileInfo& file_info, | 829 const base::PlatformFileInfo& file_info, |
829 const base::FilePath& platform_path, | 830 const base::FilePath& platform_path, |
830 SnapshotFilePolicy snapshot_policy) { | 831 const scoped_refptr<ShareableFileReference>& file_ref) { |
831 scoped_refptr<ShareableFileReference> file_ref; | |
832 if (result == base::PLATFORM_FILE_OK && | |
833 snapshot_policy == kSnapshotFileTemporary) { | |
834 file_ref = ShareableFileReference::GetOrCreate( | |
835 platform_path, ShareableFileReference::DELETE_ON_FINAL_RELEASE, | |
836 file_system_context()->task_runners()->file_task_runner()); | |
837 } | |
838 callback.Run(result, file_info, platform_path, file_ref); | 832 callback.Run(result, file_info, platform_path, file_ref); |
839 } | 833 } |
840 | 834 |
841 base::PlatformFileError LocalFileSystemOperation::SetUp( | 835 base::PlatformFileError LocalFileSystemOperation::SetUp( |
842 const FileSystemURL& url, | 836 const FileSystemURL& url, |
843 OperationMode mode) { | 837 OperationMode mode) { |
844 DCHECK(url.is_valid()); | 838 DCHECK(url.is_valid()); |
845 | 839 |
846 async_file_util_ = file_system_context()->GetAsyncFileUtil(url.type()); | 840 async_file_util_ = file_system_context()->GetAsyncFileUtil(url.type()); |
847 if (!async_file_util_) | 841 if (!async_file_util_) |
(...skipping 21 matching lines...) Expand all Loading... |
869 } | 863 } |
870 | 864 |
871 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { | 865 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { |
872 if (pending_operation_ != kOperationNone) | 866 if (pending_operation_ != kOperationNone) |
873 return false; | 867 return false; |
874 pending_operation_ = type; | 868 pending_operation_ = type; |
875 return true; | 869 return true; |
876 } | 870 } |
877 | 871 |
878 } // namespace fileapi | 872 } // namespace fileapi |
OLD | NEW |