Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / base / prefs / scoped_user_pref_update.cc
blob1440a5711d8f911d545dbcbbc792abb464bb13de
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/prefs/scoped_user_pref_update.h"
7 #include "base/logging.h"
8 #include "base/prefs/pref_notifier.h"
9 #include "base/prefs/pref_service.h"
11 namespace subtle {
13 ScopedUserPrefUpdateBase::ScopedUserPrefUpdateBase(PrefService* service,
14 const std::string& path)
15 : service_(service), path_(path), value_(NULL) {
16 DCHECK(service_->CalledOnValidThread());
19 ScopedUserPrefUpdateBase::~ScopedUserPrefUpdateBase() {
20 Notify();
23 base::Value* ScopedUserPrefUpdateBase::GetValueOfType(base::Value::Type type) {
24 DCHECK(CalledOnValidThread());
25 if (!value_)
26 value_ = service_->GetMutableUserPref(path_, type);
27 return value_;
30 void ScopedUserPrefUpdateBase::Notify() {
31 if (value_) {
32 service_->ReportUserPrefChanged(path_);
33 value_ = NULL;
37 } // namespace subtle