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

Side by Side Diff: components/prefs/pref_service.h

Issue 1907043002: Convert //components/prefs from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IWYU fixes Created 4 years, 8 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 // This provides a way to access the application's current preferences. 5 // This provides a way to access the application's current preferences.
6 6
7 // Chromium settings and storage represent user-selected preferences and 7 // Chromium settings and storage represent user-selected preferences and
8 // information and MUST not be extracted, overwritten or modified except 8 // information and MUST not be extracted, overwritten or modified except
9 // through Chromium defined APIs. 9 // through Chromium defined APIs.
10 10
11 #ifndef COMPONENTS_PREFS_PREF_SERVICE_H_ 11 #ifndef COMPONENTS_PREFS_PREF_SERVICE_H_
12 #define COMPONENTS_PREFS_PREF_SERVICE_H_ 12 #define COMPONENTS_PREFS_PREF_SERVICE_H_
13 13
14 #include <stdint.h> 14 #include <stdint.h>
15 15
16 #include <memory>
16 #include <set> 17 #include <set>
17 #include <string> 18 #include <string>
18 19
19 #include "base/callback.h" 20 #include "base/callback.h"
20 #include "base/compiler_specific.h" 21 #include "base/compiler_specific.h"
21 #include "base/containers/hash_tables.h" 22 #include "base/containers/hash_tables.h"
22 #include "base/macros.h" 23 #include "base/macros.h"
23 #include "base/memory/ref_counted.h" 24 #include "base/memory/ref_counted.h"
24 #include "base/memory/scoped_ptr.h"
25 #include "base/observer_list.h" 25 #include "base/observer_list.h"
26 #include "base/threading/non_thread_safe.h" 26 #include "base/threading/non_thread_safe.h"
27 #include "base/values.h" 27 #include "base/values.h"
28 #include "components/prefs/base_prefs_export.h" 28 #include "components/prefs/base_prefs_export.h"
29 #include "components/prefs/persistent_pref_store.h" 29 #include "components/prefs/persistent_pref_store.h"
30 30
31 class PrefNotifier; 31 class PrefNotifier;
32 class PrefNotifierImpl; 32 class PrefNotifierImpl;
33 class PrefObserver; 33 class PrefObserver;
34 class PrefRegistry; 34 class PrefRegistry;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // registered preference. In that case, will never return NULL. 244 // registered preference. In that case, will never return NULL.
245 const base::Value* GetDefaultPrefValue(const std::string& path) const; 245 const base::Value* GetDefaultPrefValue(const std::string& path) const;
246 246
247 // Returns true if a value has been set for the specified path. 247 // Returns true if a value has been set for the specified path.
248 // NOTE: this is NOT the same as FindPreference. In particular 248 // NOTE: this is NOT the same as FindPreference. In particular
249 // FindPreference returns whether RegisterXXX has been invoked, where as 249 // FindPreference returns whether RegisterXXX has been invoked, where as
250 // this checks if a value exists for the path. 250 // this checks if a value exists for the path.
251 bool HasPrefPath(const std::string& path) const; 251 bool HasPrefPath(const std::string& path) const;
252 252
253 // Returns a dictionary with effective preference values. 253 // Returns a dictionary with effective preference values.
254 scoped_ptr<base::DictionaryValue> GetPreferenceValues() const; 254 std::unique_ptr<base::DictionaryValue> GetPreferenceValues() const;
255 255
256 // Returns a dictionary with effective preference values, omitting prefs that 256 // Returns a dictionary with effective preference values, omitting prefs that
257 // are at their default values. 257 // are at their default values.
258 scoped_ptr<base::DictionaryValue> GetPreferenceValuesOmitDefaults() const; 258 std::unique_ptr<base::DictionaryValue> GetPreferenceValuesOmitDefaults()
259 const;
259 260
260 // Returns a dictionary with effective preference values. Contrary to 261 // Returns a dictionary with effective preference values. Contrary to
261 // GetPreferenceValues(), the paths of registered preferences are not split on 262 // GetPreferenceValues(), the paths of registered preferences are not split on
262 // '.' characters. If a registered preference stores a dictionary, however, 263 // '.' characters. If a registered preference stores a dictionary, however,
263 // the hierarchical structure inside the preference will be preserved. 264 // the hierarchical structure inside the preference will be preserved.
264 // For example, if "foo.bar" is a registered preference, the result could look 265 // For example, if "foo.bar" is a registered preference, the result could look
265 // like this: 266 // like this:
266 // {"foo.bar": {"a": {"b": true}}}. 267 // {"foo.bar": {"a": {"b": true}}}.
267 scoped_ptr<base::DictionaryValue> GetPreferenceValuesWithoutPathExpansion() 268 std::unique_ptr<base::DictionaryValue>
268 const; 269 GetPreferenceValuesWithoutPathExpansion() const;
269 270
270 bool ReadOnly() const; 271 bool ReadOnly() const;
271 272
272 PrefInitializationStatus GetInitializationStatus() const; 273 PrefInitializationStatus GetInitializationStatus() const;
273 274
274 // Tell our PrefValueStore to update itself to |command_line_store|. 275 // Tell our PrefValueStore to update itself to |command_line_store|.
275 // Takes ownership of the store. 276 // Takes ownership of the store.
276 virtual void UpdateCommandLinePrefStore(PrefStore* command_line_store); 277 virtual void UpdateCommandLinePrefStore(PrefStore* command_line_store);
277 278
278 // We run the callback once, when initialization completes. The bool 279 // We run the callback once, when initialization completes. The bool
(...skipping 16 matching lines...) Expand all
295 // implemented in chrome/browser/prefs/browser_prefs.cc. 296 // implemented in chrome/browser/prefs/browser_prefs.cc.
296 PrefRegistry* DeprecatedGetPrefRegistry(); 297 PrefRegistry* DeprecatedGetPrefRegistry();
297 298
298 // Clears mutable values. 299 // Clears mutable values.
299 void ClearMutableValues(); 300 void ClearMutableValues();
300 301
301 protected: 302 protected:
302 // The PrefNotifier handles registering and notifying preference observers. 303 // The PrefNotifier handles registering and notifying preference observers.
303 // It is created and owned by this PrefService. Subclasses may access it for 304 // It is created and owned by this PrefService. Subclasses may access it for
304 // unit testing. 305 // unit testing.
305 scoped_ptr<PrefNotifierImpl> pref_notifier_; 306 std::unique_ptr<PrefNotifierImpl> pref_notifier_;
306 307
307 // The PrefValueStore provides prioritized preference values. It is owned by 308 // The PrefValueStore provides prioritized preference values. It is owned by
308 // this PrefService. Subclasses may access it for unit testing. 309 // this PrefService. Subclasses may access it for unit testing.
309 scoped_ptr<PrefValueStore> pref_value_store_; 310 std::unique_ptr<PrefValueStore> pref_value_store_;
310 311
311 scoped_refptr<PrefRegistry> pref_registry_; 312 scoped_refptr<PrefRegistry> pref_registry_;
312 313
313 // Pref Stores and profile that we passed to the PrefValueStore. 314 // Pref Stores and profile that we passed to the PrefValueStore.
314 scoped_refptr<PersistentPrefStore> user_pref_store_; 315 scoped_refptr<PersistentPrefStore> user_pref_store_;
315 316
316 // Callback to call when a read error occurs. 317 // Callback to call when a read error occurs.
317 base::Callback<void(PersistentPrefStore::PrefReadError)> read_error_callback_; 318 base::Callback<void(PersistentPrefStore::PrefReadError)> read_error_callback_;
318 319
319 private: 320 private:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 380
380 // Local cache of registered Preference objects. The pref_registry_ 381 // Local cache of registered Preference objects. The pref_registry_
381 // is authoritative with respect to what the types and default values 382 // is authoritative with respect to what the types and default values
382 // of registered preferences are. 383 // of registered preferences are.
383 mutable PreferenceMap prefs_map_; 384 mutable PreferenceMap prefs_map_;
384 385
385 DISALLOW_COPY_AND_ASSIGN(PrefService); 386 DISALLOW_COPY_AND_ASSIGN(PrefService);
386 }; 387 };
387 388
388 #endif // COMPONENTS_PREFS_PREF_SERVICE_H_ 389 #endif // COMPONENTS_PREFS_PREF_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698