// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_VALUE_STORE_VALUE_STORE_CHANGE_H_ #define CHROME_BROWSER_VALUE_STORE_VALUE_STORE_CHANGE_H_ #include #include #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" class ValueStoreChange; typedef std::vector ValueStoreChangeList; // A change to a setting. Safe/efficient to copy. class ValueStoreChange { public: // Converts an ValueStoreChangeList into JSON of the form: // { "foo": { "key": "foo", "oldValue": "bar", "newValue": "baz" } } static std::string ToJson(const ValueStoreChangeList& changes); // Ownership of |old_value| and |new_value| taken. ValueStoreChange( const std::string& key, base::Value* old_value, base::Value* new_value); ~ValueStoreChange(); // Gets the key of the setting which changed. const std::string& key() const; // Gets the value of the setting before the change, or NULL if there was no // old value. const base::Value* old_value() const; // Gets the value of the setting after the change, or NULL if there is no new // value. const base::Value* new_value() const; private: class Inner : public base::RefCountedThreadSafe { public: Inner( const std::string& key, base::Value* old_value, base::Value* new_value); const std::string key_; const scoped_ptr old_value_; const scoped_ptr new_value_; private: friend class base::RefCountedThreadSafe; virtual ~Inner(); }; scoped_refptr inner_; }; #endif // CHROME_BROWSER_VALUE_STORE_VALUE_STORE_CHANGE_H_