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

Unified Diff: base/prefs/scoped_user_pref_update.cc

Issue 1645073005: Revert of Move base/prefs to components/prefs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/prefs/scoped_user_pref_update.h ('k') | base/prefs/scoped_user_pref_update_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/prefs/scoped_user_pref_update.cc
diff --git a/base/prefs/scoped_user_pref_update.cc b/base/prefs/scoped_user_pref_update.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1440a5711d8f911d545dbcbbc792abb464bb13de
--- /dev/null
+++ b/base/prefs/scoped_user_pref_update.cc
@@ -0,0 +1,37 @@
+// Copyright 2013 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 "base/prefs/scoped_user_pref_update.h"
+
+#include "base/logging.h"
+#include "base/prefs/pref_notifier.h"
+#include "base/prefs/pref_service.h"
+
+namespace subtle {
+
+ScopedUserPrefUpdateBase::ScopedUserPrefUpdateBase(PrefService* service,
+ const std::string& path)
+ : service_(service), path_(path), value_(NULL) {
+ DCHECK(service_->CalledOnValidThread());
+}
+
+ScopedUserPrefUpdateBase::~ScopedUserPrefUpdateBase() {
+ Notify();
+}
+
+base::Value* ScopedUserPrefUpdateBase::GetValueOfType(base::Value::Type type) {
+ DCHECK(CalledOnValidThread());
+ if (!value_)
+ value_ = service_->GetMutableUserPref(path_, type);
+ return value_;
+}
+
+void ScopedUserPrefUpdateBase::Notify() {
+ if (value_) {
+ service_->ReportUserPrefChanged(path_);
+ value_ = NULL;
+ }
+}
+
+} // namespace subtle
« no previous file with comments | « base/prefs/scoped_user_pref_update.h ('k') | base/prefs/scoped_user_pref_update_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698