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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 quota_status_(quota::kQuotaStatusUnknown), | 125 quota_status_(quota::kQuotaStatusUnknown), |
126 usage_(-1) { | 126 usage_(-1) { |
127 } | 127 } |
128 | 128 |
129 virtual void SetUp() { | 129 virtual void SetUp() { |
130 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 130 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
131 | 131 |
132 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = | 132 scoped_refptr<quota::SpecialStoragePolicy> storage_policy = |
133 new quota::MockSpecialStoragePolicy(); | 133 new quota::MockSpecialStoragePolicy(); |
134 | 134 |
135 quota_manager_ = new quota::QuotaManager( | 135 quota_manager_ = new quota::QuotaManager(false /* is_incognito */, |
136 false /* is_incognito */, | 136 data_dir_.path(), |
137 data_dir_.path(), | 137 base::MessageLoopProxy::current(), |
138 base::MessageLoopProxy::current(), | 138 base::MessageLoopProxy::current(), |
139 base::MessageLoopProxy::current(), | 139 storage_policy.get()); |
140 storage_policy); | |
141 | 140 |
142 // Every time we create a new sandbox_file_system helper, | 141 // Every time we create a new sandbox_file_system helper, |
143 // it creates another context, which creates another path manager, | 142 // it creates another context, which creates another path manager, |
144 // another sandbox_mount_point_provider, and | 143 // another sandbox_mount_point_provider, and |
145 // another OFU. We need to pass in the context to skip all that. | 144 // another OFU. We need to pass in the context to skip all that. |
146 file_system_context_ = CreateFileSystemContextForTesting( | 145 file_system_context_ = CreateFileSystemContextForTesting( |
147 quota_manager_->proxy(), | 146 quota_manager_->proxy(), |
148 data_dir_.path()); | 147 data_dir_.path()); |
149 | 148 |
150 sandbox_file_system_.SetUp(file_system_context_.get()); | 149 sandbox_file_system_.SetUp(file_system_context_.get()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 return type_; | 219 return type_; |
221 } | 220 } |
222 | 221 |
223 int64 ComputeTotalFileSize() { | 222 int64 ComputeTotalFileSize() { |
224 return sandbox_file_system_.ComputeCurrentOriginUsage() - | 223 return sandbox_file_system_.ComputeCurrentOriginUsage() - |
225 sandbox_file_system_.ComputeCurrentDirectoryDatabaseUsage(); | 224 sandbox_file_system_.ComputeCurrentDirectoryDatabaseUsage(); |
226 } | 225 } |
227 | 226 |
228 void GetUsageFromQuotaManager() { | 227 void GetUsageFromQuotaManager() { |
229 int64 quota = -1; | 228 int64 quota = -1; |
230 quota_status_ = AsyncFileTestHelper::GetUsageAndQuota( | 229 quota_status_ = |
231 quota_manager_, origin(), sandbox_file_system_.type(), | 230 AsyncFileTestHelper::GetUsageAndQuota(quota_manager_.get(), |
232 &usage_, "a); | 231 origin(), |
| 232 sandbox_file_system_.type(), |
| 233 &usage_, |
| 234 "a); |
233 EXPECT_EQ(quota::kQuotaStatusOk, quota_status_); | 235 EXPECT_EQ(quota::kQuotaStatusOk, quota_status_); |
234 } | 236 } |
235 | 237 |
236 void RevokeUsageCache() { | 238 void RevokeUsageCache() { |
237 quota_manager_->ResetUsageTracker(sandbox_file_system_.storage_type()); | 239 quota_manager_->ResetUsageTracker(sandbox_file_system_.storage_type()); |
238 usage_cache()->Delete(sandbox_file_system_.GetUsageCachePath()); | 240 usage_cache()->Delete(sandbox_file_system_.GetUsageCachePath()); |
239 } | 241 } |
240 | 242 |
241 int64 SizeByQuotaUtil() { | 243 int64 SizeByQuotaUtil() { |
242 return sandbox_file_system_.GetCachedOriginUsage(); | 244 return sandbox_file_system_.GetCachedOriginUsage(); |
(...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 ASSERT_EQ(base::PLATFORM_FILE_OK, | 2245 ASSERT_EQ(base::PLATFORM_FILE_OK, |
2244 ofu()->CreateOrOpen( | 2246 ofu()->CreateOrOpen( |
2245 AllowUsageIncrease(-length)->context(), file, | 2247 AllowUsageIncrease(-length)->context(), file, |
2246 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, | 2248 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, |
2247 &file_handle, &created)); | 2249 &file_handle, &created)); |
2248 ASSERT_EQ(0, ComputeTotalFileSize()); | 2250 ASSERT_EQ(0, ComputeTotalFileSize()); |
2249 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); | 2251 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); |
2250 } | 2252 } |
2251 | 2253 |
2252 } // namespace fileapi | 2254 } // namespace fileapi |
OLD | NEW |