OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ | 5 #ifndef STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ |
6 #define STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ | 6 #define STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "storage/common/storage_common_export.h" | 12 #include "storage/common/storage_common_export.h" |
13 | 13 |
14 namespace storage { | 14 namespace storage { |
15 | 15 |
| 16 constexpr size_t kDefaultIPCMemorySize = 250u * 1024; |
| 17 constexpr size_t kDefaultSharedMemorySize = 10u * 1024 * 1024; |
| 18 constexpr size_t kDefaultMaxBlobInMemorySpace = 500u * 1024 * 1024; |
| 19 constexpr uint64_t kDefaultMaxBlobDiskSpace = 0ull; |
| 20 constexpr uint64_t kDefaultMinPageFileSize = 5ull * 1024 * 1024; |
| 21 constexpr uint64_t kDefaultMaxPageFileSize = 100ull * 1024 * 1024; |
| 22 |
16 // All sizes are in bytes. | 23 // All sizes are in bytes. |
17 struct BlobStorageLimits { | 24 struct STORAGE_COMMON_EXPORT BlobStorageLimits { |
| 25 // Returns if the current configuration is valid. |
| 26 bool IsValid() const; |
| 27 |
18 size_t memory_limit_before_paging() const { | 28 size_t memory_limit_before_paging() const { |
19 return max_blob_in_memory_space - min_page_file_size; | 29 return max_blob_in_memory_space - min_page_file_size; |
20 } | 30 } |
21 | 31 |
| 32 // If disk space goes less than this we stop allocating more disk quota. |
| 33 uint64_t min_available_external_disk_space() const { |
| 34 return 2ull * memory_limit_before_paging(); |
| 35 } |
| 36 |
| 37 bool IsDiskSpaceConstrained() const { |
| 38 return desired_max_disk_space != effective_max_disk_space; |
| 39 } |
| 40 |
22 // This is the maximum amount of memory we can send in an IPC. | 41 // This is the maximum amount of memory we can send in an IPC. |
23 size_t max_ipc_memory_size = 250 * 1024; | 42 size_t max_ipc_memory_size = kDefaultIPCMemorySize; |
24 // This is the maximum size of a shared memory handle. | 43 // This is the maximum size of a shared memory handle. |
25 size_t max_shared_memory_size = 10 * 1024 * 1024; | 44 size_t max_shared_memory_size = kDefaultSharedMemorySize; |
26 | 45 |
27 // This is the maximum amount of memory we can use to store blobs. | 46 // This is the maximum amount of memory we can use to store blobs. |
28 size_t max_blob_in_memory_space = 500 * 1024 * 1024; | 47 size_t max_blob_in_memory_space = kDefaultMaxBlobInMemorySpace; |
29 | 48 |
30 // This is the maximum amount of disk space we can use. | 49 // This is the maximum amount of disk space we can use. |
31 // TODO(dmurph): Determine initial heuristic based on disk usage & arch. | 50 uint64_t desired_max_disk_space = kDefaultMaxBlobDiskSpace; |
32 uint64_t max_blob_disk_space = 0ull; | 51 // This value will change based on the amount of free space on the device. |
| 52 uint64_t effective_max_disk_space = kDefaultMaxBlobDiskSpace; |
33 | 53 |
34 // This is the minimum file size we can use when paging blob items to disk. | 54 // This is the minimum file size we can use when paging blob items to disk. |
35 // We combine items until we reach at least this size. | 55 // We combine items until we reach at least this size. |
36 uint64_t min_page_file_size = 5 * 1024 * 1024; | 56 uint64_t min_page_file_size = kDefaultMinPageFileSize; |
37 // This is the maximum file size we can create. | 57 // This is the maximum file size we can create. |
38 uint64_t max_file_size = 100 * 1024 * 1024; | 58 uint64_t max_file_size = kDefaultMaxPageFileSize; |
39 }; | 59 }; |
40 | 60 |
41 enum class IPCBlobItemRequestStrategy { | 61 enum class IPCBlobItemRequestStrategy { |
42 UNKNOWN = 0, | 62 UNKNOWN = 0, |
43 IPC, | 63 IPC, |
44 SHARED_MEMORY, | 64 SHARED_MEMORY, |
45 FILE, | 65 FILE, |
46 LAST = FILE | 66 LAST = FILE |
47 }; | 67 }; |
48 | 68 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 111 |
92 STORAGE_COMMON_EXPORT bool BlobStatusIsPending(BlobStatus status); | 112 STORAGE_COMMON_EXPORT bool BlobStatusIsPending(BlobStatus status); |
93 | 113 |
94 // Returns if the status is a bad enough error to flag the IPC as bad. This is | 114 // Returns if the status is a bad enough error to flag the IPC as bad. This is |
95 // only INVALID_CONSTRUCTION_ARGUMENTS. | 115 // only INVALID_CONSTRUCTION_ARGUMENTS. |
96 STORAGE_COMMON_EXPORT bool BlobStatusIsBadIPC(BlobStatus status); | 116 STORAGE_COMMON_EXPORT bool BlobStatusIsBadIPC(BlobStatus status); |
97 | 117 |
98 } // namespace storage | 118 } // namespace storage |
99 | 119 |
100 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ | 120 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ |
OLD | NEW |