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

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

Issue 1921923002: Convert //components/[o-t]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 "components/test_runner/tracked_dictionary.h" 5 #include "components/test_runner/tracked_dictionary.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h"
10
9 namespace test_runner { 11 namespace test_runner {
10 12
11 TrackedDictionary::TrackedDictionary() {} 13 TrackedDictionary::TrackedDictionary() {}
12 14
13 void TrackedDictionary::ResetChangeTracking() { 15 void TrackedDictionary::ResetChangeTracking() {
14 changed_values_.Clear(); 16 changed_values_.Clear();
15 } 17 }
16 18
17 void TrackedDictionary::ApplyUntrackedChanges( 19 void TrackedDictionary::ApplyUntrackedChanges(
18 const base::DictionaryValue& new_changes) { 20 const base::DictionaryValue& new_changes) {
19 current_values_.MergeDictionary(&new_changes); 21 current_values_.MergeDictionary(&new_changes);
20 22
21 for (base::DictionaryValue::Iterator it(new_changes); !it.IsAtEnd(); 23 for (base::DictionaryValue::Iterator it(new_changes); !it.IsAtEnd();
22 it.Advance()) { 24 it.Advance()) {
23 changed_values_.Remove(it.key(), nullptr); 25 changed_values_.Remove(it.key(), nullptr);
24 } 26 }
25 } 27 }
26 28
27 void TrackedDictionary::Set(const std::string& path, 29 void TrackedDictionary::Set(const std::string& path,
28 scoped_ptr<base::Value> new_value) { 30 std::unique_ptr<base::Value> new_value) {
29 // Is this truly a *new* value? 31 // Is this truly a *new* value?
30 const base::Value* old_value; 32 const base::Value* old_value;
31 if (current_values_.Get(path, &old_value)) { 33 if (current_values_.Get(path, &old_value)) {
32 if (base::Value::Equals(old_value, new_value.get())) 34 if (base::Value::Equals(old_value, new_value.get()))
33 return; 35 return;
34 } 36 }
35 37
36 changed_values_.Set(path, new_value->CreateDeepCopy()); 38 changed_values_.Set(path, new_value->CreateDeepCopy());
37 current_values_.Set(path, std::move(new_value)); 39 current_values_.Set(path, std::move(new_value));
38 } 40 }
39 41
40 void TrackedDictionary::SetBoolean(const std::string& path, bool new_value) { 42 void TrackedDictionary::SetBoolean(const std::string& path, bool new_value) {
41 Set(path, make_scoped_ptr(new base::FundamentalValue(new_value))); 43 Set(path, base::WrapUnique(new base::FundamentalValue(new_value)));
42 } 44 }
43 45
44 void TrackedDictionary::SetString(const std::string& path, 46 void TrackedDictionary::SetString(const std::string& path,
45 const std::string& new_value) { 47 const std::string& new_value) {
46 Set(path, make_scoped_ptr(new base::StringValue(new_value))); 48 Set(path, base::WrapUnique(new base::StringValue(new_value)));
47 } 49 }
48 50
49 } // namespace test_runner 51 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/tracked_dictionary.h ('k') | components/test_runner/web_frame_test_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698