OLD | NEW |
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 #ifndef COMPONENTS_TEST_RUNNER_TRACKED_DICTIONARY_H_ | 5 #ifndef COMPONENTS_TEST_RUNNER_TRACKED_DICTIONARY_H_ |
6 #define COMPONENTS_TEST_RUNNER_TRACKED_DICTIONARY_H_ | 6 #define COMPONENTS_TEST_RUNNER_TRACKED_DICTIONARY_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "components/test_runner/test_runner_export.h" | 13 #include "components/test_runner/test_runner_export.h" |
14 | 14 |
15 namespace test_runner { | 15 namespace test_runner { |
16 | 16 |
17 // TrackedDictionary wraps base::DictionaryValue, but forces all mutations to go | 17 // TrackedDictionary wraps base::DictionaryValue, but forces all mutations to go |
18 // through TrackedDictionary's Set methods. This allows tracking of changes | 18 // through TrackedDictionary's Set methods. This allows tracking of changes |
19 // accumulated since the last call to ResetChangeTracking. | 19 // accumulated since the last call to ResetChangeTracking. |
20 class TEST_RUNNER_EXPORT TrackedDictionary { | 20 class TEST_RUNNER_EXPORT TrackedDictionary { |
21 public: | 21 public: |
(...skipping 11 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 // Clears out |changed_values|. | 35 // Clears out |changed_values|. |
36 void ResetChangeTracking(); | 36 void ResetChangeTracking(); |
37 | 37 |
38 // Overwrites |current_values| with values present in |new_changes|. | 38 // Overwrites |current_values| with values present in |new_changes|. |
39 // The new values are not present in |changed_values| afterwards. | 39 // The new values are not present in |changed_values| afterwards. |
40 void ApplyUntrackedChanges(const base::DictionaryValue& new_changes); | 40 void ApplyUntrackedChanges(const base::DictionaryValue& new_changes); |
41 | 41 |
42 // Sets a value in |current_values| and tracks the change in |changed_values|. | 42 // Sets a value in |current_values| and tracks the change in |changed_values|. |
43 void Set(const std::string& path, scoped_ptr<base::Value> new_value); | 43 void Set(const std::string& path, std::unique_ptr<base::Value> new_value); |
44 | 44 |
45 // Type-specific setter for convenience. | 45 // Type-specific setter for convenience. |
46 void SetBoolean(const std::string& path, bool new_value); | 46 void SetBoolean(const std::string& path, bool new_value); |
47 void SetString(const std::string& path, const std::string& new_value); | 47 void SetString(const std::string& path, const std::string& new_value); |
48 | 48 |
49 private: | 49 private: |
50 base::DictionaryValue current_values_; | 50 base::DictionaryValue current_values_; |
51 base::DictionaryValue changed_values_; | 51 base::DictionaryValue changed_values_; |
52 | 52 |
53 DISALLOW_COPY_AND_ASSIGN(TrackedDictionary); | 53 DISALLOW_COPY_AND_ASSIGN(TrackedDictionary); |
54 }; | 54 }; |
55 | 55 |
56 } // namespace test_runner | 56 } // namespace test_runner |
57 | 57 |
58 #endif // COMPONENTS_TEST_RUNNER_TRACKED_DICTIONARY_H_ | 58 #endif // COMPONENTS_TEST_RUNNER_TRACKED_DICTIONARY_H_ |
OLD | NEW |