forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalue_map_pref_store.cc
64 lines (49 loc) · 2.05 KB
/
value_map_pref_store.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/prefs/value_map_pref_store.h"
#include <algorithm>
#include <utility>
#include "base/stl_util.h"
#include "base/values.h"
ValueMapPrefStore::ValueMapPrefStore() {}
bool ValueMapPrefStore::GetValue(const std::string& key,
const base::Value** value) const {
return prefs_.GetValue(key, value);
}
void ValueMapPrefStore::AddObserver(PrefStore::Observer* observer) {
observers_.AddObserver(observer);
}
void ValueMapPrefStore::RemoveObserver(PrefStore::Observer* observer) {
observers_.RemoveObserver(observer);
}
bool ValueMapPrefStore::HasObservers() const {
return observers_.might_have_observers();
}
void ValueMapPrefStore::SetValue(const std::string& key,
scoped_ptr<base::Value> value,
uint32_t flags) {
if (prefs_.SetValue(key, std::move(value)))
FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key));
}
void ValueMapPrefStore::RemoveValue(const std::string& key, uint32_t flags) {
if (prefs_.RemoveValue(key))
FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key));
}
bool ValueMapPrefStore::GetMutableValue(const std::string& key,
base::Value** value) {
return prefs_.GetValue(key, value);
}
void ValueMapPrefStore::ReportValueChanged(const std::string& key,
uint32_t flags) {
FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key));
}
void ValueMapPrefStore::SetValueSilently(const std::string& key,
scoped_ptr<base::Value> value,
uint32_t flags) {
prefs_.SetValue(key, std::move(value));
}
ValueMapPrefStore::~ValueMapPrefStore() {}
void ValueMapPrefStore::NotifyInitializationCompleted() {
FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(true));
}