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 |
13 // TODO(michaeln): use base::SysInfo::AmountOfPhysicalMemoryMB() in some | 16 // TODO(michaeln): use base::SysInfo::AmountOfPhysicalMemoryMB() in some |
14 // way to come up with a better limit. | 17 // way to come up with a better limit. |
15 const int64_t kBlobStorageMaxMemoryUsage = 500 * 1024 * 1024; // Half a gig. | 18 const int64_t kBlobStorageMaxMemoryUsage = 500 * 1024 * 1024; // Half a gig. |
19 | |
16 const size_t kBlobStorageIPCThresholdBytes = 250 * 1024; | 20 const size_t kBlobStorageIPCThresholdBytes = 250 * 1024; |
17 const size_t kBlobStorageMaxSharedMemoryBytes = 10 * 1024 * 1024; | 21 const size_t kBlobStorageMaxSharedMemoryBytes = 10 * 1024 * 1024; |
18 const uint64_t kBlobStorageMaxFileSizeBytes = 100 * 1024 * 1024; | 22 const uint64_t kBlobStorageMaxFileSizeBytes = 100 * 1024 * 1024; |
19 const uint64_t kBlobStorageMinFileSizeBytes = 1 * 1024 * 1024; | 23 const uint64_t kBlobStorageMinFileSizeBytes = 5 * 1024 * 1024; |
20 const size_t kBlobStorageMaxBlobMemorySize = | 24 const size_t kBlobStorageMaxBlobMemorySize = |
21 kBlobStorageMaxMemoryUsage - kBlobStorageMinFileSizeBytes; | 25 kBlobStorageMaxMemoryUsage - kBlobStorageMinFileSizeBytes; |
26 const uint64_t kBlobStorageInFlightMemory = kBlobStorageMinFileSizeBytes; | |
27 const uint64_t kBlobStorageMaxDiskSpace = 5ull * 1024 * 1024 * 1024; // 5 gigs. | |
kinuko
2016/07/17 16:15:47
Bytes, Size, Space, or just Memory-- the terms use
dmurph
2016/07/19 02:26:28
I'll use Bytes and Space. Space is for quotas, Byt
| |
22 | 28 |
23 enum class IPCBlobItemRequestStrategy { | 29 enum class IPCBlobItemRequestStrategy { |
24 UNKNOWN = 0, | 30 UNKNOWN = 0, |
25 IPC, | 31 IPC, |
26 SHARED_MEMORY, | 32 SHARED_MEMORY, |
27 FILE, | 33 FILE, |
28 LAST = FILE | 34 LAST = FILE |
29 }; | 35 }; |
30 | 36 |
31 // These items cannot be reordered or renumbered because they're recorded to | 37 // 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 | 38 // These values are used in UMA metrics, so they should not be changed. Please |
33 // the the last item. | 39 // update LAST_ERROR if you add an error condition and LAST if you add new |
34 enum class IPCBlobCreationCancelCode { | 40 // state. |
35 UNKNOWN = 0, | 41 enum class BlobStatus { |
42 // Error case section: | |
43 // The construction arguments are invalid. | |
44 INVALID_CONSTRUCTION_ARGUMENTS = 0, | |
45 // We don't have enough memory for the blob. | |
36 OUT_OF_MEMORY = 1, | 46 OUT_OF_MEMORY = 1, |
37 // We couldn't create or write to a file. File system error, like a full disk. | 47 // We couldn't create or write to a file. File system error, like a full disk. |
38 FILE_WRITE_FAILED = 2, | 48 FILE_WRITE_FAILED = 2, |
39 // The renderer was destroyed while data was in transit. | 49 // The renderer was destroyed while data was in transit. |
40 SOURCE_DIED_IN_TRANSIT = 3, | 50 SOURCE_DIED_IN_TRANSIT = 3, |
41 // The renderer destructed the blob before it was done transferring, and there | 51 // 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 | 52 // were no outstanding references (no one is waiting to read) to keep the |
43 // blob alive. | 53 // blob alive. |
44 BLOB_DEREFERENCED_WHILE_BUILDING = 4, | 54 BLOB_DEREFERENCED_WHILE_BUILDING = 4, |
45 // A blob that we referenced during construction is broken, or a browser-side | 55 // 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 | 56 // builder tries to build a blob with a blob reference that isn't finished |
47 // constructing. | 57 // constructing. |
48 REFERENCED_BLOB_BROKEN = 5, | 58 REFERENCED_BLOB_BROKEN = 5, |
kinuko
2016/07/17 16:15:47
I'm a bit concerned about using the same enum for
dmurph
2016/07/19 02:26:28
Done.
| |
49 LAST = REFERENCED_BLOB_BROKEN | 59 LAST_ERROR = REFERENCED_BLOB_BROKEN, |
60 | |
61 // Blob state section: | |
62 // The blob is finished constructing. | |
63 DONE = 200, | |
64 // The system is pending on memory quota from the BlobMemoryController. | |
65 PENDING_MEMORY_QUOTA = 201, | |
66 // The system is pending on the transport layer populating data and/or copies | |
67 // from other blobs. | |
68 PENDING_DATA_POPULATION = 202, | |
69 LAST = PENDING_DATA_POPULATION | |
50 }; | 70 }; |
51 | 71 |
72 using BlobStatusCallback = base::Callback<void(BlobStatus)>; | |
73 | |
74 // Returns if the status is an error code. | |
75 STORAGE_COMMON_EXPORT bool BlobStatusIsError(BlobStatus status); | |
76 | |
77 // Returns if the status is a bad enough error to flag the IPC as bad. | |
78 STORAGE_COMMON_EXPORT bool BlobStatusIsBadIPC(BlobStatus status); | |
79 | |
80 // Returns if the status is 'PENDING'. | |
81 STORAGE_COMMON_EXPORT bool BlobStatusIsPending(BlobStatus status); | |
82 | |
52 } // namespace storage | 83 } // namespace storage |
53 | 84 |
54 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ | 85 #endif // STORAGE_COMMON_BLOB_STORAGE_BLOB_STORAGE_CONSTANTS_H_ |
OLD | NEW |