1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_VALUE_STORE_VALUE_STORE_CHANGE_H_
6 #define CHROME_BROWSER_VALUE_STORE_VALUE_STORE_CHANGE_H_
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h"
15 class ValueStoreChange
;
16 typedef std::vector
<ValueStoreChange
> ValueStoreChangeList
;
18 // A change to a setting. Safe/efficient to copy.
19 class ValueStoreChange
{
21 // Converts an ValueStoreChangeList into JSON of the form:
22 // { "foo": { "key": "foo", "oldValue": "bar", "newValue": "baz" } }
23 static std::string
ToJson(const ValueStoreChangeList
& changes
);
25 // Ownership of |old_value| and |new_value| taken.
27 const std::string
& key
, base::Value
* old_value
, base::Value
* new_value
);
31 // Gets the key of the setting which changed.
32 const std::string
& key() const;
34 // Gets the value of the setting before the change, or NULL if there was no
36 const base::Value
* old_value() const;
38 // Gets the value of the setting after the change, or NULL if there is no new
40 const base::Value
* new_value() const;
43 class Inner
: public base::RefCountedThreadSafe
<Inner
> {
46 const std::string
& key
, base::Value
* old_value
, base::Value
* new_value
);
48 const std::string key_
;
49 const scoped_ptr
<base::Value
> old_value_
;
50 const scoped_ptr
<base::Value
> new_value_
;
53 friend class base::RefCountedThreadSafe
<Inner
>;
57 scoped_refptr
<Inner
> inner_
;
60 #endif // CHROME_BROWSER_VALUE_STORE_VALUE_STORE_CHANGE_H_