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

Side by Side Diff: services/preferences/tracked/segregated_pref_store.cc

Issue 2782803002: Move tracked prefs into services/preferences/tracked. (Closed)
Patch Set: rebase Created 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/user_prefs/tracked/segregated_pref_store.h" 5 #include "services/preferences/tracked/segregated_pref_store.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 12
13 SegregatedPrefStore::AggregatingObserver::AggregatingObserver( 13 SegregatedPrefStore::AggregatingObserver::AggregatingObserver(
14 SegregatedPrefStore* outer) 14 SegregatedPrefStore* outer)
15 : outer_(outer), 15 : outer_(outer),
16 failed_sub_initializations_(0), 16 failed_sub_initializations_(0),
17 successful_sub_initializations_(0) { 17 successful_sub_initializations_(0) {}
18 }
19 18
20 void SegregatedPrefStore::AggregatingObserver::OnPrefValueChanged( 19 void SegregatedPrefStore::AggregatingObserver::OnPrefValueChanged(
21 const std::string& key) { 20 const std::string& key) {
22 // There is no need to tell clients about changes if they have not yet been 21 // There is no need to tell clients about changes if they have not yet been
23 // told about initialization. 22 // told about initialization.
24 if (failed_sub_initializations_ + successful_sub_initializations_ < 2) 23 if (failed_sub_initializations_ + successful_sub_initializations_ < 2)
25 return; 24 return;
26 25
27 for (auto& observer : outer_->observers_) 26 for (auto& observer : outer_->observers_)
28 observer.OnPrefValueChanged(key); 27 observer.OnPrefValueChanged(key);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 .get(); 184 .get();
186 } 185 }
187 186
188 const PersistentPrefStore* SegregatedPrefStore::StoreForKey( 187 const PersistentPrefStore* SegregatedPrefStore::StoreForKey(
189 const std::string& key) const { 188 const std::string& key) const {
190 return (base::ContainsKey(selected_preference_names_, key) 189 return (base::ContainsKey(selected_preference_names_, key)
191 ? selected_pref_store_ 190 ? selected_pref_store_
192 : default_pref_store_) 191 : default_pref_store_)
193 .get(); 192 .get();
194 } 193 }
OLDNEW
« no previous file with comments | « services/preferences/tracked/segregated_pref_store.h ('k') | services/preferences/tracked/segregated_pref_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698