value_store_change.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_VALUE_STORE_VALUE_STORE_CHANGE_H_
  5. #define COMPONENTS_VALUE_STORE_VALUE_STORE_CHANGE_H_
  6. #include <string>
  7. #include <vector>
  8. #include "base/memory/ref_counted.h"
  9. #include "base/values.h"
  10. #include "third_party/abseil-cpp/absl/types/optional.h"
  11. namespace value_store {
  12. struct ValueStoreChange;
  13. typedef std::vector<ValueStoreChange> ValueStoreChangeList;
  14. // A change to a setting.
  15. struct ValueStoreChange {
  16. // Converts an ValueStoreChangeList into base::Value of the form:
  17. // { "foo": { "key": "foo", "oldValue": "bar", "newValue": "baz" } }
  18. static base::Value ToValue(ValueStoreChangeList changes);
  19. ValueStoreChange(const std::string& key,
  20. absl::optional<base::Value> old_value,
  21. absl::optional<base::Value> new_value);
  22. ValueStoreChange(const ValueStoreChange& other) = delete;
  23. ValueStoreChange(ValueStoreChange&& other);
  24. ValueStoreChange& operator=(const ValueStoreChange& other) = delete;
  25. ValueStoreChange& operator=(ValueStoreChange&& other);
  26. ~ValueStoreChange();
  27. std::string key;
  28. absl::optional<base::Value> old_value;
  29. absl::optional<base::Value> new_value;
  30. };
  31. } // namespace value_store
  32. #endif // COMPONENTS_VALUE_STORE_VALUE_STORE_CHANGE_H_