OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_SCREEN_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_SCREEN_CONTEXT_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_SCREEN_CONTEXT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_SCREEN_CONTEXT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // Stores all changes since the last call to the | 77 // Stores all changes since the last call to the |
78 // GetChangesAndReset() in |diff|. All previous contents of |diff| | 78 // GetChangesAndReset() in |diff|. All previous contents of |diff| |
79 // will be thrown away. | 79 // will be thrown away. |
80 void GetChangesAndReset(base::DictionaryValue* diff); | 80 void GetChangesAndReset(base::DictionaryValue* diff); |
81 | 81 |
82 // Applies changes from |diff| to the context. All keys from |diff| | 82 // Applies changes from |diff| to the context. All keys from |diff| |
83 // are stored in |keys|. |keys| argument is optional and can be NULL. | 83 // are stored in |keys|. |keys| argument is optional and can be NULL. |
84 void ApplyChanges(const base::DictionaryValue& diff, | 84 void ApplyChanges(const base::DictionaryValue& diff, |
85 std::vector<std::string>* keys); | 85 std::vector<std::string>* keys); |
86 | 86 |
| 87 // Returns underlying dictionary containing all the stored data. |
| 88 const base::DictionaryValue& storage() const { return storage_; } |
| 89 |
87 private: | 90 private: |
88 bool Set(const KeyType& key, base::Value* value); | 91 bool Set(const KeyType& key, base::Value* value); |
89 | 92 |
90 template <typename T> | 93 template <typename T> |
91 T Get(const KeyType& key) const { | 94 T Get(const KeyType& key) const { |
92 DCHECK(CalledOnValidThread()); | 95 DCHECK(CalledOnValidThread()); |
93 const base::Value* value; | 96 const base::Value* value; |
94 bool has_key = storage_.Get(key, &value); | 97 bool has_key = storage_.Get(key, &value); |
95 DCHECK(has_key); | 98 DCHECK(has_key); |
96 T result; | 99 T result; |
(...skipping 17 matching lines...) Expand all Loading... |
114 | 117 |
115 // Contains all pending changes. | 118 // Contains all pending changes. |
116 base::DictionaryValue changes_; | 119 base::DictionaryValue changes_; |
117 | 120 |
118 DISALLOW_COPY_AND_ASSIGN(ScreenContext); | 121 DISALLOW_COPY_AND_ASSIGN(ScreenContext); |
119 }; | 122 }; |
120 | 123 |
121 } // namespace chromeos | 124 } // namespace chromeos |
122 | 125 |
123 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_SCREEN_CONTEXT_H_ | 126 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_SCREEN_CONTEXT_H_ |
OLD | NEW |