Chromium Code Reviews| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 origin, type, base::Bind(&QuotaManagerTest::DidGetUsageAndQuota, | 160 origin, type, base::Bind(&QuotaManagerTest::DidGetUsageAndQuota, |
| 161 weak_factory_.GetWeakPtr())); | 161 weak_factory_.GetWeakPtr())); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void SetQuotaSettings(int64_t pool_size, | 164 void SetQuotaSettings(int64_t pool_size, |
| 165 int64_t per_host_quota, | 165 int64_t per_host_quota, |
| 166 int64_t must_remain_available) { | 166 int64_t must_remain_available) { |
| 167 storage::QuotaSettings settings; | 167 storage::QuotaSettings settings; |
| 168 settings.pool_size = pool_size; | 168 settings.pool_size = pool_size; |
| 169 settings.per_host_quota = per_host_quota; | 169 settings.per_host_quota = per_host_quota; |
| 170 settings.session_only_per_host_quota = | |
| 171 (per_host_quota > 0) ? (per_host_quota - 1) : INT64_C(0); | |
|
Thiemo Nagel
2017/04/10 09:41:37
Nit: What's the purpose of INT64_C() here?
michaeln
2017/04/10 23:15:35
I'll remove it if its not needed to compile withou
| |
| 170 settings.must_remain_available = must_remain_available; | 172 settings.must_remain_available = must_remain_available; |
| 171 settings.refresh_interval = base::TimeDelta::Max(); | 173 settings.refresh_interval = base::TimeDelta::Max(); |
| 172 quota_manager_->SetQuotaSettings(settings); | 174 quota_manager_->SetQuotaSettings(settings); |
| 173 } | 175 } |
| 174 | 176 |
| 175 void GetPersistentHostQuota(const std::string& host) { | 177 void GetPersistentHostQuota(const std::string& host) { |
| 176 quota_status_ = kQuotaStatusUnknown; | 178 quota_status_ = kQuotaStatusUnknown; |
| 177 quota_ = -1; | 179 quota_ = -1; |
| 178 quota_manager_->GetPersistentHostQuota( | 180 quota_manager_->GetPersistentHostQuota( |
| 179 host, | 181 host, |
| (...skipping 2065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2245 EXPECT_EQ(80, usage()); | 2247 EXPECT_EQ(80, usage()); |
| 2246 EXPECT_EQ(available_space() + usage(), quota()); | 2248 EXPECT_EQ(available_space() + usage(), quota()); |
| 2247 | 2249 |
| 2248 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 2250 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
| 2249 base::RunLoop().RunUntilIdle(); | 2251 base::RunLoop().RunUntilIdle(); |
| 2250 EXPECT_EQ(kQuotaStatusOk, status()); | 2252 EXPECT_EQ(kQuotaStatusOk, status()); |
| 2251 EXPECT_EQ(10, usage()); | 2253 EXPECT_EQ(10, usage()); |
| 2252 EXPECT_EQ(available_space() + usage(), quota()); | 2254 EXPECT_EQ(available_space() + usage(), quota()); |
| 2253 } | 2255 } |
| 2254 | 2256 |
| 2257 TEST_F(QuotaManagerTest, GetUsageAndQuota_SessionOnly) { | |
| 2258 const GURL kEpheremalOrigin("http://ephemeral/"); | |
| 2259 mock_special_storage_policy()->AddSessionOnly(kEpheremalOrigin); | |
| 2260 | |
| 2261 GetUsageAndQuotaForWebApps(kEpheremalOrigin, kTemp); | |
| 2262 base::RunLoop().RunUntilIdle(); | |
| 2263 EXPECT_EQ(quota_manager()->settings().session_only_per_host_quota, quota()); | |
| 2264 | |
| 2265 GetUsageAndQuotaForWebApps(kEpheremalOrigin, kPerm); | |
| 2266 base::RunLoop().RunUntilIdle(); | |
| 2267 EXPECT_EQ(0, quota()); | |
| 2268 } | |
| 2269 | |
| 2255 } // namespace content | 2270 } // namespace content |
| OLD | NEW |