blob: a4f26b39f436101d42222d5dd0b160beedf77f56 [file] [log] [blame]
Austin Sullivan2b1e6e02022-12-07 18:10:201// Copyright 2022 The Chromium Authors
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 "content/browser/file_system_access/features.h"
6
7#include "base/feature_list.h"
Austin Sullivanb33295c2023-02-06 23:34:178#include "build/build_config.h"
Nathan Memmottf3f35272024-12-18 17:22:589#include "third_party/blink/public/common/features.h"
10#include "third_party/blink/public/common/features_generated.h"
Austin Sullivan2b1e6e02022-12-07 18:10:2011
12namespace content::features {
13
Alison Gale59c007a2024-04-20 03:05:4014// TODO(crbug.com/40896420): Remove this flag eventually.
Daseul Leeaaacdf3492024-07-30 16:37:4715// TODO(b/354661640): Temporarily disable this flag while investigating CrOS
16// file saving issue.
17//
Daseul Leec67802492023-12-07 19:52:5218// When enabled, GetFile() and GetEntries() on a directory handle performs
19// the blocklist check on child file handles.
20BASE_FEATURE(kFileSystemAccessDirectoryIterationBlocklistCheck,
21 "FileSystemAccessDirectoryIterationBlocklistCheck",
Nathan Memmott6739e182024-10-28 17:04:1722 base::FEATURE_ENABLED_BY_DEFAULT);
Nathan Memmottf3f35272024-12-18 17:22:5823
24// When enabled, sites are limited in how much underlying operating resources
25// they can access through the `FileSystemObserver` API. This limit is called
26// the quota limit. Without this enabled, sites will be limited by the system
27// limit.
28BASE_FEATURE(kFileSystemAccessObserverQuotaLimit,
29 "FileSystemAccessObserverQuotaLimit",
30 base::FEATURE_ENABLED_BY_DEFAULT);
31
32// On Linux, the quota limit is found by:
33// 1. Rounding down the system limit (read from
34// /proc/sys/fs/inotify/max_user_watches) to the nearest
35// `kFileSystemObserverQuotaLimitLinuxBucketSize`.
36// 2. Taking that max of that result and
37// `kFileSystemObserverQuotaLimitLinuxMin`.
38// 3. And setting quota limit to `kFileSystemObserverQuotaLimitLinuxPercent`% of
39// that result.
40BASE_FEATURE_PARAM(size_t,
41 kFileSystemObserverQuotaLimitLinuxBucketSize,
42 &kFileSystemAccessObserverQuotaLimit,
43 "file_system_observer_quota_limit_linux_bucket_size",
44 100000);
45BASE_FEATURE_PARAM(size_t,
46 kFileSystemObserverQuotaLimitLinuxMin,
47 &kFileSystemAccessObserverQuotaLimit,
48 "file_system_observer_quota_limit_linux_min",
49 8192);
50BASE_FEATURE_PARAM(double,
51 kFileSystemObserverQuotaLimitLinuxPercent,
52 &kFileSystemAccessObserverQuotaLimit,
53 "file_system_observer_quota_limit_linux_percent",
54 0.8);
55
56// On Mac, the quota limit is `kFileSystemObserverQuotaLimitMacPercent`% of the
57// system limit (512) which is constant across all devices.
58BASE_FEATURE_PARAM(double,
59 kFileSystemObserverQuotaLimitMacPercent,
60 &kFileSystemAccessObserverQuotaLimit,
61 "file_system_observer_quota_limit_mac_percent",
62 0.2 // About 100 FSEventStreamCreate calls.
63);
64
65// On Windows, the quota limit is a constant memory size.
66BASE_FEATURE_PARAM(size_t,
67 kFileSystemObserverQuotaLimitWindows,
68 &kFileSystemAccessObserverQuotaLimit,
69 "file_system_observer_quota_limit_windows",
70 2 << 28 // 1/2GiB
71);
72
Austin Sullivan2b1e6e02022-12-07 18:10:2073} // namespace content::features