Add ability to join two ScopedReservation's.
Bug: b:233089187
Change-Id: I7989de7982d31b45be1806bf14c22737a5ef4c82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3703493
Reviewed-by: Hong Xu <[email protected]>
Commit-Queue: Leonid Baraz <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1014255}
diff --git a/components/reporting/resources/resource_interface.h b/components/reporting/resources/resource_interface.h
index 235f42f..56fd3bce 100644
--- a/components/reporting/resources/resource_interface.h
+++ b/components/reporting/resources/resource_interface.h
@@ -60,16 +60,26 @@
// Can be handed over to another owner.
class ScopedReservation {
public:
- ScopedReservation(uint64_t size,
- scoped_refptr<ResourceInterface> resource_interface);
- ScopedReservation(ScopedReservation&& other);
+ ScopedReservation(
+ uint64_t size,
+ scoped_refptr<ResourceInterface> resource_interface) noexcept;
+ ScopedReservation(ScopedReservation&& other) noexcept;
ScopedReservation(const ScopedReservation& other) = delete;
+ ScopedReservation& operator=(ScopedReservation&& other) = delete;
ScopedReservation& operator=(const ScopedReservation& other) = delete;
~ScopedReservation();
bool reserved() const;
+
+ // Reduces reservation to |new_size|.
bool Reduce(uint64_t new_size);
+ // Adds |other| to |this| without assigning or releasing any reservation.
+ // Used for seamless transition from one reservation to another (more generic
+ // than std::move). Resets |other| to non-reserved state upon return from this
+ // method.
+ void HandOver(ScopedReservation& other);
+
private:
const scoped_refptr<ResourceInterface> resource_interface_;
absl::optional<uint64_t> size_;