Austin Sullivan | 2b1e6e0 | 2022-12-07 18:10:20 | [diff] [blame] | 1 | // 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 Sullivan | b33295c | 2023-02-06 23:34:17 | [diff] [blame] | 8 | #include "build/build_config.h" |
Nathan Memmott | f3f3527 | 2024-12-18 17:22:58 | [diff] [blame] | 9 | #include "third_party/blink/public/common/features.h" |
| 10 | #include "third_party/blink/public/common/features_generated.h" |
Austin Sullivan | 2b1e6e0 | 2022-12-07 18:10:20 | [diff] [blame] | 11 | |
| 12 | namespace content::features { |
| 13 | |
Alison Gale | 59c007a | 2024-04-20 03:05:40 | [diff] [blame] | 14 | // TODO(crbug.com/40896420): Remove this flag eventually. |
Daseul Lee | aaacdf349 | 2024-07-30 16:37:47 | [diff] [blame] | 15 | // TODO(b/354661640): Temporarily disable this flag while investigating CrOS |
| 16 | // file saving issue. |
| 17 | // |
Daseul Lee | c6780249 | 2023-12-07 19:52:52 | [diff] [blame] | 18 | // When enabled, GetFile() and GetEntries() on a directory handle performs |
| 19 | // the blocklist check on child file handles. |
| 20 | BASE_FEATURE(kFileSystemAccessDirectoryIterationBlocklistCheck, |
| 21 | "FileSystemAccessDirectoryIterationBlocklistCheck", |
Nathan Memmott | 6739e18 | 2024-10-28 17:04:17 | [diff] [blame] | 22 | base::FEATURE_ENABLED_BY_DEFAULT); |
Nathan Memmott | f3f3527 | 2024-12-18 17:22:58 | [diff] [blame] | 23 | |
| 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. |
| 28 | BASE_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. |
| 40 | BASE_FEATURE_PARAM(size_t, |
| 41 | kFileSystemObserverQuotaLimitLinuxBucketSize, |
| 42 | &kFileSystemAccessObserverQuotaLimit, |
| 43 | "file_system_observer_quota_limit_linux_bucket_size", |
| 44 | 100000); |
| 45 | BASE_FEATURE_PARAM(size_t, |
| 46 | kFileSystemObserverQuotaLimitLinuxMin, |
| 47 | &kFileSystemAccessObserverQuotaLimit, |
| 48 | "file_system_observer_quota_limit_linux_min", |
| 49 | 8192); |
| 50 | BASE_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. |
| 58 | BASE_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. |
| 66 | BASE_FEATURE_PARAM(size_t, |
| 67 | kFileSystemObserverQuotaLimitWindows, |
| 68 | &kFileSystemAccessObserverQuotaLimit, |
| 69 | "file_system_observer_quota_limit_windows", |
| 70 | 2 << 28 // 1/2GiB |
| 71 | ); |
| 72 | |
Austin Sullivan | 2b1e6e0 | 2022-12-07 18:10:20 | [diff] [blame] | 73 | } // namespace content::features |