buffet: Fix issues in StateChangeQueue
Addressed additional code review issues brought after the original
code has been published.
- NotifyPropertiesUpdated() now takes timestamp and property set
as separate parameters to simplify implementation of StateManager.
- StateChangeQueue::max_queue_size_ is made 'const'
- StateChangeQueue now maintains a time-to-event map instead of
a vector of StateChange. This allows to keep the events sorted
by time stamp. Also adding discrete events with the same time stamp
coalesces the property changes.
- added a unit test for coalescing property set changes based on
the timestamp.
BUG=None
TEST=FEATURES=test emerge-link buffet
Change-Id: I309816d1f040558620fa68a844b05251d0e4319b
Reviewed-on: https://chromium-review.googlesource.com/226300
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Anton Muhin <antonm@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/states/state_manager.h b/buffet/states/state_manager.h
index f17e8a6..53695e2 100644
--- a/buffet/states/state_manager.h
+++ b/buffet/states/state_manager.h
@@ -21,6 +21,7 @@
namespace base {
class DictionaryValue;
class FilePath;
+class Time;
} // namespace base
namespace buffet {
@@ -45,11 +46,7 @@
// name of the property to update in format "package.property".
bool SetPropertyValue(const std::string& full_property_name,
const chromeos::Any& value,
- chromeos::ErrorPtr* error);
-
- // Updates a number of state properties in one shot.
- // |property_set| is a (full_property_name)-to-(property_value) map.
- bool UpdateProperties(const chromeos::VariantDictionary& property_set,
+ const base::Time& timestamp,
chromeos::ErrorPtr* error);
// Returns all the categories the state properties are registered from.
@@ -64,11 +61,6 @@
std::vector<StateChange> GetAndClearRecordedStateChanges();
private:
- // Helper method to be used with SetPropertyValue() and UpdateProperties()
- bool UpdatePropertyValue(const std::string& full_property_name,
- const chromeos::Any& value,
- chromeos::ErrorPtr* error);
-
// Loads a device state fragment from a JSON object. |category| represents
// a device daemon providing the state fragment or empty string for the
// base state fragment.