OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/browser/value_store/value_store_change.h" | 5 #include "extensions/browser/value_store/value_store_change.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 | 12 |
13 // static | 13 // static |
14 std::string ValueStoreChange::ToJson( | 14 std::string ValueStoreChange::ToJson( |
15 const ValueStoreChangeList& changes) { | 15 const ValueStoreChangeList& changes) { |
16 base::DictionaryValue changes_value; | 16 base::DictionaryValue changes_value; |
17 for (ValueStoreChangeList::const_iterator it = changes.begin(); | 17 for (ValueStoreChangeList::const_iterator it = changes.begin(); |
18 it != changes.end(); ++it) { | 18 it != changes.end(); ++it) { |
19 std::unique_ptr<base::DictionaryValue> change_value = | 19 std::unique_ptr<base::DictionaryValue> change_value = |
20 base::MakeUnique<base::DictionaryValue>(); | 20 base::MakeUnique<base::DictionaryValue>(); |
21 if (it->old_value()) { | 21 if (it->old_value()) { |
22 change_value->Set("oldValue", it->old_value()->DeepCopy()); | 22 change_value->Set("oldValue", |
| 23 base::MakeUnique<base::Value>(*it->old_value())); |
23 } | 24 } |
24 if (it->new_value()) { | 25 if (it->new_value()) { |
25 change_value->Set("newValue", it->new_value()->DeepCopy()); | 26 change_value->Set("newValue", |
| 27 base::MakeUnique<base::Value>(*it->new_value())); |
26 } | 28 } |
27 changes_value.SetWithoutPathExpansion(it->key(), std::move(change_value)); | 29 changes_value.SetWithoutPathExpansion(it->key(), std::move(change_value)); |
28 } | 30 } |
29 std::string json; | 31 std::string json; |
30 bool success = base::JSONWriter::Write(changes_value, &json); | 32 bool success = base::JSONWriter::Write(changes_value, &json); |
31 DCHECK(success); | 33 DCHECK(success); |
32 return json; | 34 return json; |
33 } | 35 } |
34 | 36 |
35 ValueStoreChange::ValueStoreChange(const std::string& key, | 37 ValueStoreChange::ValueStoreChange(const std::string& key, |
(...skipping 21 matching lines...) Expand all Loading... |
57 } | 59 } |
58 | 60 |
59 ValueStoreChange::Inner::Inner(const std::string& key, | 61 ValueStoreChange::Inner::Inner(const std::string& key, |
60 std::unique_ptr<base::Value> old_value, | 62 std::unique_ptr<base::Value> old_value, |
61 std::unique_ptr<base::Value> new_value) | 63 std::unique_ptr<base::Value> new_value) |
62 : key_(key), | 64 : key_(key), |
63 old_value_(std::move(old_value)), | 65 old_value_(std::move(old_value)), |
64 new_value_(std::move(new_value)) {} | 66 new_value_(std::move(new_value)) {} |
65 | 67 |
66 ValueStoreChange::Inner::~Inner() {} | 68 ValueStoreChange::Inner::~Inner() {} |
OLD | NEW |