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

Unified Diff: storage/browser/quota/quota_settings.h

Issue 1782053004: Change how the quota system computes the total poolsize for temporary storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: storage/browser/quota/quota_settings.h
diff --git a/storage/browser/quota/quota_settings.h b/storage/browser/quota/quota_settings.h
new file mode 100644
index 0000000000000000000000000000000000000000..b6a6b039b900bb3f16dd45877ce51fb966d78158
--- /dev/null
+++ b/storage/browser/quota/quota_settings.h
@@ -0,0 +1,76 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef STORAGE_BROWSER_QUOTA_QUOTA_SETTINGS_H_
+#define STORAGE_BROWSER_QUOTA_QUOTA_SETTINGS_H_
+
+#include <stdint.h>
+
+#include "base/callback.h"
+#include "base/files/file_path.h"
+#include "base/optional.h"
+#include "base/time/time.h"
+#include "storage/browser/storage_browser_export.h"
+
+namespace storage {
+
+// Settings the storage lib embedder must provide to the QuotaManager.
+struct QuotaSettings {
+ QuotaSettings() = default;
+ QuotaSettings(int64_t pool_size,
+ int64_t per_host_quota,
+ int64_t must_remain_available)
+ : pool_size(pool_size),
+ per_host_quota(per_host_quota),
+ must_remain_available(must_remain_available) {}
+
+ // The target size in bytes of the shared pool of disk space the quota
+ // system allows for use by by websites using HTML5 storage apis, for
+ // example an embedder may use 50% of the total volume size.
+ int64_t pool_size = 0;
+
+ // The amount in bytes of the pool an individual site may consume. The
+ // value must be less than or equal to the pool_size.
+ int64_t per_host_quota = 0;
+
+ // The amount of space that must remain available on the storage
+ // volume. As the volume approaches this limit, the quota system gets
+ // more aggressive about evicting data and disallowing new data.
+ int64_t must_remain_available = 0;
+
+ // The quota system querries the embedder for the QuataSettings,
+ // but will rate limit the frequency of the querries to no more than once
+ // per refresh interval.
+ base::TimeDelta refresh_interval = base::TimeDelta::Max();
+};
+
+// Function type used to return the settings in response to a
+// GetQuotaSettingsFunc invocation. If the embedder cannot
+// produce a settings values, base::nullopt can be returned.
+using OptionalQuotaSettingsCallback =
+ base::Callback<void(base::Optional<QuotaSettings>)>;
+
+// Function type used to query the embedder about the quota manager settings.
+// This function is invoked on the UI thread.
+using GetQuotaSettingsFunc =
+ base::Callback<void(const base::FilePath& partition_path,
+ bool is_incognito,
+ const OptionalQuotaSettingsCallback& callback)>;
+
+STORAGE_EXPORT
+base::Optional<storage::QuotaSettings> CalculateNominalDynamicSettings(
jsbell 2016/11/09 00:12:04 Should probably document the algorithm here, at a
michaeln 2016/11/11 02:31:53 Done.
+ const base::FilePath& partition_path,
+ bool is_incognito);
+
+inline QuotaSettings GetNoQuotaSettings() {
+ return QuotaSettings();
+}
+
+inline QuotaSettings GetHardCodedSettings(int64_t per_host_quota) {
+ return QuotaSettings(per_host_quota * 5, per_host_quota, per_host_quota);
+}
+
+} // namespace storage
+
+#endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698