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/sequenced_task_runner.h" | 8 #include "base/sequenced_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" |
11 #include "net/base/escape.h" | 11 #include "net/base/escape.h" |
12 #include "net/url_request/url_request_context.h" | 12 #include "net/url_request/url_request_context.h" |
13 #include "webkit/blob/shareable_file_reference.h" | 13 #include "webkit/blob/shareable_file_reference.h" |
14 #include "webkit/fileapi/file_system_context.h" | 14 #include "webkit/fileapi/file_system_context.h" |
15 #include "webkit/fileapi/file_system_file_util_proxy.h" | 15 #include "webkit/fileapi/file_system_file_util_proxy.h" |
16 #include "webkit/fileapi/file_system_mount_point_provider.h" | 16 #include "webkit/fileapi/file_system_mount_point_provider.h" |
17 #include "webkit/fileapi/file_system_operation_context.h" | 17 #include "webkit/fileapi/file_system_operation_context.h" |
18 #include "webkit/fileapi/file_system_quota_util.h" | 18 #include "webkit/fileapi/file_system_quota_util.h" |
19 #include "webkit/fileapi/file_system_types.h" | 19 #include "webkit/fileapi/file_system_types.h" |
20 #include "webkit/fileapi/file_system_url.h" | 20 #include "webkit/fileapi/file_system_url.h" |
21 #include "webkit/fileapi/file_system_util.h" | 21 #include "webkit/fileapi/file_system_util.h" |
22 #include "webkit/fileapi/file_writer_delegate.h" | 22 #include "webkit/fileapi/file_writer_delegate.h" |
23 #include "webkit/fileapi/sandbox_file_stream_writer.h" | 23 #include "webkit/fileapi/sandbox_file_stream_writer.h" |
24 #include "webkit/quota/quota_manager.h" | 24 #include "webkit/quota/quota_manager.h" |
25 #include "webkit/quota/quota_types.h" | 25 #include "webkit/quota/quota_types.h" |
26 | 26 |
| 27 using webkit_blob::ShareableFileReference; |
| 28 |
27 namespace fileapi { | 29 namespace fileapi { |
28 | 30 |
29 class LocalFileSystemOperation::ScopedQuotaNotifier { | 31 class LocalFileSystemOperation::ScopedQuotaNotifier { |
30 public: | 32 public: |
31 ScopedQuotaNotifier(FileSystemContext* context, | 33 ScopedQuotaNotifier(FileSystemContext* context, |
32 const GURL& origin_url, | 34 const GURL& origin_url, |
33 FileSystemType type); | 35 FileSystemType type); |
34 ~ScopedQuotaNotifier(); | 36 ~ScopedQuotaNotifier(); |
35 | 37 |
36 private: | 38 private: |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 if (rv == base::PLATFORM_FILE_OK) | 671 if (rv == base::PLATFORM_FILE_OK) |
670 CHECK_NE(base::kNullProcessHandle, peer_handle_); | 672 CHECK_NE(base::kNullProcessHandle, peer_handle_); |
671 callback.Run(rv, file.ReleaseValue(), peer_handle_); | 673 callback.Run(rv, file.ReleaseValue(), peer_handle_); |
672 } | 674 } |
673 | 675 |
674 void LocalFileSystemOperation::DidCreateSnapshotFile( | 676 void LocalFileSystemOperation::DidCreateSnapshotFile( |
675 const SnapshotFileCallback& callback, | 677 const SnapshotFileCallback& callback, |
676 base::PlatformFileError result, | 678 base::PlatformFileError result, |
677 const base::PlatformFileInfo& file_info, | 679 const base::PlatformFileInfo& file_info, |
678 const FilePath& platform_path, | 680 const FilePath& platform_path, |
679 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { | 681 FileSystemFileUtil::SnapshotFilePolicy snapshot_policy) { |
| 682 scoped_refptr<ShareableFileReference> file_ref; |
| 683 if (result == base::PLATFORM_FILE_OK && |
| 684 snapshot_policy == FileSystemFileUtil::kSnapshotFileTemporary) { |
| 685 file_ref = ShareableFileReference::GetOrCreate( |
| 686 platform_path, ShareableFileReference::DELETE_ON_FINAL_RELEASE, |
| 687 file_system_context()->file_task_runner()); |
| 688 } |
680 callback.Run(result, file_info, platform_path, file_ref); | 689 callback.Run(result, file_info, platform_path, file_ref); |
681 } | 690 } |
682 | 691 |
683 base::PlatformFileError LocalFileSystemOperation::SetUp( | 692 base::PlatformFileError LocalFileSystemOperation::SetUp( |
684 const FileSystemURL& url, | 693 const FileSystemURL& url, |
685 FileSystemFileUtil** file_util, | 694 FileSystemFileUtil** file_util, |
686 SetUpMode mode) { | 695 SetUpMode mode) { |
687 if (!url.is_valid()) | 696 if (!url.is_valid()) |
688 return base::PLATFORM_FILE_ERROR_INVALID_URL; | 697 return base::PLATFORM_FILE_ERROR_INVALID_URL; |
689 | 698 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 } | 741 } |
733 | 742 |
734 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { | 743 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { |
735 if (pending_operation_ != kOperationNone) | 744 if (pending_operation_ != kOperationNone) |
736 return false; | 745 return false; |
737 pending_operation_ = type; | 746 pending_operation_ = type; |
738 return true; | 747 return true; |
739 } | 748 } |
740 | 749 |
741 } // namespace fileapi | 750 } // namespace fileapi |
OLD | NEW |