| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "storage/browser/fileapi/quota/quota_backend_impl.h" | 5 #include "storage/browser/fileapi/quota/quota_backend_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/test/scoped_task_environment.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "storage/browser/fileapi/file_system_usage_cache.h" | 17 #include "storage/browser/fileapi/file_system_usage_cache.h" |
| 17 #include "storage/browser/fileapi/obfuscated_file_util.h" | 18 #include "storage/browser/fileapi/obfuscated_file_util.h" |
| 18 #include "storage/browser/quota/quota_manager_proxy.h" | 19 #include "storage/browser/quota/quota_manager_proxy.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" | 21 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" |
| 21 #include "third_party/leveldatabase/src/include/leveldb/env.h" | 22 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
| 22 | 23 |
| 23 using storage::FileSystemUsageCache; | 24 using storage::FileSystemUsageCache; |
| 24 using storage::ObfuscatedFileUtil; | 25 using storage::ObfuscatedFileUtil; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 140 |
| 140 base::FilePath GetUsageCachePath(const GURL& origin, | 141 base::FilePath GetUsageCachePath(const GURL& origin, |
| 141 storage::FileSystemType type) { | 142 storage::FileSystemType type) { |
| 142 base::FilePath path; | 143 base::FilePath path; |
| 143 base::File::Error error = backend_->GetUsageCachePath(origin, type, &path); | 144 base::File::Error error = backend_->GetUsageCachePath(origin, type, &path); |
| 144 EXPECT_EQ(base::File::FILE_OK, error); | 145 EXPECT_EQ(base::File::FILE_OK, error); |
| 145 EXPECT_FALSE(path.empty()); | 146 EXPECT_FALSE(path.empty()); |
| 146 return path; | 147 return path; |
| 147 } | 148 } |
| 148 | 149 |
| 149 base::MessageLoop message_loop_; | 150 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 150 base::ScopedTempDir data_dir_; | 151 base::ScopedTempDir data_dir_; |
| 151 std::unique_ptr<leveldb::Env> in_memory_env_; | 152 std::unique_ptr<leveldb::Env> in_memory_env_; |
| 152 std::unique_ptr<ObfuscatedFileUtil> file_util_; | 153 std::unique_ptr<ObfuscatedFileUtil> file_util_; |
| 153 FileSystemUsageCache file_system_usage_cache_; | 154 FileSystemUsageCache file_system_usage_cache_; |
| 154 scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; | 155 scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; |
| 155 std::unique_ptr<QuotaBackendImpl> backend_; | 156 std::unique_ptr<QuotaBackendImpl> backend_; |
| 156 | 157 |
| 157 private: | 158 private: |
| 158 DISALLOW_COPY_AND_ASSIGN(QuotaBackendImplTest); | 159 DISALLOW_COPY_AND_ASSIGN(QuotaBackendImplTest); |
| 159 }; | 160 }; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 uint32_t dirty = 0; | 267 uint32_t dirty = 0; |
| 267 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); | 268 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); |
| 268 EXPECT_EQ(1u, dirty); | 269 EXPECT_EQ(1u, dirty); |
| 269 | 270 |
| 270 backend_->DecrementDirtyCount(GURL(kOrigin), type); | 271 backend_->DecrementDirtyCount(GURL(kOrigin), type); |
| 271 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); | 272 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); |
| 272 EXPECT_EQ(0u, dirty); | 273 EXPECT_EQ(0u, dirty); |
| 273 } | 274 } |
| 274 | 275 |
| 275 } // namespace content | 276 } // namespace content |
| OLD | NEW |