| Index: storage/common/blob_storage/blob_storage_constants.h
|
| diff --git a/storage/common/blob_storage/blob_storage_constants.h b/storage/common/blob_storage/blob_storage_constants.h
|
| index 0fc10c583cee8031d3b8159adb45d87d2caf99b7..98a46ad0c09ba8a29e9074515697b2ef6b90b860 100644
|
| --- a/storage/common/blob_storage/blob_storage_constants.h
|
| +++ b/storage/common/blob_storage/blob_storage_constants.h
|
| @@ -8,10 +8,12 @@
|
| #include <stddef.h>
|
| #include <stdint.h>
|
|
|
| +#include "base/callback_forward.h"
|
| +#include "storage/common/storage_common_export.h"
|
| +
|
| namespace storage {
|
|
|
| -// TODO(michaeln): use base::SysInfo::AmountOfPhysicalMemoryMB() in some
|
| -// way to come up with a better limit.
|
| +// All sizes are in bytes. Deprecated, please use BlobStorageLimits.
|
| const int64_t kBlobStorageMaxMemoryUsage = 500 * 1024 * 1024; // Half a gig.
|
| const size_t kBlobStorageIPCThresholdBytes = 250 * 1024;
|
| const size_t kBlobStorageMaxSharedMemoryBytes = 10 * 1024 * 1024;
|
| @@ -20,6 +22,33 @@ const uint64_t kBlobStorageMinFileSizeBytes = 1 * 1024 * 1024;
|
| const size_t kBlobStorageMaxBlobMemorySize =
|
| kBlobStorageMaxMemoryUsage - kBlobStorageMinFileSizeBytes;
|
|
|
| +// All sizes are in bytes.
|
| +struct BlobStorageLimits {
|
| + size_t total_memory_space() const {
|
| + return max_blob_in_memory_space + in_flight_space;
|
| + }
|
| +
|
| + // This is the maximum amount of memory we can send in an IPC.
|
| + size_t max_ipc_memory_size = 250 * 1024;
|
| + // This is the maximum size of a shared memory handle.
|
| + size_t max_shared_memory_size = 10 * 1024 * 1024;
|
| +
|
| + // This is the maximum amount of memory we can use to store blobs.
|
| + size_t max_blob_in_memory_space = 495 * 1024 * 1024;
|
| + // This is the maximum amount of extra memory we can temporarily allocate
|
| + // towards blob items that we're currently writing to disk.
|
| + size_t in_flight_space = 5 * 1024 * 1024;
|
| +
|
| + // This is the maximum amount of disk space we can use.
|
| + uint64_t max_blob_disk_space = 5ull * 1024 * 1024 * 1024;
|
| +
|
| + // This is the minimum file size we can use when paging blob items to disk.
|
| + // We combine items until we reach at least this size.
|
| + uint64_t min_page_file_size = 5 * 1024 * 1024;
|
| + // This is the maximum file size we can create.
|
| + uint64_t max_file_size = 100 * 1024 * 1024;
|
| +};
|
| +
|
| enum class IPCBlobItemRequestStrategy {
|
| UNKNOWN = 0,
|
| IPC,
|
| @@ -31,6 +60,7 @@ enum class IPCBlobItemRequestStrategy {
|
| // These items cannot be reordered or renumbered because they're recorded to
|
| // UMA. New items must be added immediately before LAST, and LAST must be set to
|
| // the the last item.
|
| +// DEPRECATED, please use BlobStatus instead.
|
| enum class IPCBlobCreationCancelCode {
|
| UNKNOWN = 0,
|
| OUT_OF_MEMORY = 1,
|
| @@ -49,6 +79,50 @@ enum class IPCBlobCreationCancelCode {
|
| LAST = REFERENCED_BLOB_BROKEN
|
| };
|
|
|
| +// This is the enum to rule them all in the blob system.
|
| +// These values are used in UMA metrics, so they should not be changed. Please
|
| +// update LAST_ERROR if you add an error condition and LAST if you add new
|
| +// state.
|
| +enum class BlobStatus {
|
| + // Error case section:
|
| + // The construction arguments are invalid. This is considered a bad ipc.
|
| + ERR_INVALID_CONSTRUCTION_ARGUMENTS = 0,
|
| + // We don't have enough memory for the blob.
|
| + ERR_OUT_OF_MEMORY = 1,
|
| + // We couldn't create or write to a file. File system error, like a full disk.
|
| + ERR_FILE_WRITE_FAILED = 2,
|
| + // The renderer was destroyed while data was in transit.
|
| + ERR_SOURCE_DIED_IN_TRANSIT = 3,
|
| + // The renderer destructed the blob before it was done transferring, and there
|
| + // were no outstanding references (no one is waiting to read) to keep the
|
| + // blob alive.
|
| + ERR_BLOB_DEREFERENCED_WHILE_BUILDING = 4,
|
| + // A blob that we referenced during construction is broken, or a browser-side
|
| + // builder tries to build a blob with a blob reference that isn't finished
|
| + // constructing.
|
| + ERR_REFERENCED_BLOB_BROKEN = 5,
|
| + LAST_ERROR = ERR_REFERENCED_BLOB_BROKEN,
|
| +
|
| + // Blob state section:
|
| + // The blob has finished.
|
| + DONE = 200,
|
| + // The system is pending on quota being granted, the transport layer
|
| + // populating pending data, and/or copying data from dependent blobs. See
|
| + // InternalBlobData::BuildingState determine which of these are happening, as
|
| + // they all can happen concurrently.
|
| + PENDING = 201,
|
| + LAST = PENDING
|
| +};
|
| +
|
| +using BlobStatusCallback = base::Callback<void(BlobStatus)>;
|
| +
|
| +// Returns if the status is an error code.
|
| +STORAGE_COMMON_EXPORT bool BlobStatusIsError(BlobStatus status);
|
| +
|
| +// Returns if the status is a bad enough error to flag the IPC as bad. This is
|
| +// only INVALID_CONSTRUCTION_ARGUMENTS.
|
| +STORAGE_COMMON_EXPORT bool BlobStatusIsBadIPC(BlobStatus status);
|
| +
|
| } // namespace storage
|
|
|
| #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_
|
|
|