Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: webkit/fileapi/file_system_operation.cc

Issue 9004019: Cleanup: Removing FileSystemPathManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_system_operation.h" 5 #include "webkit/fileapi/file_system_operation.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "net/base/escape.h" 10 #include "net/base/escape.h"
11 #include "net/url_request/url_request_context.h" 11 #include "net/url_request/url_request_context.h"
12 #include "webkit/fileapi/file_system_callback_dispatcher.h" 12 #include "webkit/fileapi/file_system_callback_dispatcher.h"
13 #include "webkit/fileapi/file_system_context.h" 13 #include "webkit/fileapi/file_system_context.h"
14 #include "webkit/fileapi/file_system_file_util_proxy.h" 14 #include "webkit/fileapi/file_system_file_util_proxy.h"
15 #include "webkit/fileapi/file_system_mount_point_provider.h"
15 #include "webkit/fileapi/file_system_operation_context.h" 16 #include "webkit/fileapi/file_system_operation_context.h"
16 #include "webkit/fileapi/file_system_path_manager.h"
17 #include "webkit/fileapi/file_system_quota_util.h" 17 #include "webkit/fileapi/file_system_quota_util.h"
18 #include "webkit/fileapi/file_system_types.h" 18 #include "webkit/fileapi/file_system_types.h"
19 #include "webkit/fileapi/file_system_util.h" 19 #include "webkit/fileapi/file_system_util.h"
20 #include "webkit/fileapi/file_writer_delegate.h" 20 #include "webkit/fileapi/file_writer_delegate.h"
21 #include "webkit/fileapi/local_file_util.h" 21 #include "webkit/fileapi/local_file_util.h"
22 #include "webkit/fileapi/quota_file_util.h" 22 #include "webkit/fileapi/quota_file_util.h"
23 #include "webkit/quota/quota_types.h" 23 #include "webkit/quota/quota_types.h"
24 24
25 namespace fileapi { 25 namespace fileapi {
26 26
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 DCHECK(file_system_context()); 94 DCHECK(file_system_context());
95 operation_context_.set_src_origin_url(origin_url); 95 operation_context_.set_src_origin_url(origin_url);
96 operation_context_.set_src_type(type); 96 operation_context_.set_src_type(type);
97 // TODO(ericu): We don't really need to make this call if !create. 97 // TODO(ericu): We don't really need to make this call if !create.
98 // Also, in the future we won't need it either way, as long as we do all 98 // Also, in the future we won't need it either way, as long as we do all
99 // permission+quota checks beforehand. We only need it now because we have to 99 // permission+quota checks beforehand. We only need it now because we have to
100 // create an unpredictable directory name. Without that, we could lazily 100 // create an unpredictable directory name. Without that, we could lazily
101 // create the root later on the first filesystem write operation, and just 101 // create the root later on the first filesystem write operation, and just
102 // return GetFileSystemRootURI() here. 102 // return GetFileSystemRootURI() here.
103 file_system_context()->path_manager()->ValidateFileSystemRootAndGetURL( 103 FileSystemMountPointProvider* mount_point_provider =
104 file_system_context()->GetMountPointProvider(type);
105 DCHECK(mount_point_provider);
106 mount_point_provider->ValidateFileSystemRootAndGetURL(
104 origin_url, type, create, 107 origin_url, type, create,
105 base::Bind(&FileSystemOperation::DidGetRootPath, 108 base::Bind(&FileSystemOperation::DidGetRootPath,
106 base::Owned(this))); 109 base::Owned(this)));
107 } 110 }
108 111
109 void FileSystemOperation::CreateFile(const GURL& path, 112 void FileSystemOperation::CreateFile(const GURL& path,
110 bool exclusive) { 113 bool exclusive) {
111 #ifndef NDEBUG 114 #ifndef NDEBUG
112 DCHECK(kOperationNone == pending_operation_); 115 DCHECK(kOperationNone == pending_operation_);
113 pending_operation_ = kOperationCreateFile; 116 pending_operation_ = kOperationCreateFile;
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 FilePath* virtual_path, FileSystemFileUtil** file_util) { 769 FilePath* virtual_path, FileSystemFileUtil** file_util) {
767 if (!VerifyFileSystemPath(path, origin_url, type, virtual_path, file_util)) 770 if (!VerifyFileSystemPath(path, origin_url, type, virtual_path, file_util))
768 return false; 771 return false;
769 772
770 // Any write access is disallowed on the root path. 773 // Any write access is disallowed on the root path.
771 if (virtual_path->value().length() == 0 || 774 if (virtual_path->value().length() == 0 ||
772 virtual_path->DirName().value() == virtual_path->value()) { 775 virtual_path->DirName().value() == virtual_path->value()) {
773 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); 776 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
774 return false; 777 return false;
775 } 778 }
776 if (create && file_system_context()->path_manager()->IsRestrictedFileName( 779 if (create &&
777 *type, virtual_path->BaseName())) { 780 file_system_context()->GetMountPointProvider(*type)->IsRestrictedFileName(
781 virtual_path->BaseName())) {
778 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); 782 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
779 return false; 783 return false;
780 } 784 }
781 785
782 return true; 786 return true;
783 } 787 }
784 788
785 bool FileSystemOperation::VerifyFileSystemPath( 789 bool FileSystemOperation::VerifyFileSystemPath(
786 const GURL& path, GURL* origin_url, FileSystemType* type, 790 const GURL& path, GURL* origin_url, FileSystemType* type,
787 FilePath* virtual_path, FileSystemFileUtil** file_util) { 791 FilePath* virtual_path, FileSystemFileUtil** file_util) {
788 DCHECK(file_system_context()); 792 DCHECK(file_system_context());
789 793
790 if (!CrackFileSystemURL(path, origin_url, type, virtual_path)) { 794 if (!CrackFileSystemURL(path, origin_url, type, virtual_path)) {
791 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_INVALID_URL); 795 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_INVALID_URL);
792 return false; 796 return false;
793 } 797 }
794 if (!file_system_context()->path_manager()->IsAccessAllowed( 798 if (!file_system_context()->GetMountPointProvider(*type)->IsAccessAllowed(
795 *origin_url, *type, *virtual_path)) { 799 *origin_url, *type, *virtual_path)) {
796 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); 800 dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
797 return false; 801 return false;
798 } 802 }
799 DCHECK(file_util); 803 DCHECK(file_util);
800 *file_util = file_system_context()->path_manager()->GetFileUtil(*type); 804 *file_util = file_system_context()->GetFileUtil(*type);
801 DCHECK(*file_util); 805 DCHECK(*file_util);
802 806
803 return true; 807 return true;
804 } 808 }
805 809
806 bool FileSystemOperation::SetupSrcContextForRead(const GURL& path) { 810 bool FileSystemOperation::SetupSrcContextForRead(const GURL& path) {
807 GURL origin_url; 811 GURL origin_url;
808 FileSystemType type; 812 FileSystemType type;
809 FileSystemFileUtil* file_util; 813 FileSystemFileUtil* file_util;
810 bool result = VerifyFileSystemPathForRead( 814 bool result = VerifyFileSystemPathForRead(
(...skipping 27 matching lines...) Expand all
838 bool result = VerifyFileSystemPathForWrite( 842 bool result = VerifyFileSystemPathForWrite(
839 path, create, &origin_url, &type, &dest_virtual_path_, &file_util); 843 path, create, &origin_url, &type, &dest_virtual_path_, &file_util);
840 operation_context_.set_dest_origin_url(origin_url); 844 operation_context_.set_dest_origin_url(origin_url);
841 operation_context_.set_dest_type(type); 845 operation_context_.set_dest_type(type);
842 if (!operation_context_.dest_file_util()) 846 if (!operation_context_.dest_file_util())
843 operation_context_.set_dest_file_util(file_util); 847 operation_context_.set_dest_file_util(file_util);
844 return result; 848 return result;
845 } 849 }
846 850
847 } // namespace fileapi 851 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698