Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: services/resource_coordinator/coordination_unit/coordination_unit_impl.cc

Issue 2917793002: [GRC] Coordination Unit Key-Value Storage (Closed)
Patch Set: Fix comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/resource_coordinator/coordination_unit/coordination_unit_impl.cc
diff --git a/services/resource_coordinator/coordination_unit/coordination_unit_impl.cc b/services/resource_coordinator/coordination_unit/coordination_unit_impl.cc
index 034b9e42aebe4a11c7be689d2194e9590f3955d4..7f37d358d2800c5aca1d9f8033630fc5d3df0c59 100644
--- a/services/resource_coordinator/coordination_unit/coordination_unit_impl.cc
+++ b/services/resource_coordinator/coordination_unit/coordination_unit_impl.cc
@@ -216,4 +216,30 @@ double CoordinationUnitImpl::GetCPUUsageForTesting() {
return kCPUUsageUnmeasuredForTesting;
}
+base::Value CoordinationUnitImpl::GetProperty(mojom::PropertyType property) {
+ auto value_it = property_store_.find(property);
+
+ return value_it != property_store_.end() ? value_it->second : base::Value();
+}
+
+void CoordinationUnitImpl::ClearProperty(mojom::PropertyType property) {
+ property_store_.erase(property);
+}
+
+void CoordinationUnitImpl::SetProperty(mojom::PropertyPtr property) {
+ SetProperty(property->property, *property->value);
+}
+
+void CoordinationUnitImpl::SetProperty(mojom::PropertyType property,
+ base::Value value) {
+ // setting a property with an empty value is effectively clearing the
+ // value from storage
+ if (value.IsType(base::Value::Type::NONE)) {
+ ClearProperty(property);
+ return;
+ }
+
+ property_store_[property] = value;
+}
+
} // namespace resource_coordinator

Powered by Google App Engine
This is Rietveld 408576698