| 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 <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "storage/browser/fileapi/file_system_usage_cache.h" | 15 #include "storage/browser/fileapi/file_system_usage_cache.h" |
| 16 #include "storage/browser/fileapi/obfuscated_file_util.h" | 16 #include "storage/browser/fileapi/obfuscated_file_util.h" |
| 17 #include "storage/browser/quota/quota_manager_proxy.h" | 17 #include "storage/browser/quota/quota_manager_proxy.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" | 19 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" |
| 20 #include "third_party/leveldatabase/src/include/leveldb/env.h" | 20 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
| 21 | 21 |
| 22 using storage::FileSystemUsageCache; | 22 using storage::FileSystemUsageCache; |
| 23 using storage::ObfuscatedFileUtil; | 23 using storage::ObfuscatedFileUtil; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 base::FilePath path; | 141 base::FilePath path; |
| 142 base::File::Error error = | 142 base::File::Error error = |
| 143 backend_->GetUsageCachePath(origin, type, &path); | 143 backend_->GetUsageCachePath(origin, type, &path); |
| 144 EXPECT_EQ(base::File::FILE_OK, error); | 144 EXPECT_EQ(base::File::FILE_OK, error); |
| 145 EXPECT_FALSE(path.empty()); | 145 EXPECT_FALSE(path.empty()); |
| 146 return path; | 146 return path; |
| 147 } | 147 } |
| 148 | 148 |
| 149 base::MessageLoop message_loop_; | 149 base::MessageLoop message_loop_; |
| 150 base::ScopedTempDir data_dir_; | 150 base::ScopedTempDir data_dir_; |
| 151 scoped_ptr<leveldb::Env> in_memory_env_; | 151 std::unique_ptr<leveldb::Env> in_memory_env_; |
| 152 scoped_ptr<ObfuscatedFileUtil> file_util_; | 152 std::unique_ptr<ObfuscatedFileUtil> file_util_; |
| 153 FileSystemUsageCache file_system_usage_cache_; | 153 FileSystemUsageCache file_system_usage_cache_; |
| 154 scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; | 154 scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; |
| 155 scoped_ptr<QuotaBackendImpl> backend_; | 155 std::unique_ptr<QuotaBackendImpl> backend_; |
| 156 | 156 |
| 157 private: | 157 private: |
| 158 DISALLOW_COPY_AND_ASSIGN(QuotaBackendImplTest); | 158 DISALLOW_COPY_AND_ASSIGN(QuotaBackendImplTest); |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 TEST_F(QuotaBackendImplTest, ReserveQuota_Basic) { | 161 TEST_F(QuotaBackendImplTest, ReserveQuota_Basic) { |
| 162 storage::FileSystemType type = storage::kFileSystemTypeTemporary; | 162 storage::FileSystemType type = storage::kFileSystemTypeTemporary; |
| 163 InitializeForOriginAndType(GURL(kOrigin), type); | 163 InitializeForOriginAndType(GURL(kOrigin), type); |
| 164 quota_manager_proxy_->set_quota(10000); | 164 quota_manager_proxy_->set_quota(10000); |
| 165 | 165 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 uint32_t dirty = 0; | 266 uint32_t dirty = 0; |
| 267 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); | 267 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); |
| 268 EXPECT_EQ(1u, dirty); | 268 EXPECT_EQ(1u, dirty); |
| 269 | 269 |
| 270 backend_->DecrementDirtyCount(GURL(kOrigin), type); | 270 backend_->DecrementDirtyCount(GURL(kOrigin), type); |
| 271 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); | 271 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); |
| 272 EXPECT_EQ(0u, dirty); | 272 EXPECT_EQ(0u, dirty); |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace content | 275 } // namespace content |
| OLD | NEW |