| 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 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 void RevokeUsageCache() { | 222 void RevokeUsageCache() { |
| 223 quota_manager_->ResetUsageTracker(test_helper_.storage_type()); | 223 quota_manager_->ResetUsageTracker(test_helper_.storage_type()); |
| 224 file_util::Delete(test_helper_.GetUsageCachePath(), false); | 224 file_util::Delete(test_helper_.GetUsageCachePath(), false); |
| 225 } | 225 } |
| 226 | 226 |
| 227 int64 SizeByQuotaUtil() { | 227 int64 SizeByQuotaUtil() { |
| 228 return test_helper_.GetCachedOriginUsage(); | 228 return test_helper_.GetCachedOriginUsage(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 int64 SizeInUsageFile() { | 231 int64 SizeInUsageFile() { |
| 232 MessageLoop::current()->RunUntilIdle(); |
| 232 return FileSystemUsageCache::GetUsage(test_helper_.GetUsageCachePath()); | 233 return FileSystemUsageCache::GetUsage(test_helper_.GetUsageCachePath()); |
| 233 } | 234 } |
| 234 | 235 |
| 235 bool PathExists(const FileSystemURL& url) { | 236 bool PathExists(const FileSystemURL& url) { |
| 236 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); | 237 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); |
| 237 return FileUtilHelper::PathExists(context.get(), ofu(), url); | 238 return FileUtilHelper::PathExists(context.get(), ofu(), url); |
| 238 } | 239 } |
| 239 | 240 |
| 240 bool DirectoryExists(const FileSystemURL& url) { | 241 bool DirectoryExists(const FileSystemURL& url) { |
| 241 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); | 242 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 class UsageVerifyHelper { | 347 class UsageVerifyHelper { |
| 347 public: | 348 public: |
| 348 UsageVerifyHelper(scoped_ptr<FileSystemOperationContext> context, | 349 UsageVerifyHelper(scoped_ptr<FileSystemOperationContext> context, |
| 349 LocalFileSystemTestOriginHelper* test_helper, | 350 LocalFileSystemTestOriginHelper* test_helper, |
| 350 int64 expected_usage) | 351 int64 expected_usage) |
| 351 : context_(context.Pass()), | 352 : context_(context.Pass()), |
| 352 test_helper_(test_helper), | 353 test_helper_(test_helper), |
| 353 expected_usage_(expected_usage) {} | 354 expected_usage_(expected_usage) {} |
| 354 | 355 |
| 355 ~UsageVerifyHelper() { | 356 ~UsageVerifyHelper() { |
| 357 MessageLoop::current()->RunUntilIdle(); |
| 356 Check(); | 358 Check(); |
| 357 } | 359 } |
| 358 | 360 |
| 359 FileSystemOperationContext* context() { | 361 FileSystemOperationContext* context() { |
| 360 return context_.get(); | 362 return context_.get(); |
| 361 } | 363 } |
| 362 | 364 |
| 363 private: | 365 private: |
| 364 void Check() { | 366 void Check() { |
| 365 ASSERT_EQ(expected_usage_, | 367 ASSERT_EQ(expected_usage_, |
| (...skipping 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2225 ASSERT_EQ(base::PLATFORM_FILE_OK, | 2227 ASSERT_EQ(base::PLATFORM_FILE_OK, |
| 2226 ofu()->CreateOrOpen( | 2228 ofu()->CreateOrOpen( |
| 2227 AllowUsageIncrease(-length)->context(), file, | 2229 AllowUsageIncrease(-length)->context(), file, |
| 2228 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, | 2230 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, |
| 2229 &file_handle, &created)); | 2231 &file_handle, &created)); |
| 2230 ASSERT_EQ(0, ComputeTotalFileSize()); | 2232 ASSERT_EQ(0, ComputeTotalFileSize()); |
| 2231 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); | 2233 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); |
| 2232 } | 2234 } |
| 2233 | 2235 |
| 2234 } // namespace fileapi | 2236 } // namespace fileapi |
| OLD | NEW |