• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef COMPONENTS_METRICS_STRUCTURED_LIB_RESOURCE_INFO_H_
6 #define COMPONENTS_METRICS_STRUCTURED_LIB_RESOURCE_INFO_H_
7 
8 #include <cstdint>
9 
10 namespace metrics::structured {
11 // The current usage and limits of some recourse.
12 //
13 // These resources could be disk space or memory consumption.
14 struct ResourceInfo {
15   uint64_t used_size_bytes = 0;
16   uint64_t max_size_bytes = 0;
17 
18   explicit ResourceInfo(uint64_t max_size_bytes);
19 
20   // Check whether |this| can accommodate |size|.
21   bool HasRoom(uint64_t size_bytes) const;
22 
23   // Increases currently used space with |size|.
24   bool Consume(uint64_t size_bytes);
25 };
26 }  // namespace metrics::structured
27 
28 #endif  // COMPONENTS_METRICS_STRUCTURED_LIB_RESOURCE_INFO_H_
29