OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 | |
5 #include "components/test_runner/tracked_dictionary.h" | |
6 | |
7 #include <memory> | |
dcheng
2016/03/08 23:09:37
Nit: utility (memory is for unique_ptr, which isn'
Łukasz Anforowicz
2016/03/10 22:24:21
Done. Thanks for pointing this out.
| |
8 | |
9 namespace test_runner { | |
10 | |
11 TrackedDictionary::TrackedDictionary() {} | |
12 | |
13 void TrackedDictionary::ResetChangeTracking() { | |
14 changed_values_.Clear(); | |
15 } | |
16 | |
17 void TrackedDictionary::ApplyUntrackedChanges( | |
18 const base::DictionaryValue& new_changes) { | |
19 current_values_.MergeDictionary(&new_changes); | |
20 | |
21 for (base::DictionaryValue::Iterator it(new_changes); !it.IsAtEnd(); | |
22 it.Advance()) { | |
23 changed_values_.Remove(it.key(), nullptr); | |
24 } | |
25 } | |
26 | |
27 void TrackedDictionary::Set(const std::string& path, | |
28 scoped_ptr<base::Value> new_value) { | |
29 // Is this truly a *new* value? | |
30 const base::Value* old_value; | |
31 if (current_values_.Get(path, &old_value)) { | |
32 if (base::Value::Equals(old_value, new_value.get())) | |
33 return; | |
34 } | |
35 | |
36 changed_values_.Set(path, new_value->CreateDeepCopy()); | |
37 current_values_.Set(path, std::move(new_value)); | |
38 } | |
39 | |
40 void TrackedDictionary::SetBoolean(const std::string& path, bool new_value) { | |
41 Set(path, make_scoped_ptr(new base::FundamentalValue(new_value))); | |
42 } | |
43 | |
44 } // namespace test_runner | |
OLD | NEW |