Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: content/browser/quota/quota_manager_unittest.cc

Issue 2777183010: [Quota] Lower quota for ephemeral mode (ie. session only) (Closed)
Patch Set: comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | storage/browser/quota/quota_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 origin, type, base::Bind(&QuotaManagerTest::DidGetUsageAndQuota, 161 origin, type, base::Bind(&QuotaManagerTest::DidGetUsageAndQuota,
162 weak_factory_.GetWeakPtr())); 162 weak_factory_.GetWeakPtr()));
163 } 163 }
164 164
165 void SetQuotaSettings(int64_t pool_size, 165 void SetQuotaSettings(int64_t pool_size,
166 int64_t per_host_quota, 166 int64_t per_host_quota,
167 int64_t must_remain_available) { 167 int64_t must_remain_available) {
168 storage::QuotaSettings settings; 168 storage::QuotaSettings settings;
169 settings.pool_size = pool_size; 169 settings.pool_size = pool_size;
170 settings.per_host_quota = per_host_quota; 170 settings.per_host_quota = per_host_quota;
171 settings.session_only_per_host_quota =
172 (per_host_quota > 0) ? (per_host_quota - 1) : 0;
171 settings.must_remain_available = must_remain_available; 173 settings.must_remain_available = must_remain_available;
172 settings.refresh_interval = base::TimeDelta::Max(); 174 settings.refresh_interval = base::TimeDelta::Max();
173 quota_manager_->SetQuotaSettings(settings); 175 quota_manager_->SetQuotaSettings(settings);
174 } 176 }
175 177
176 void GetPersistentHostQuota(const std::string& host) { 178 void GetPersistentHostQuota(const std::string& host) {
177 quota_status_ = kQuotaStatusUnknown; 179 quota_status_ = kQuotaStatusUnknown;
178 quota_ = -1; 180 quota_ = -1;
179 quota_manager_->GetPersistentHostQuota( 181 quota_manager_->GetPersistentHostQuota(
180 host, 182 host,
(...skipping 2065 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 EXPECT_EQ(80, usage()); 2248 EXPECT_EQ(80, usage());
2247 EXPECT_EQ(available_space() + usage(), quota()); 2249 EXPECT_EQ(available_space() + usage(), quota());
2248 2250
2249 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); 2251 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
2250 base::RunLoop().RunUntilIdle(); 2252 base::RunLoop().RunUntilIdle();
2251 EXPECT_EQ(kQuotaStatusOk, status()); 2253 EXPECT_EQ(kQuotaStatusOk, status());
2252 EXPECT_EQ(10, usage()); 2254 EXPECT_EQ(10, usage());
2253 EXPECT_EQ(available_space() + usage(), quota()); 2255 EXPECT_EQ(available_space() + usage(), quota());
2254 } 2256 }
2255 2257
2258 TEST_F(QuotaManagerTest, GetUsageAndQuota_SessionOnly) {
2259 const GURL kEpheremalOrigin("http://ephemeral/");
2260 mock_special_storage_policy()->AddSessionOnly(kEpheremalOrigin);
2261
2262 GetUsageAndQuotaForWebApps(kEpheremalOrigin, kTemp);
2263 base::RunLoop().RunUntilIdle();
2264 EXPECT_EQ(quota_manager()->settings().session_only_per_host_quota, quota());
2265
2266 GetUsageAndQuotaForWebApps(kEpheremalOrigin, kPerm);
2267 base::RunLoop().RunUntilIdle();
2268 EXPECT_EQ(0, quota());
2269 }
2270
2256 } // namespace content 2271 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | storage/browser/quota/quota_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698