Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / extensions / browser / value_store / value_store_change.h
blob4c03cc3645985dc8a9495952c371ee4a0455f14f
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.
5 #ifndef EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_CHANGE_H_
6 #define EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_CHANGE_H_
8 #include <string>
9 #include <vector>
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 {
20 public:
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.
26 ValueStoreChange(
27 const std::string& key, base::Value* old_value, base::Value* new_value);
29 ~ValueStoreChange();
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
35 // old value.
36 const base::Value* old_value() const;
38 // Gets the value of the setting after the change, or NULL if there is no new
39 // value.
40 const base::Value* new_value() const;
42 private:
43 class Inner : public base::RefCountedThreadSafe<Inner> {
44 public:
45 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_;
52 private:
53 friend class base::RefCountedThreadSafe<Inner>;
54 virtual ~Inner();
57 scoped_refptr<Inner> inner_;
60 #endif // EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_CHANGE_H_