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

Side by Side Diff: storage/browser/quota/quota_settings.cc

Issue 2592793002: Revert of Change how the quota system computes the total poolsize for temporary storage (Closed)
Patch Set: Created 4 years 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "storage/browser/quota/quota_settings.h"
6
7 #include <algorithm>
8
9 #include "base/metrics/histogram_macros.h"
10 #include "base/sys_info.h"
11
12 #define UMA_HISTOGRAM_MBYTES(name, sample) \
13 UMA_HISTOGRAM_CUSTOM_COUNTS((name), static_cast<int>((sample) / kMBytes), 1, \
14 10 * 1024 * 1024 /* 10TB */, 100)
15
16 namespace storage {
17
18 base::Optional<storage::QuotaSettings> CalculateNominalDynamicSettings(
19 const base::FilePath& partition_path,
20 bool is_incognito) {
21 const int64_t kMBytes = 1024 * 1024;
22
23 if (is_incognito) {
24 storage::QuotaSettings settings;
25 settings.pool_size =
26 std::min(300 * kMBytes, base::SysInfo::AmountOfPhysicalMemory() / 10);
27 settings.per_host_quota = settings.pool_size / 3;
28 settings.refresh_interval = base::TimeDelta::Max();
29 return settings;
30 }
31
32 // The fraction of the device's storage the browser is willing to
33 // use for temporary storage, this is applied after adjusting the
34 // total to take os_accomodation into account.
35 const double kTemporaryPoolSizeRatio = 1.0 / 3.0; // 33%
36
37 // The fraction of the device's storage the browser attempts to
38 // keep free.
39 const double kMustRemainAvailableRatio = 0.1;
40
41 // Determines the portion of the temp pool that can be
42 // utilized by a single host (ie. 5 for 20%).
43 const int kPerHostTemporaryPortion = 5;
44
45 // os_accomodation is an estimate of how much storage is needed for
46 // the os and essential application code outside of the browser.
47 const int64_t kDefaultOSAccomodation =
48 #if defined(OS_ANDROID)
49 1000 * kMBytes;
50 #elif defined(OS_CHROMEOS)
51 1000 * kMBytes;
52 #elif defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX)
53 10000 * kMBytes;
54 #else
55 #error "Port: Need to define an OS accomodation value for unknown OS."
56 #endif
57
58 storage::QuotaSettings settings;
59
60 int64_t total = base::SysInfo::AmountOfTotalDiskSpace(partition_path);
61 if (total == -1) {
62 LOG(ERROR) << "Unable to compute QuotaSettings.";
63 return base::nullopt;
64 }
65
66 // If our hardcoded OS accomodation is too large for the volume size, define
67 // the value as a fraction of the total volume size instead.
68 int64_t os_accomodation =
69 std::min(kDefaultOSAccomodation, static_cast<int64_t>(total * 0.8));
70 UMA_HISTOGRAM_MBYTES("Quota.OSAccomodationDelta",
71 kDefaultOSAccomodation - os_accomodation);
72
73 int64_t adjusted_total = total - os_accomodation;
74 int64_t pool_size = adjusted_total * kTemporaryPoolSizeRatio;
75
76 settings.pool_size = pool_size;
77 settings.must_remain_available = total * kMustRemainAvailableRatio;
78 settings.per_host_quota = pool_size / kPerHostTemporaryPortion;
79 settings.refresh_interval = base::TimeDelta::FromSeconds(60);
80 return settings;
81 }
82
83 } // namespace
OLDNEW
« no previous file with comments | « storage/browser/quota/quota_settings.h ('k') | storage/browser/quota/quota_temporary_storage_evictor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698