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

Side by Side Diff: chrome/browser/prefs/scoped_user_pref_update.cc

Issue 12211105: Move remaining non-test, non-Chrome-specific Prefs code to base/prefs/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments, merge to LKGR. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/prefs/scoped_user_pref_update.h" 5 #include "chrome/browser/prefs/scoped_user_pref_update.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/prefs/pref_notifier.h" 8 #include "base/prefs/pref_notifier.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 10
11 namespace subtle { 11 namespace subtle {
12 12
13 ScopedUserPrefUpdateBase::ScopedUserPrefUpdateBase(PrefService* service, 13 ScopedUserPrefUpdateBase::ScopedUserPrefUpdateBase(PrefService* service,
14 const char* path) 14 const char* path)
15 : service_(service), 15 : service_(service),
16 path_(path), 16 path_(path),
17 value_(NULL) {} 17 value_(NULL) {}
18 18
19 ScopedUserPrefUpdateBase::~ScopedUserPrefUpdateBase() { 19 ScopedUserPrefUpdateBase::~ScopedUserPrefUpdateBase() {
20 Notify(); 20 Notify();
21 } 21 }
22 22
23 Value* ScopedUserPrefUpdateBase::GetValueOfType(base::Value::Type type) { 23 Value* ScopedUserPrefUpdateBase::GetValueOfType(base::Value::Type type) {
24 if (!value_) 24 if (!value_)
25 value_ = service_->GetMutableUserPref(path_.c_str(), type); 25 value_ = service_->GetMutableUserPref(path_.c_str(), type);
26 return value_; 26 return value_;
27 } 27 }
28 28
29 void ScopedUserPrefUpdateBase::Notify() { 29 void ScopedUserPrefUpdateBase::Notify() {
30 if (value_) { 30 if (value_) {
31 service_->ReportUserPrefChanged(path_); 31 service_->ReportUserPrefChanged(path_);
32 value_ = NULL; 32 value_ = NULL;
33 } 33 }
34 } 34 }
35 35
36 } // namespace subtle 36 } // namespace subtle
OLDNEW
« no previous file with comments | « chrome/browser/prefs/scoped_user_pref_update.h ('k') | chrome/browser/prefs/scoped_user_pref_update_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698