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

Side by Side Diff: components/prefs/value_map_pref_store.cc

Issue 2444753002: Reduce usage of FOR_EACH_OBSERVER macro in components/ (Closed)
Patch Set: Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/prefs/value_map_pref_store.h" 5 #include "components/prefs/value_map_pref_store.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 14 matching lines...) Expand all
25 observers_.RemoveObserver(observer); 25 observers_.RemoveObserver(observer);
26 } 26 }
27 27
28 bool ValueMapPrefStore::HasObservers() const { 28 bool ValueMapPrefStore::HasObservers() const {
29 return observers_.might_have_observers(); 29 return observers_.might_have_observers();
30 } 30 }
31 31
32 void ValueMapPrefStore::SetValue(const std::string& key, 32 void ValueMapPrefStore::SetValue(const std::string& key,
33 std::unique_ptr<base::Value> value, 33 std::unique_ptr<base::Value> value,
34 uint32_t flags) { 34 uint32_t flags) {
35 if (prefs_.SetValue(key, std::move(value))) 35 if (prefs_.SetValue(key, std::move(value))) {
36 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); 36 for (Observer& observer : observers_)
37 observer.OnPrefValueChanged(key);
38 }
37 } 39 }
38 40
39 void ValueMapPrefStore::RemoveValue(const std::string& key, uint32_t flags) { 41 void ValueMapPrefStore::RemoveValue(const std::string& key, uint32_t flags) {
40 if (prefs_.RemoveValue(key)) 42 if (prefs_.RemoveValue(key)) {
41 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); 43 for (Observer& observer : observers_)
44 observer.OnPrefValueChanged(key);
45 }
42 } 46 }
43 47
44 bool ValueMapPrefStore::GetMutableValue(const std::string& key, 48 bool ValueMapPrefStore::GetMutableValue(const std::string& key,
45 base::Value** value) { 49 base::Value** value) {
46 return prefs_.GetValue(key, value); 50 return prefs_.GetValue(key, value);
47 } 51 }
48 52
49 void ValueMapPrefStore::ReportValueChanged(const std::string& key, 53 void ValueMapPrefStore::ReportValueChanged(const std::string& key,
50 uint32_t flags) { 54 uint32_t flags) {
51 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); 55 for (Observer& observer : observers_)
56 observer.OnPrefValueChanged(key);
52 } 57 }
53 58
54 void ValueMapPrefStore::SetValueSilently(const std::string& key, 59 void ValueMapPrefStore::SetValueSilently(const std::string& key,
55 std::unique_ptr<base::Value> value, 60 std::unique_ptr<base::Value> value,
56 uint32_t flags) { 61 uint32_t flags) {
57 prefs_.SetValue(key, std::move(value)); 62 prefs_.SetValue(key, std::move(value));
58 } 63 }
59 64
60 ValueMapPrefStore::~ValueMapPrefStore() {} 65 ValueMapPrefStore::~ValueMapPrefStore() {}
61 66
62 void ValueMapPrefStore::NotifyInitializationCompleted() { 67 void ValueMapPrefStore::NotifyInitializationCompleted() {
63 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(true)); 68 for (Observer& observer : observers_)
69 observer.OnInitializationCompleted(true);
64 } 70 }
OLDNEW
« no previous file with comments | « components/prefs/testing_pref_store.cc ('k') | components/proxy_config/pref_proxy_config_tracker_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698