Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: components/test_runner/tracked_dictionary.cc

Issue 2707183003: Move //components/test_runner back into //content/shell (Closed)
Patch Set: Trim DEPS Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <utility>
8
9 #include "base/memory/ptr_util.h"
10
11 namespace test_runner {
12
13 TrackedDictionary::TrackedDictionary() {}
14
15 void TrackedDictionary::ResetChangeTracking() {
16 changed_values_.Clear();
17 }
18
19 void TrackedDictionary::ApplyUntrackedChanges(
20 const base::DictionaryValue& new_changes) {
21 current_values_.MergeDictionary(&new_changes);
22
23 for (base::DictionaryValue::Iterator it(new_changes); !it.IsAtEnd();
24 it.Advance()) {
25 changed_values_.Remove(it.key(), nullptr);
26 }
27 }
28
29 void TrackedDictionary::Set(const std::string& path,
30 std::unique_ptr<base::Value> new_value) {
31 // Is this truly a *new* value?
32 const base::Value* old_value;
33 if (current_values_.Get(path, &old_value)) {
34 if (base::Value::Equals(old_value, new_value.get()))
35 return;
36 }
37
38 changed_values_.Set(path, new_value->CreateDeepCopy());
39 current_values_.Set(path, std::move(new_value));
40 }
41
42 void TrackedDictionary::SetBoolean(const std::string& path, bool new_value) {
43 Set(path, base::MakeUnique<base::FundamentalValue>(new_value));
44 }
45
46 void TrackedDictionary::SetString(const std::string& path,
47 const std::string& new_value) {
48 Set(path, base::MakeUnique<base::StringValue>(new_value));
49 }
50
51 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698