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" | 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 // All sizes are in bytes. Deprecated, please use BlobStorageLimits. | |
| 17 const int64_t kBlobStorageMaxMemoryUsage = 500 * 1024 * 1024; // Half a gig. | |
| 18 const size_t kBlobStorageIPCThresholdBytes = 250 * 1024; | |
| 19 const size_t kBlobStorageMaxSharedMemoryBytes = 10 * 1024 * 1024; | |
| 20 const uint64_t kBlobStorageMaxFileSizeBytes = 100 * 1024 * 1024; | |
| 21 const uint64_t kBlobStorageMinFileSizeBytes = 1 * 1024 * 1024; | |
| 22 const size_t kBlobStorageMaxBlobMemorySize = | |
| 23 kBlobStorageMaxMemoryUsage - kBlobStorageMinFileSizeBytes; | |
| 24 | |
| 25 // All sizes are in bytes. | 16 // All sizes are in bytes. |
| 26 struct BlobStorageLimits { | 17 struct BlobStorageLimits { |
| 27 size_t memory_limit_before_paging() const { | 18 size_t memory_limit_before_paging() const { |
| 28 return max_blob_in_memory_space - min_page_file_size; | 19 return max_blob_in_memory_space - min_page_file_size; |
| 29 } | 20 } |
| 30 | 21 |
| 31 // This is the maximum amount of memory we can send in an IPC. | 22 // This is the maximum amount of memory we can send in an IPC. |
| 32 size_t max_ipc_memory_size = 250 * 1024; | 23 size_t max_ipc_memory_size = 250 * 1024; |
| 33 // This is the maximum size of a shared memory handle. | 24 // This is the maximum size of a shared memory handle. |
| 34 size_t max_shared_memory_size = 10 * 1024 * 1024; | 25 size_t max_shared_memory_size = 10 * 1024 * 1024; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 48 }; | 39 }; |
| 49 | 40 |
| 50 enum class IPCBlobItemRequestStrategy { | 41 enum class IPCBlobItemRequestStrategy { |
| 51 UNKNOWN = 0, | 42 UNKNOWN = 0, |
| 52 IPC, | 43 IPC, |
| 53 SHARED_MEMORY, | 44 SHARED_MEMORY, |
| 54 FILE, | 45 FILE, |
| 55 LAST = FILE | 46 LAST = FILE |
| 56 }; | 47 }; |
| 57 | 48 |
| 58 // These items cannot be reordered or renumbered because they're recorded to | |
| 59 // UMA. New items must be added immediately before LAST, and LAST must be set to | |
| 60 // the the last item. | |
| 61 // DEPRECATED, please use BlobStatus instead. | |
| 62 enum class IPCBlobCreationCancelCode { | |
| 63 UNKNOWN = 0, | |
| 64 OUT_OF_MEMORY = 1, | |
| 65 // We couldn't create or write to a file. File system error, like a full disk. | |
| 66 FILE_WRITE_FAILED = 2, | |
| 67 // The renderer was destroyed while data was in transit. | |
| 68 SOURCE_DIED_IN_TRANSIT = 3, | |
| 69 // The renderer destructed the blob before it was done transferring, and there | |
| 70 // were no outstanding references (no one is waiting to read) to keep the | |
| 71 // blob alive. | |
| 72 BLOB_DEREFERENCED_WHILE_BUILDING = 4, | |
| 73 // A blob that we referenced during construction is broken, or a browser-side | |
| 74 // builder tries to build a blob with a blob reference that isn't finished | |
| 75 // constructing. | |
| 76 REFERENCED_BLOB_BROKEN = 5, | |
| 77 LAST = REFERENCED_BLOB_BROKEN | |
| 78 }; | |
| 79 | |
| 80 // This is the enum to rule them all in the blob system. | 49 // This is the enum to rule them all in the blob system. |
| 81 // These values are used in UMA metrics, so they should not be changed. Please | 50 // These values are used in UMA metrics, so they should not be changed. Please |
| 82 // update LAST_ERROR if you add an error condition and LAST if you add new | 51 // update LAST_ERROR if you add an error condition and LAST if you add new |
| 83 // state. | 52 // state. |
| 84 enum class BlobStatus { | 53 enum class BlobStatus { |
| 85 // Error case section: | 54 // Error case section: |
| 86 // The construction arguments are invalid. This is considered a bad ipc. | 55 // The construction arguments are invalid. This is considered a bad ipc. |
| 87 ERR_INVALID_CONSTRUCTION_ARGUMENTS = 0, | 56 ERR_INVALID_CONSTRUCTION_ARGUMENTS = 0, |
| 88 // We don't have enough memory for the blob. | 57 // We don't have enough memory for the blob. |
| 89 ERR_OUT_OF_MEMORY = 1, | 58 ERR_OUT_OF_MEMORY = 1, |
| 90 // We couldn't create or write to a file. File system error, like a full disk. | 59 // We couldn't create or write to a file. File system error, like a full disk. |
| 91 ERR_FILE_WRITE_FAILED = 2, | 60 ERR_FILE_WRITE_FAILED = 2, |
| 92 // The renderer was destroyed while data was in transit. | 61 // The renderer was destroyed while data was in transit. |
| 93 ERR_SOURCE_DIED_IN_TRANSIT = 3, | 62 ERR_SOURCE_DIED_IN_TRANSIT = 3, |
| 94 // The renderer destructed the blob before it was done transferring, and there | 63 // The renderer destructed the blob before it was done transferring, and there |
| 95 // were no outstanding references (no one is waiting to read) to keep the | 64 // were no outstanding references (no one is waiting to read) to keep the |
| 96 // blob alive. | 65 // blob alive. |
| 97 ERR_BLOB_DEREFERENCED_WHILE_BUILDING = 4, | 66 ERR_BLOB_DEREFERENCED_WHILE_BUILDING = 4, |
| 98 // A blob that we referenced during construction is broken, or a browser-side | 67 // A blob that we referenced during construction is broken, or a browser-side |
| 99 // builder tries to build a blob with a blob reference that isn't finished | 68 // builder tries to build a blob with a blob reference that isn't finished |
| 100 // constructing. | 69 // constructing. |
| 101 ERR_REFERENCED_BLOB_BROKEN = 5, | 70 ERR_REFERENCED_BLOB_BROKEN = 5, |
| 102 LAST_ERROR = ERR_REFERENCED_BLOB_BROKEN, | 71 LAST_ERROR = ERR_REFERENCED_BLOB_BROKEN, |
| 103 | 72 |
| 104 // Blob state section: | 73 // Blob state section: |
| 105 // The blob has finished. | 74 // The blob has finished. |
| 106 DONE = 200, | 75 DONE = 200, |
| 107 // The system is pending on quota being granted, the transport layer | 76 // The system is pending on quota being granted, the transport layer |
| 108 // populating pending data, and/or copying data from dependent blobs. See | 77 // populating pending data, and/or copying data from dependent blobs. See |
| 109 // InternalBlobData::BuildingState determine which of these are happening, as | 78 // InternalBlobData::BuildingState determine which of these are happening, as |
|
michaeln
2016/11/07 21:47:05
InternalBlobData is stale
dmurph
2016/11/08 21:19:59
Done.
| |
| 110 // they all can happen concurrently. | 79 // they all can happen concurrently. |
| 111 PENDING = 201, | 80 PENDING_QUOTA = 201, |
| 112 LAST = PENDING | 81 PENDING_TRANSPORT = 202, |
| 82 PENDING_INTERNALS = 203, | |
| 83 LAST = PENDING_INTERNALS | |
| 113 }; | 84 }; |
| 114 | 85 |
| 115 using BlobStatusCallback = base::Callback<void(BlobStatus)>; | 86 using BlobStatusCallback = base::Callback<void(BlobStatus)>; |
| 116 | 87 |
| 117 // Returns if the status is an error code. | 88 // Returns if the status is an error code. |
| 118 STORAGE_COMMON_EXPORT bool BlobStatusIsError(BlobStatus status); | 89 STORAGE_COMMON_EXPORT bool BlobStatusIsError(BlobStatus status); |
| 119 | 90 |
| 91 STORAGE_COMMON_EXPORT bool BlobStatusIsPending(BlobStatus status); | |
| 92 | |
| 120 // Returns if the status is a bad enough error to flag the IPC as bad. This is | 93 // Returns if the status is a bad enough error to flag the IPC as bad. This is |
| 121 // only INVALID_CONSTRUCTION_ARGUMENTS. | 94 // only INVALID_CONSTRUCTION_ARGUMENTS. |
| 95 // When a system gives a BadIPC status, it has already cleaned up & removed the | |
|
michaeln
2016/11/07 21:47:05
the comment about "already cleaned up" seems out o
dmurph
2016/11/08 21:19:59
Can't inline, it breaks builds.
| |
| 96 // blob internally. | |
| 122 STORAGE_COMMON_EXPORT bool BlobStatusIsBadIPC(BlobStatus status); | 97 STORAGE_COMMON_EXPORT bool BlobStatusIsBadIPC(BlobStatus status); |
| 123 | 98 |
| 124 } // namespace storage | 99 } // namespace storage |
| 125 | 100 |
| 126 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ | 101 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ |
| OLD | NEW |