• 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 #include "components/metrics/structured/lib/resource_info.h"
6 
7 #include <cstdint>
8 
9 namespace metrics::structured {
10 
ResourceInfo(uint64_t max_size_bytes)11 ResourceInfo::ResourceInfo(uint64_t max_size_bytes)
12     : max_size_bytes(max_size_bytes) {}
13 
HasRoom(uint64_t size_bytes) const14 bool ResourceInfo::HasRoom(uint64_t size_bytes) const {
15   return used_size_bytes + size_bytes <= max_size_bytes;
16 }
17 
Consume(uint64_t size_bytes)18 bool ResourceInfo::Consume(uint64_t size_bytes) {
19   used_size_bytes += size_bytes;
20   return used_size_bytes <= max_size_bytes;
21 }
22 }  // namespace metrics::structured
23