buffet: Add state change ID to state queue
Each state update will now increment a state change ID to help correlate
device state and command updates.
Right now, each call to NotifyPropertiesUpdated() will increment the ID.
This functionality will be used in subsequent CLs to implement ordering
of state and command updates on GCD server.
BUG=brillo:1202
TEST=`FEATURES=test emerge-link buffet`
Change-Id: I8cd591ec83cef7c1f1019728c0492fdee23d64dc
Reviewed-on: https://chromium-review.googlesource.com/282081
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/states/state_change_queue.h b/buffet/states/state_change_queue.h
index 9181ef4..83161fe 100644
--- a/buffet/states/state_change_queue.h
+++ b/buffet/states/state_change_queue.h
@@ -26,6 +26,7 @@
base::Time timestamp,
native_types::Object changed_properties) override;
std::vector<StateChange> GetAndClearRecordedStateChanges() override;
+ UpdateID GetLastStateChangeId() const override { return last_change_id_; }
private:
// To make sure we do not call NotifyPropertiesUpdated() and
@@ -40,6 +41,10 @@
// Accumulated list of device state change notifications.
std::map<base::Time, native_types::Object> state_changes_;
+ // An ID of last state change update. Each NotifyPropertiesUpdated()
+ // invocation increments this value by 1.
+ UpdateID last_change_id_{0};
+
DISALLOW_COPY_AND_ASSIGN(StateChangeQueue);
};