| 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_test_helper.h" | 5 #include "webkit/fileapi/local_file_system_test_helper.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // Initialize the usage cache file. | 56 // Initialize the usage cache file. |
| 57 base::FilePath usage_cache_path = GetUsageCachePath(); | 57 base::FilePath usage_cache_path = GetUsageCachePath(); |
| 58 if (!usage_cache_path.empty()) | 58 if (!usage_cache_path.empty()) |
| 59 usage_cache()->UpdateUsage(usage_cache_path, 0); | 59 usage_cache()->UpdateUsage(usage_cache_path, 0); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void LocalFileSystemTestOriginHelper::SetUp( | 62 void LocalFileSystemTestOriginHelper::SetUp( |
| 63 const base::FilePath& base_dir, | 63 const base::FilePath& base_dir, |
| 64 bool unlimited_quota, | 64 bool unlimited_quota, |
| 65 quota::QuotaManagerProxy* quota_manager_proxy) { | 65 quota::QuotaManagerProxy* quota_manager_proxy) { |
| 66 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = | |
| 67 new quota::MockSpecialStoragePolicy; | |
| 68 special_storage_policy->SetAllUnlimited(unlimited_quota); | |
| 69 file_system_context_ = new FileSystemContext( | 66 file_system_context_ = new FileSystemContext( |
| 70 FileSystemTaskRunners::CreateMockTaskRunners(), | 67 FileSystemTaskRunners::CreateMockTaskRunners(), |
| 71 ExternalMountPoints::CreateRefCounted().get(), | |
| 72 special_storage_policy, | |
| 73 quota_manager_proxy, | 68 quota_manager_proxy, |
| 69 ScopedVector<FileSystemMountPointProvider>(), |
| 70 std::vector<MountPoints*>(), |
| 74 base_dir, | 71 base_dir, |
| 75 CreateAllowFileAccessOptions()); | 72 CreateAllowFileAccessOptions()); |
| 76 | 73 |
| 77 SetUpFileUtil(); | 74 SetUpFileUtil(); |
| 78 | 75 |
| 79 // Prepare the origin's root directory. | 76 // Prepare the origin's root directory. |
| 80 FileSystemMountPointProvider* mount_point_provider = | 77 FileSystemMountPointProvider* mount_point_provider = |
| 81 file_system_context_->GetMountPointProvider(type_); | 78 file_system_context_->GetMountPointProvider(type_); |
| 82 mount_point_provider->GetFileSystemRootPathOnFileThread( | 79 mount_point_provider->GetFileSystemRootPathOnFileThread( |
| 83 CreateURL(base::FilePath()), true /* create */); | 80 CreateURL(base::FilePath()), true /* create */); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return context; | 163 return context; |
| 167 } | 164 } |
| 168 | 165 |
| 169 FileSystemUsageCache* LocalFileSystemTestOriginHelper::usage_cache() { | 166 FileSystemUsageCache* LocalFileSystemTestOriginHelper::usage_cache() { |
| 170 return file_system_context()->sandbox_provider()->usage_cache(); | 167 return file_system_context()->sandbox_provider()->usage_cache(); |
| 171 } | 168 } |
| 172 | 169 |
| 173 void LocalFileSystemTestOriginHelper::SetUpFileUtil() { | 170 void LocalFileSystemTestOriginHelper::SetUpFileUtil() { |
| 174 DCHECK(file_system_context_); | 171 DCHECK(file_system_context_); |
| 175 if (type_ == kFileSystemTypeTest) { | 172 if (type_ == kFileSystemTypeTest) { |
| 176 file_system_context_->RegisterMountPointProvider( | 173 file_system_context_->RegisterMountPointProviderForTesting( |
| 177 type_, | 174 type_, |
| 178 new TestMountPointProvider( | 175 new TestMountPointProvider( |
| 179 file_system_context_->task_runners()->file_task_runner(), | 176 file_system_context_->task_runners()->file_task_runner(), |
| 180 file_system_context_->partition_path())); | 177 file_system_context_->partition_path())); |
| 181 } | 178 } |
| 182 file_util_ = file_system_context_->GetFileUtil(type_); | 179 file_util_ = file_system_context_->GetFileUtil(type_); |
| 183 DCHECK(file_util_); | 180 DCHECK(file_util_); |
| 184 } | 181 } |
| 185 | 182 |
| 186 } // namespace fileapi | 183 } // namespace fileapi |
| OLD | NEW |