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

Unified Diff: chrome/browser/prefs/pref_service_syncable.h

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review. Created 8 years 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
Index: chrome/browser/prefs/pref_service_syncable.h
diff --git a/chrome/browser/prefs/pref_service_syncable.h b/chrome/browser/prefs/pref_service_syncable.h
new file mode 100644
index 0000000000000000000000000000000000000000..2df79c0fe93b6f148797871aea2f0e288cb69276
--- /dev/null
+++ b/chrome/browser/prefs/pref_service_syncable.h
@@ -0,0 +1,138 @@
+// 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.
+
+#ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_
+#define CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_
+
+#include "chrome/browser/prefs/pref_model_associator.h"
+#include "chrome/browser/prefs/pref_service.h"
+
+// TODO(joi) Move to c/b/prefs and rename PrefServiceSyncableObserver.
+class PrefServiceObserver;
+
+namespace syncer {
+class SyncableService;
+}
+
+// A PrefService that can be synced. Users are forced to declare
+// whether preferences are syncable or not when registering them to
+// this PrefService.
+class PrefServiceSyncable : public PrefService {
+ public:
+ // Enum used when registering preferences to determine if it should be synced
+ // or not. This is only used for profile prefs, not local state prefs.
+ // See the Register*Pref methods for profile prefs below.
+ enum PrefSyncStatus {
+ UNSYNCABLE_PREF,
+ SYNCABLE_PREF
+ };
+
+ virtual ~PrefServiceSyncable();
+
+ // Creates an incognito copy of the pref service that shares most pref stores
+ // but uses a fresh non-persistent overlay for the user pref store and an
+ // individual extension pref store (to cache the effective extension prefs for
+ // incognito windows).
+ PrefServiceSyncable* CreateIncognitoPrefService(
+ PrefStore* incognito_extension_prefs);
+
+ // Returns true if preferences state has synchronized with the remote
+ // preferences. If true is returned it can be assumed the local preferences
+ // has applied changes from the remote preferences. The two may not be
+ // identical if a change is in flight (from either side).
+ bool IsSyncing();
+
+ void AddObserver(PrefServiceObserver* observer);
+ void RemoveObserver(PrefServiceObserver* observer);
+
+ virtual void UnregisterPreference(const char* path) OVERRIDE;
+
+ void RegisterBooleanPref(const char* path,
+ bool default_value,
+ PrefSyncStatus sync_status);
+ void RegisterIntegerPref(const char* path,
+ int default_value,
+ PrefSyncStatus sync_status);
+ void RegisterDoublePref(const char* path,
+ double default_value,
+ PrefSyncStatus sync_status);
+ void RegisterStringPref(const char* path,
+ const std::string& default_value,
+ PrefSyncStatus sync_status);
+ void RegisterFilePathPref(const char* path,
+ const FilePath& default_value,
+ PrefSyncStatus sync_status);
+ void RegisterListPref(const char* path,
+ PrefSyncStatus sync_status);
+ void RegisterDictionaryPref(const char* path,
+ PrefSyncStatus sync_status);
+ void RegisterListPref(const char* path,
+ base::ListValue* default_value,
+ PrefSyncStatus sync_status);
+ void RegisterDictionaryPref(const char* path,
+ base::DictionaryValue* default_value,
+ PrefSyncStatus sync_status);
+ void RegisterLocalizedBooleanPref(const char* path,
+ int locale_default_message_id,
+ PrefSyncStatus sync_status);
+ void RegisterLocalizedIntegerPref(const char* path,
+ int locale_default_message_id,
+ PrefSyncStatus sync_status);
+ void RegisterLocalizedDoublePref(const char* path,
+ int locale_default_message_id,
+ PrefSyncStatus sync_status);
+ void RegisterLocalizedStringPref(const char* path,
+ int locale_default_message_id,
+ PrefSyncStatus sync_status);
+ void RegisterInt64Pref(const char* path,
+ int64 default_value,
+ PrefSyncStatus sync_status);
+ void RegisterUint64Pref(const char* path,
+ uint64 default_value,
+ PrefSyncStatus sync_status);
+
+ // syncer::SyncableService getter.
+ // TODO(zea): Have PrefService implement syncer::SyncableService directly.
Mattias Nissler (ping if slow) 2012/12/20 13:41:52 update comment
Jói 2012/12/20 16:30:31 Done.
+ syncer::SyncableService* GetSyncableService();
+
+ // Do not call this after having derived an incognito or per tab pref service.
+ virtual void UpdateCommandLinePrefStore(PrefStore* cmd_line_store) OVERRIDE;
+
+ protected:
+ // Only use ChromePrefServiceFactory to create initialized PrefServiceSyncable
+ // objects.
+ PrefServiceSyncable();
+
+ virtual void Initialize(
+ PrefNotifierImpl* pref_notifier,
+ PrefValueStore* pref_value_store,
+ PersistentPrefStore* user_prefs,
+ DefaultPrefStore* default_store,
+ base::Callback<void(PersistentPrefStore::PrefReadError)>
+ read_error_callback,
+ bool async) OVERRIDE;
+
+ private:
+ friend class PrefModelAssociator;
+
+ // Constructs objects.
Mattias Nissler (ping if slow) 2012/12/20 13:41:52 s/objects/instances/
Jói 2012/12/20 16:30:31 Done.
+ friend class ChromePrefServiceFactory;
+ friend class PrefServiceMockBuilder;
+
+ // Invoked internally when the IsSyncing() state changes.
+ void OnIsSyncingChanged();
+
Mattias Nissler (ping if slow) 2012/12/20 13:41:52 documentation.
Jói 2012/12/20 16:30:31 Done.
+ void RegisterSyncablePreference(
+ const char* path, Value* default_value, PrefSyncStatus sync_status);
Mattias Nissler (ping if slow) 2012/12/20 13:41:52 param decls on separate lines.
Jói 2012/12/20 16:30:31 Done.
+
+ // Whether CreateIncognitoPrefService() has been called to create a
+ // "forked" PrefService.
+ bool pref_service_forked_;
+
+ PrefModelAssociator pref_sync_associator_;
+
+ ObserverList<PrefServiceObserver> observer_list_;
Mattias Nissler (ping if slow) 2012/12/20 13:41:52 DISALLOW_COPY_AND_ASSIGN
Jói 2012/12/20 16:30:31 Done.
+};
+
+#endif // CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_

Powered by Google App Engine
This is Rietveld 408576698