Chromium Code Reviews| 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" | |
| 12 #include "storage/common/storage_common_export.h" | |
| 13 | |
| 11 namespace storage { | 14 namespace storage { |
| 12 | 15 |
| 16 // All sizes are in bytes. | |
| 13 // TODO(michaeln): use base::SysInfo::AmountOfPhysicalMemoryMB() in some | 17 // TODO(michaeln): use base::SysInfo::AmountOfPhysicalMemoryMB() in some |
| 14 // way to come up with a better limit. | 18 // way to come up with a better limit. |
| 15 const int64_t kBlobStorageMaxMemoryUsage = 500 * 1024 * 1024; // Half a gig. | 19 struct BlobStorageQuotas { |
|
michaeln
2016/08/23 01:31:55
not sure about calling this Quotas since that term
| |
| 16 const size_t kBlobStorageIPCThresholdBytes = 250 * 1024; | 20 size_t GetTotalMemorySpace() const { |
|
michaeln
2016/08/23 01:31:55
nit: total_memory_space()
| |
| 17 const size_t kBlobStorageMaxSharedMemoryBytes = 10 * 1024 * 1024; | 21 return max_blob_in_memory_space + in_flight_space; |
| 18 const uint64_t kBlobStorageMaxFileSizeBytes = 100 * 1024 * 1024; | 22 } |
| 19 const uint64_t kBlobStorageMinFileSizeBytes = 1 * 1024 * 1024; | 23 |
| 20 const size_t kBlobStorageMaxBlobMemorySize = | 24 // This is the maximum amount of memory we can send in an IPC. |
| 21 kBlobStorageMaxMemoryUsage - kBlobStorageMinFileSizeBytes; | 25 size_t max_ipc_memory_size = 250 * 1024; |
| 26 // This is the maximum size of a shared memory handle. | |
| 27 size_t max_shared_memory_size = 10 * 1024 * 1024; | |
| 28 | |
| 29 // This is the maximum amount of memory we can use to store blobs. | |
| 30 size_t max_blob_in_memory_space = 495 * 1024 * 1024; | |
| 31 // This is the maximum amount of extra memory we can temporarily allocate | |
| 32 // towards blob items that we're currently writing to disk. | |
| 33 size_t in_flight_space = 5 * 1024 * 1024; | |
| 34 | |
| 35 // This is the maximum amount of disk space we can use. | |
| 36 uint64_t max_blob_disk_space = 5ull * 1024 * 1024 * 1024; | |
| 37 | |
| 38 // This is the minimum file size we can use when paging blob items to disk. | |
| 39 // We combine items until we reach at least this size. | |
| 40 uint64_t min_page_file_size = 5 * 1024 * 1024; | |
| 41 // This is the maximum file size we can create. | |
| 42 uint64_t max_file_size = 100 * 1024 * 1024; | |
| 43 }; | |
| 22 | 44 |
| 23 enum class IPCBlobItemRequestStrategy { | 45 enum class IPCBlobItemRequestStrategy { |
| 24 UNKNOWN = 0, | 46 UNKNOWN = 0, |
| 25 IPC, | 47 IPC, |
| 26 SHARED_MEMORY, | 48 SHARED_MEMORY, |
| 27 FILE, | 49 FILE, |
| 28 LAST = FILE | 50 LAST = FILE |
| 29 }; | 51 }; |
| 30 | 52 |
| 31 // These items cannot be reordered or renumbered because they're recorded to | 53 // This is the enum to rule them all in the blob system. |
| 32 // UMA. New items must be added immediately before LAST, and LAST must be set to | 54 // These values are used in UMA metrics, so they should not be changed. Please |
| 33 // the the last item. | 55 // update LAST_ERROR if you add an error condition and LAST if you add new |
| 34 enum class IPCBlobCreationCancelCode { | 56 // state. |
| 35 UNKNOWN = 0, | 57 enum class BlobStatus { |
| 36 OUT_OF_MEMORY = 1, | 58 // Error case section: |
| 59 // The construction arguments are invalid. This is considered a bad ipc. | |
| 60 ERR_INVALID_CONSTRUCTION_ARGUMENTS = 0, | |
| 61 // We don't have enough memory for the blob. | |
| 62 ERR_OUT_OF_MEMORY = 1, | |
| 37 // We couldn't create or write to a file. File system error, like a full disk. | 63 // We couldn't create or write to a file. File system error, like a full disk. |
| 38 FILE_WRITE_FAILED = 2, | 64 ERR_FILE_WRITE_FAILED = 2, |
| 39 // The renderer was destroyed while data was in transit. | 65 // The renderer was destroyed while data was in transit. |
| 40 SOURCE_DIED_IN_TRANSIT = 3, | 66 ERR_SOURCE_DIED_IN_TRANSIT = 3, |
| 41 // The renderer destructed the blob before it was done transferring, and there | 67 // The renderer destructed the blob before it was done transferring, and there |
| 42 // were no outstanding references (no one is waiting to read) to keep the | 68 // were no outstanding references (no one is waiting to read) to keep the |
| 43 // blob alive. | 69 // blob alive. |
| 44 BLOB_DEREFERENCED_WHILE_BUILDING = 4, | 70 ERR_BLOB_DEREFERENCED_WHILE_BUILDING = 4, |
| 45 // A blob that we referenced during construction is broken, or a browser-side | 71 // A blob that we referenced during construction is broken, or a browser-side |
| 46 // builder tries to build a blob with a blob reference that isn't finished | 72 // builder tries to build a blob with a blob reference that isn't finished |
| 47 // constructing. | 73 // constructing. |
| 48 REFERENCED_BLOB_BROKEN = 5, | 74 ERR_REFERENCED_BLOB_BROKEN = 5, |
| 49 LAST = REFERENCED_BLOB_BROKEN | 75 LAST_ERROR = ERR_REFERENCED_BLOB_BROKEN, |
| 76 | |
| 77 // Blob state section: | |
| 78 // The blob is finished constructing. | |
| 79 DONE = 200, | |
| 80 // The system is pending on quota being granted, the transport layer | |
| 81 // populating pending data, and/or copying data from dependent blobs. See | |
| 82 // InternalBlobData::BuildingState determine which of these are happening, as | |
| 83 // they all can happen concurrently. | |
| 84 PENDING = 201, | |
| 85 LAST = PENDING | |
| 50 }; | 86 }; |
| 51 | 87 |
| 88 using BlobStatusCallback = base::Callback<void(BlobStatus)>; | |
| 89 | |
| 90 // Returns if the status is an error code. | |
| 91 STORAGE_COMMON_EXPORT bool BlobStatusIsError(BlobStatus status); | |
| 92 | |
| 93 // Returns if the status is a bad enough error to flag the IPC as bad. This is | |
| 94 // only INVALID_CONSTRUCTION_ARGUMENTS. | |
| 95 STORAGE_COMMON_EXPORT bool BlobStatusIsBadIPC(BlobStatus status); | |
| 96 | |
| 52 } // namespace storage | 97 } // namespace storage |
| 53 | 98 |
| 54 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ | 99 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ |
| OLD | NEW |